用于MIDI输入/输出的Delphi库?

时间:2010-09-06 06:27:42

标签: delphi midi

用于MIDI输入/输出的Delphi库是什么?

8 个答案:

答案 0 :(得分:4)

您确定需要第三方库吗?如果您的需求是基本的,那么您只需要Windows API(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;

仪器在哪里

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);

试试这个:

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;

答案 1 :(得分:2)

我一直在为ages使用这些组件:

http://bitbucket.org/h4ndy/midiio-dev

他们几乎没有对我失败,而且与其他许多已经存在很长时间的专业Delphi组件不同,这段代码非常活跃(最近增加了更新和改进)。

没什么特别的,但它易于使用,快速,坚如磐石。如果你打算做一些严肃的midi东西,你最终会最终使用它。

答案 2 :(得分:2)

我已经使用这些组件超过6个月了,取得了巨大的成功。应在后续帖子中对所有其他人进行评估。

http://sourceforge.net/projects/midisequencer/

答案 3 :(得分:1)

答案 4 :(得分:1)

我已经使用.NET包装器BASS MIDI取得了巨大的成功,并且还有Delphi wrappers可用。

答案 5 :(得分:1)

一个非常简单的MIDI输入/输出类: www.midimountain.com/delphi_midi.html

如果您想自己动手并使用Windows API,它看起来是一个很好的起点。

答案 6 :(得分:1)

只是一个小小的额外信息:SourceForge“dmidi”项目实际上与BitBucket上的“midiio”相同(但开发发生在这里)。

答案 7 :(得分:0)

星期四4/14/2014 9:49 am。由于我不被允许评论,我会尝试回答:我为midimountain.com候选人投了我过去的投票。我得到了demo_MidiDevices_D6.zip(在页面http://www.midimountain.com/delphi_midi.html上获取它,没有“下载”链接),解压缩它,并且在我的古董Delphi 7和中编译时没有发生任何事故然。我实际上没有测试它是否有MIDI,但它确实显示我的连接MIDI设备的动物园....