Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Promit

Programming MIDI?

This topic is 5585 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I wanted to write a program which can input and output via MIDI ports (win32), but I''ve been utterly unable to hunt anything down on this. Found a couple API calls that looked interesting, but failed to find out anything about them. Can someone show me where to start on coding MIDI?

Share this post


Link to post
Share on other sites
Advertisement
Hey,

Petzold has a couple chapters on programming MIDI. It''ll show you how to open ports and start sending messages. You can also check out his homepage for more MIDI apps.

''Maximum MIDI'' is an old book dedicated to MIDI programming on the Windows platform. The book is fairly old, and implements a MIDI engine in Win95/MFC. All the concepts are there tho, and upgrading the code would not be terribly difficult.

Cheers.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Random bits of old sucky MFC MIDI In code:

int num = midiInGetNumDevs();

for (int i=0; i<num; i++) {
MIDIINCAPS caps;
midiInGetDevCaps(i,&caps, sizeof(caps));
m_Devices.AddString(caps.szPname);
}
m_Devices.SetCurSel(0);
return 1;


device=m_Devices.GetCurSel();


void CRazorSynthInterfaceDlg::OpenMIDI()
{
if (!midiopen && curdevice != -1) {
if (MMSYSERR_NOERROR != midiInOpen(&handle, curdevice, (unsigned long)(this->GetSafeHwnd()), 0, CALLBACK_WINDOW)) {
MessageBox("Couldn''t open MIDI in device";
return;
}
midiInStart(handle);
SetTitle("Running...";
midiopen=1;
}
}
void CRazorSynthInterfaceDlg::CloseMIDI()
{
if (midiopen && curdevice != -1) {
midiInStop(handle);
midiInClose(handle);
midiopen=0;
SetTitle("Stopped";
}
}


LRESULT CRazorSynthInterfaceDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == MM_MIM_DATA) {
//we caught a midi message
woohooMIDIMessage(lParam & 0xff, (lParam>>8) & 0xff, (lParam>>16) & 0xff);
}
return CDialog::WindowProc(message, wParam, lParam);
}

I''m too lazy to write up something proper but you should be able to figure out how to recieve MIDI data from this
if you need more info use MSDN.

Share this post


Link to post
Share on other sites
With the Allegro library, sending MIDI data is very easy if you know what you''re doing.

void midi_out(unsigned char *data, int length);
Streams a block of MIDI commands into the player in realtime.

And the relevant initialisation is only a few lines as well. Of course you have to know what data to feed in, but that''s not too hard either.

What exactly are you trying to do?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!