Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MIDI output using : winmm.lib

85 views
Skip to first unread message

Chris Barbour

unread,
Jan 23, 2001, 3:27:27 PM1/23/01
to
Hi there

I'm trying to open a midi output and send simple note on / off messages to
midi channels.
I'am unsure of the complete procedure for opening a midi output and sending
MIDI messages.
So far i know you need to call openMidiOut ... get a midi output handle, and
use midiOutShortMessage
to send a single MIDI event to the output.

When I tried the following test prog no sound was produced when the message
was sent.

HMIDIOUT m_hMidiOut; // Dlg Class member
// construction
CMIDITestDlg::CMidiTestDlg()
{
midiOpenOut( &m_hMidiOut ); // Initialize midiOut
}
// Handlers
CMIDITestDlg::OnOn()
{
sendMIDIEvent(192, 1, 0); // 192 = set channel 1 voice, 1 = Grand
Piano
sendMIDIMsg( 144, 50, 127 ); // 144 status byte = channel 1 note
on, 50 = note value, 127 = velocity
}
CMIDITestDlg::OnOff()
{
sendMIDIMsg( 128, 50, 127 ); 128 = channel 1 note off
}
// Function to send message
void CMIDITestDlg::sendMIDIEvent(BYTE bStatus, BYTE bData1, BYTE bData2)
{
union {
DWORD dwData;
BYTE bData[4];
} u;

// Construct the MIDI message.

u.bData[0] = bStatus; // MIDI status byte
u.bData[1] = bData1; // first MIDI data byte
u.bData[2] = bData2; // second MIDI data byte
u.bData[3] = 0;
// Send the message.
midiOutShortMsg( m_hMidiOut, u.dwData);
}
Is there any other initialization needed for the midi output, such as directing midi
output to the sound card synth or sound card output?

Any tips advice or directions would be greatly apreciated;
thank-you


Mark Heath

unread,
Jan 26, 2001, 9:32:55 AM1/26/01
to
You mention openMidiOut and midiOpenOut but as far as I know, neither
exists.
try using
midiOutOpen(&m_hMidiOut,MIDI_MAPPER,0,0,CALLBACK_NULL)

"Chris Barbour" <Chris....@btinternet.com> wrote in message
news:#0uNspXhAHA.2096@tkmsftngp04...

0 new messages