| Here a simple example in C++(below) that I found on my hard drive. I
looked at portmidi some time ago but only to see how it worked. I
never developed anything with it so I'm no expert. I just tested this
example and it seems to work fine, it just keeps repeating notes until
the user enters some text to the command prompt.
Rory.
#include
#include "portmidi.h"
#include "porttime.h"
#include
#include
#include
#define TIME_PROC ((long (*)(void *)) Pt_Time)
using namespace std;
PmStream * midi;
char line[80];
PmEvent buffer[5];
void process_midi(PtTimestamp timestamp, void *userData);
int main(int argc, char *argv[])
{
//pt_start must be called before initialising midi
Pt_Start(2000, &process_midi, 0);
Pm_Initialize();
int device = 0;//microsoft midi mapper...
Pm_OpenOutput(&midi,device,NULL,0,NULL,NULL,10);
/*calling callback function once. When I called Pt_start
it waits until 'resolution' millisecs have passed before
start, hence I call the callback function once beforehand */
process_midi(NULL, NULL);
cin.get();
//wiat for user input and then stop midi timer callback function...
Pt_Stop();
Pm_Close(midi);
printf("done closing and terminating...\n");
Pm_Terminate();
}
void process_midi(PtTimestamp timestamp, void *userData)
{
buffer[0].timestamp = timestamp+0;
buffer[0].message = Pm_Message(0x90, 60, 100);
buffer[1].timestamp = timestamp+1000;
buffer[1].message = Pm_Message(0x90, 60, 0);
buffer[2].timestamp = timestamp+1000;
buffer[2].message = Pm_Message(0x90, 64, 100);
buffer[3].timestamp = timestamp+2000;
buffer[3].message = Pm_Message(0x90, 64, 0);
Pm_Write(midi, buffer, 4);
}
2009/10/14 Michael Mossey :
> I'm trying to get the Haskell PortMidi interface working, and I'm having
> trouble. I wonder if anyone out there has either
>
> (1) an example Haskell program using PortMidi
> (2) an example of PortMidi use in ANY language
>
> Thanks,
> Mike
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
> csound"
>
Send bugs reports to this list.
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |