#pragma comment(lib, "winmm")
#include <Windows.h>
// status
#define NOTE_OFF 0x8
#define NOTE_ON 0x9
#define PROGRAM_CHANGE 0xc
// note number
#define G3 55
#define C4 60
#define D4 62
#define E4 64
#define G4 67
#define B4 71
#define C5 72
#define MAKESMSG(st,ch,d1,d2) ((st)<<4|(ch)|(d1)<<8|(d2)<<16)
#define MAKESMSG_(d1,d2) ((d1)|(d2)<<8)
#define CH 0
int main()
{
HMIDIOUT hmo;
midiOutOpen(&hmo, MIDI_MAPPER, NULL, 0, CALLBACK_NULL);
midiOutShortMsg(hmo, MAKESMSG(PROGRAM_CHANGE, CH, 0, 0)); // Acoustic Piano
midiOutShortMsg(hmo, MAKESMSG(NOTE_ON, CH, C4, 127));
midiOutShortMsg(hmo, MAKESMSG_(E4, 127));
midiOutShortMsg(hmo, MAKESMSG_(G4, 127));
midiOutShortMsg(hmo, MAKESMSG_(C5, 127));
Sleep(1500);
midiOutShortMsg(hmo, MAKESMSG(NOTE_OFF, CH, C4, 0));
midiOutShortMsg(hmo, MAKESMSG_(E4, 0));
midiOutShortMsg(hmo, MAKESMSG_(G4, 0));
midiOutShortMsg(hmo, MAKESMSG_(C5, 0));
midiOutShortMsg(hmo, MAKESMSG(NOTE_ON, CH, G3, 127));
midiOutShortMsg(hmo, MAKESMSG_(D4, 127));
midiOutShortMsg(hmo, MAKESMSG_(G4, 127));
midiOutShortMsg(hmo, MAKESMSG_(B4, 127));
Sleep(1500);
midiOutShortMsg(hmo, MAKESMSG(NOTE_OFF, CH, G3, 0));
midiOutShortMsg(hmo, MAKESMSG_(D4, 0));
midiOutShortMsg(hmo, MAKESMSG_(G4, 0));
midiOutShortMsg(hmo, MAKESMSG_(B4, 0));
midiOutShortMsg(hmo, MAKESMSG(NOTE_ON, CH, C4, 127));
midiOutShortMsg(hmo, MAKESMSG_(E4, 127));
midiOutShortMsg(hmo, MAKESMSG_(G4, 127));
midiOutShortMsg(hmo, MAKESMSG_(C5, 127));
Sleep(1500);
midiOutShortMsg(hmo, MAKESMSG(NOTE_OFF, CH, C4, 0));
midiOutShortMsg(hmo, MAKESMSG_(E4, 0));
midiOutShortMsg(hmo, MAKESMSG_(G4, 0));
midiOutShortMsg(hmo, MAKESMSG_(C5, 0));
midiOutReset(hmo);
midiOutClose(hmo);
return 0;
}