Qshi (2) [Avatar] Offline
#1
I'm trying to play some music from MIDI events,
and i'm trying to play it with the synchronization in Chapter 8.Becuase I'm trying to make the code as short as possible,so i want to use it with the simplest way.....

I'd try some examples,but they all mixed with MFC,and I'm new to that ...Q_Q

Here is my program...
=======
hSync = OpenSyn(0,NULL,S_INT,DEFAULT_TIMERPERIOD);
hMidiOut = OpenMidiOut(NULL,0,hSync,MIDIOUT_DEFAULT);

MidiEvent Evt;
for( i = 0 ; i < 10 ; i++){

Evt.status = 0x90; //noteOn
Evt.data1 = 0x2C + 2*i; // pitch
Evt.data2 = 0x60; //volume
Evt.time = i*40;

PutMidiOut (hMidiOut, &Evt);

}
StartSync(hSync);

===
I thought these code may make some noise at least,but I got nothing until I misused a NULL pointer,and he made the sound I expected!!!

May someone please tell me how can I make it work correcttly?

P.S. Those code runs under .NET 2003....

Thanks for your help ....
Freq (22) [Avatar] Offline
#2
Re: Need some help about play midi events
Hi Qshi,
No MFC in your code so you shouldn't have to worry about it. But your OpenMidiOut call should have a window handle as the first parameter. What do you mean by "misued a NULL pointer"? Your code should work fine.
Qshi (2) [Avatar] Offline
#3
Re: Need some help about play midi events
Thanks for your reply ....


I found my code truly work fine....
And the reason I thought it was not...
Just because I heared nothing ...
And after I used a busy loop instead of a windows handler ,to tell when it is finished sending event...

Then I can hear it !! ^^