implementation
uses mmSystem,registry,sysutils;
....
procedure VolumenMidi(VOLUMEN_MIDI_R, VOLUMEN_MIDI_L:integer);
var MidiOutPutDev:string;
amt,MidiOutputDevid,t:integer;
MidiCap:TMIDIOUTCAPS;
begin
with TRegistry.Create do
begin
RootKey := HKEY_CURRENT_USER;
OpenKey('Software\Microsoft\Windows\CurrentVersion\Multimedia\MIDIMap', false);
if ValueExists('CurrentInstrument') then
MidiOutPutDev := ReadString('CurrentInstrument');
free;
end;
amt := MidiOutGetNumDevs;
MidiOutputDevid := - 1;
for t := 0 to amt-1 do
begin
MidiOutGetDevCaps(t, @Midicap, Sizeof(Midicap));
if StrPas(@MidiCap.szPName)= MidiOutPutDev then
MidiOutputDevid := t;
end;
midiOutSetVolume(MidiOutputDevid, (VOLUMEN_MIDI_R shl 16) + VOLUMEN_MIDI_L);
end;