TheCPUWizard
July 28th, 2007, 07:22 PM
OK, just broke down and bought a M-Audio Keystation USB MIDI keyboard. Unfortunately I had to take the floor model, so I did not get any software (I will swap it with a new one when it arrives in about a week).
I do have the drivers installed, and it appears OK, however I have no application programs.
My goal is to write a program (I will be using C#, but the actual language does not matter. What I need is to be able to get to the RAW MIDI messages that are being sent.
If anyone has some useful likes (or ideally a small sample program) I will owe them BIG TIME!!!!
Anyone out there?
dglienna
July 29th, 2007, 02:15 AM
Should be able to find a free download of SONAR (by Cakewalk/12 tone systems)
http://www.google.com/search?client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&channel=s&hl=en&q=sonar+free+download&btnG=Google+Search
Trial versions didn't let you save the data though.
I'll try to dig up some MIDI stuff in the morning. I lost a lot when a drive crashed July 06, though.
Sk#
July 30th, 2007, 05:45 AM
In case you want to write a program to get them, you can use the Low Level MIDI API for Windows. Here's a short program with the main functionalities:
#include <windows.h>
#include <stdio.h>
int out(int argc, char **argv)
{
HMIDIOUT midiOutHandle;
if (midiOutOpen(&midiOutHandle, -1, 0, 0, CALLBACK_NULL) != MMSYSERR_NOERROR)
{
printf("Non riesco ad aprire!\n");
return 1;
}
midiOutShortMsg(midiOutHandle, 0x000012C0);
midiOutShortMsg(midiOutHandle, 0x007F3C90);
midiOutShortMsg(midiOutHandle, 0x007F4090);
midiOutShortMsg(midiOutHandle, 0x007F4390);
midiOutShortMsg(midiOutHandle, 0x007F4690);
Sleep(1000);
midiOutShortMsg(midiOutHandle, 0x007F01B0);
Sleep(1000);
midiOutShortMsg(midiOutHandle, 0x000001B0);
midiOutShortMsg(midiOutHandle, 0x007F40B0);
Sleep(1000);
midiOutShortMsg(midiOutHandle, 0x00003C80);
midiOutShortMsg(midiOutHandle, 0x00004080);
midiOutShortMsg(midiOutHandle, 0x00004380);
midiOutShortMsg(midiOutHandle, 0x00004680);
midiOutShortMsg(midiOutHandle, 0x007F4891);
Sleep(2000);
if (midiOutClose(midiOutHandle) != MMSYSERR_NOERROR)
{
printf("Non riesco a chiudere!\n");
return 1;
}
return 0;
}
void CALLBACK server(HMIDIIN handle, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2)
{
enum MsgKind
{
NOTOFF = 8,
NOTEON,
POLYAT,
CTRLCH,
PRGMCH,
CHANAT,
PTCHBN,
REALTM
};
MIDIINCAPS caps;
int status;
MsgKind msg;
int channel;
int data1;
int data2;
int timestamp;
switch (uMsg)
{
case MIM_OPEN:
midiInGetDevCaps(dwInstance, &caps, sizeof(MIDIINCAPS));
printf("Aperto con successo il device %d (%s)\n", dwInstance, caps.szPname);
break;
case MIM_DATA:
status = (int)(dwParam1 & 0x000000FF);
msg = (MsgKind)((status >> 4) & 0xF);
channel = (int)(status & 0xF);
data1 = (int)((dwParam1 >> 8) & 0x000000FF);
data2 = (int)((dwParam1 >> 16) & 0x000000FF);
timestamp = dwParam2;
if (msg != REALTM)
{
printf("[%4.3f] %d (msg %d on chan %d), %d, %d\n", timestamp/1000.0, status, msg, channel, data1, data2);
}
break;
case MIM_CLOSE:
midiInGetDevCaps(dwInstance, &caps, sizeof(MIDIINCAPS));
printf("Chiuso con successo il device %d (%s)\n", dwInstance, caps.szPname);
break;
}
}
int in(int argc, char **argv)
{
HMIDIIN handle;
char cmdline[51];
if (midiInOpen(&handle, 1, (DWORD)server, 1, CALLBACK_FUNCTION) != MMSYSERR_NOERROR)
{
printf("Impossibile aprire l'input 0\n");
}
midiInStart(handle);
fgets(cmdline, 50, stdin);
while (strcmp(cmdline, "exit\n") && strcmp(cmdline, "e\n"))
{
fgets(cmdline, 50, stdin);
}
midiInReset(handle);
while (midiInClose(handle) == MIDIERR_STILLPLAYING);
return 0;
}
int main(int argc, char **argv)
{
return in(argc, argv);
}
You can switch in the main between in() and out() to manage input or output of MIDI messages.
TheCPUWizard
July 30th, 2007, 07:49 AM
Thanks for the responses.
I actually found a pretty decent library (with source) for C# 2.0 on CodeProject. It is the "MIDI ToolKit" if anyone is interested.
Krishnaa
July 30th, 2007, 07:56 AM
Thanks for the responses.
I actually found a pretty decent library (with source) for C# 2.0 on CodeProject. It is the "MIDI ToolKit" if anyone is interested.
I was about to point you that. ;)