Reputation: 10368
What is a good Delphi library for MIDI input/output?
Upvotes: 5
Views: 10858
Reputation: 11
Mon 4/14/2014 9:49 am. Since I'm not allowed to comment, I'll try answering: I cast my living-in-the-past vote for the midimountain.com candidate. I got the demo_MidiDevices_D6.zip (get it on the page http://www.midimountain.com/delphi_midi.html, not the "download" link), unzipped it, and it compiled without incident in my antique Delphi 7 and ran. I haven't actually tested if it does MIDI, but it did show my menagerie of attached MIDI devices....
Upvotes: 1
Reputation: 693
I've used these components for over 6 months now with great success. They should be evaluated with all the others in the follow up posts.
http://sourceforge.net/projects/midisequencer/
Upvotes: 3
Reputation: 78
Just a small extra info: The SourceForge "dmidi" project is actually the same as the "midiio" on BitBucket (but the development happens here).
Upvotes: 1
Reputation: 10368
A very simple MIDI in/out class: www.midimountain.com/delphi_midi.html
It looks like a good starting point if you would like to roll your own and use the windows API.
Upvotes: 2
Reputation: 24086
I've been using these components for ages:
http://bitbucket.org/h4ndy/midiio-dev
They've hardly ever failed on me, and unlike many other specialized Delphi components that have been around for this long, this code is pretty much alive (updates and improvements added recently).
Nothing fancy, but it's easy to use, fast, and rock solid. If you plan to do serious midi stuff, you'll eventually end up using this.
Upvotes: 3
Reputation: 108963
Are you sure that you really need a third-party library? If your needs are basic, the Windows API is all you need (using MMSystem
).
var
mo: HMIDIOUT;
const
MIDI_NOTE_ON = $90;
MIDI_NOTE_OFF = $80;
MIDI_CHANGE_INSTRUMENT = $C0;
MIDI_DEVICE = 0;
MIDI_VEL = 108;
procedure MIDIInit;
begin
midiOutOpen(@mo, MIDI_DEVICE, 0, 0, CALLBACK_NULL);
SetPlaybackVolume($FFFFFFFF);
end;
function MIDIEncodeMessage(Msg, Param1, Param2: integer): integer;
begin
result := Msg + (Param1 shl 8) + (Param2 shl 16);
end;
procedure SetCurrentInstrument(CurrentInstrument: TMIDIInstrument);
begin
midiOutShortMsg(mo, MIDIEncodeMessage(MIDI_CHANGE_INSTRUMENT, ord(CurrentInstrument), 0));
end;
procedure NoteOn(NewNote, NewIntensity: byte);
begin
midiOutShortMsg(mo, MIDIEncodeMessage(MIDI_NOTE_ON, NewNote, NewIntensity));
end;
procedure NoteOff(NewNote, NewIntensity: byte);
begin
midiOutShortMsg(mo, MIDIEncodeMessage(MIDI_NOTE_OFF, NewNote, NewIntensity));
end;
procedure SetPlaybackVolume(PlaybackVolume: cardinal);
begin
midiOutSetVolume(mo, PlaybackVolume);
end;
where the instruments are
type
TMIDIInstrument = (midiAcousticGrandPiano, midiBrightAcousticPiano,
midiElectricGrandPiano, midiHonkyTonkPiano,
midiRhodesPiano, midiChorusedPiano, midiHarpsichord,
midiClavinet, midiCelesta, midiGlockenspiel,
midiMusicBox, midiVibraphone, midiMarimba, midiXylophone,
midiTubularBells, midiDulcimer, midiHammondOrgan,
midiPercussiveOrgan, midiRockOrgan, midiChurchOrgan,
midiReedOrgan, midiAccordion, midiHarmonica,
midiTangoAccordion, midiAcousticGuitarNylon,
midiAcousticGuitarSteel, midiElectricGuitarJazz,
midiElectricGuitarClean, midiElectricGuitarMuted,
midiOverdrivenGuitar, midiDistortionGuitar,
midiGuitarHarmonics, midiAcousticBass, midiElectricBassFinger,
midiElectricBassPick, midiFretlessBass, midiSlapBass1,
midiSlapBass2, midiSynthBass1, midiSynthBass2, midiViolin,
midiViola, midiCello, midiContrabass, midiTremoloStrings,
midiPizzicatoStrings, midiOrchestralHarp, midiTimpani,
midiStringEnsemble1, midiStringEnsemble2, midiSynthStrings1,
midiSynthStrings2, midiChoirAahs, midiVoiceOohs,
midiSynthVoice, midiOrchestraHit, midiTrumpet, midiTrombone,
midiTuba, midiMutedTrumpet, midiFrenchHorn, midiBrassSection,
midiSynthBrass1, midiSynthBrass2, midiSopranoSax, midiAltoSax,
midiTenorSax, midiBaritoneSax, midiOboe, midiEnglishHorn,
midiBassoon, midiClarinet, midiPiccolo, midiFlute,
midiRecorder, midiPanFlute, midiBottleBlow, midiShakuhachi,
midiWhistle, midiOcarina, midiLead1Square,
midiLead2Sawtooth, midiLead3CalliopeLead, midiLead4ChiffLead,
midiLead5Charang, midiLead6Voice, midiLead7Fifths,
midiLead8BrassLead, midiPad1NewAge, midiPad2Warm,
midiPad3Polysynth, midiPad4Choir, midiPad5Bowed,
midiPad6Metallic, midiPad7Halo, midiPad8Sweep, midiEmpty0,
midiEmpty1, midiEmpty2, midiEmpty3, midiEmpty4, midiEmpty5,
midiEmpty6, midiEmpty7, midiEmpty8, midiEmpty9, midiEmpty10,
midiEmpty11, midiEmpty12, midiEmpty13, midiEmpty14,
midiEmpty15, midiEmpty16, midiEmpty17, midiEmpty18,
midiEmpty19, midiEmpty20, midiEmpty21, midiEmpty22,
midiEmpty23, midiGuitarFretNoise, midiBreathNoise,
midiSeashore, midiBirdTweet, midiTelephoneRing,
midiHelicopter, midiApplause, midiGunshot);
Try this:
procedure TForm1.FormCreate(Sender: TObject);
begin
MIDIInit;
SetCurrentInstrument(midiHarmonica);
NoteOn(50, 127);
sleep(200);
NoteOn(60, 127);
sleep(200);
NoteOn(70, 127);
sleep(200);
NoteOff(70, 127);
NoteOff(60, 127);
NoteOff(50, 127);
SetCurrentInstrument(midiAcousticGrandPiano);
NoteOn(70, 127);
NoteOn(80, 127);
sleep(1000);
SetCurrentInstrument(midiApplause);
NoteOn(64, 127);
sleep(2000);
NoteOff(64, 127);
end;
Upvotes: 9
Reputation: 24483
I have used BASS MIDI using the .NET wrapper with great success, and there are Delphi wrappers available for it too.
Upvotes: 2