Einzelnen Beitrag anzeigen

Benutzerbild von turboPASCAL
turboPASCAL

Registriert seit: 8. Mai 2005
Ort: Sondershausen
4.274 Beiträge
 
Delphi 6 Personal
 
#5

Re: Warum ist diese Soundkomponente stumm?

  Alt 9. Dez 2008, 16:46
Es kommt kein Ton weil er nicht hötbar ist.

Delphi-Quellcode:
const
  NOTE_ON = $90;
  NOTE_OFF = $80;

var
  MidiNote: Cardinal;

  function MakeMidiNote(Octave, Note, Velocity: Byte): Cardinal; { Cardinal = DWORD }
  begin
    // 0..127 Octave
    // Note 0..11 -> C, C#, D, D#, E, F, F#, G, G#, A, A#, H
    // Velocity 0..127 -> Lautstärke der Note

    Result := (((Octave + 2) * 12 or Note mod 12) shl 8) or (Velocity shl 16);
  end;

procedure TPianokey.MouseDown(Button:TMouseButton; Shift: TShiftstate; X, Y: Integer);
begin
  inherited MouseDown(Button,Shift,X,Y);
  if (Button=mbLeft) and (midiOut<>0) then
  begin
    // midiOutShortMsg(midiOut, $FF0090+(256*FNote));

    MidiNote := MakeMidiNote(Octave, FNote, 100);
    midiOutShortMsg(midiOut, MidiNote or NOTE_ON);
  end;
end;

procedure TPianokey.MouseUp(Button:TMouseButton; Shift: TShiftstate; X, Y: Integer);
begin
  inherited MouseUp(Button,Shift,X,Y);
  if (Button=mbLeft) and (midiOut<>0) then
  begin
   // midiOutShortMsg(midiOut, $80+(256*FNote));
   midiOutShortMsg(midiOut, MidiNote or NOTE_OFF);
  end;
end;
Auf diese Weise lässt es sich besser lesen.
Matti
Meine Software-Projekte - Homepage - Grüße vom Rüsselmops -Mops Mopser
  Mit Zitat antworten Zitat