2 registered members (Akow, tomaslolo),
1,536
guests, and 12
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Midi Instruments
#262130
04/22/09 03:40
04/22/09 03:40
|
Joined: Oct 2004
Posts: 900 Lgh
rojart
OP
User
|
OP
User
Joined: Oct 2004
Posts: 900
Lgh
|
Hi, Here an example for playing all midi Instruments, that I use it for my contest entry Vaders, maybe you like it. P - play all midi Instruments Esc - exit Any comments are welcome. //Created by rojart 2009
#include <acknex.h>
#define API(name,lib) #define PRAGMA_API name;lib!name
#define DECLARE_HANDLE(name) typedef HANDLE name
#define CALLBACK_NULL 0x0
DECLARE_HANDLE(HMIDIOUT);
HMIDIOUT hMidiout;
DWORD __stdcall midiOutOpen(DWORD*,DWORD,DWORD,DWORD,DWORD);
DWORD __stdcall midiOutShortMsg(DWORD,DWORD);
DWORD __stdcall midiOutReset(DWORD);
DWORD __stdcall midiOutClose(DWORD);
API(midiOutOpen,winmm)
API(midiOutShortMsg,winmm)
API(midiOutReset,winmm)
API(midiOutClose,winmm)
int midiport = 0;
int on_p_event()
{
int i; BYTE octave = 60; BYTE volume = 127;
for(i=0;i<=127;i++)
{
midiOutShortMsg(hMidiout, (volume << 16) | (i << 8) | 0xC0);wait(1); // Instrument
midiOutShortMsg(hMidiout, (volume << 16) | (octave << 8) | 0x90);wait(-1); // note/octave on
midiOutShortMsg(hMidiout, (volume << 16) | (octave << 8) | 0x80);wait(1); // note off
}
}
void main()
{
midiOutOpen(&hMidiout, midiport, 0, 0, CALLBACK_NULL);
}
void on_esc_event()
{
wait(1);
midiOutReset(hMidiout);wait(1);
midiOutClose(hMidiout);wait(1);
sys_exit(NULL);
}
|
|
|
Re: Midi Instruments
[Re: rojart]
#262144
04/22/09 06:17
04/22/09 06:17
|
mercuryus
Unregistered
|
mercuryus
Unregistered
|
If works it's a great contribution! Thanx.
|
|
|
Re: Midi Instruments
[Re: ]
#262291
04/22/09 23:25
04/22/09 23:25
|
Joined: Oct 2004
Posts: 900 Lgh
rojart
OP
User
|
OP
User
Joined: Oct 2004
Posts: 900
Lgh
|
Thank you for the kind words! The same but plays only drums at channel 10 (0x9) P - play all drums Esc - Exit //Created by rojart 2009
#include <acknex.h>
#define API(name,lib) #define PRAGMA_API name;lib!name
#define DECLARE_HANDLE(name) typedef HANDLE name
#define MIDI_MAPPER -1
#define CALLBACK_NULL 0x0
DECLARE_HANDLE(HMIDIOUT);
HMIDIOUT hMidiout;
DWORD __stdcall midiOutOpen(DWORD*,DWORD,DWORD,DWORD,DWORD);
DWORD __stdcall midiOutShortMsg(DWORD,DWORD);
DWORD __stdcall midiOutReset(DWORD);
DWORD __stdcall midiOutClose(DWORD);
API(midiOutOpen,winmm)
API(midiOutShortMsg,winmm)
API(midiOutReset,winmm)
API(midiOutClose,winmm)
int midiport = 0;
int on_p_event()
{
int i; BYTE volume = 127;
for(i=27;i<=89;i++)
{
midiOutShortMsg(hMidiout, (volume << 16) | (i << 8) | 0xC9);wait(1); // Drum Sounds
midiOutShortMsg(hMidiout, (volume << 16) | (i << 8) | 0x99);wait(-0.5); // Drum on
midiOutShortMsg(hMidiout, (volume << 16) | (i << 8) | 0x89);wait(1); // Drum off
}
}
void main()
{
//midiOutOpen(&hMidiout, MIDI_MAPPER, 0, 0, 0);
//UINT result = midiOutOpen(&hMidiout, MIDI_MAPPER, 0, 0, 0);
//if(result != MMSYSERR_NOERROR) printf("No MIDI output devices!",0);
midiOutOpen(&hMidiout, midiport, 0, 0, CALLBACK_NULL);
}
void on_esc_event()
{
wait(1);
midiOutReset(hMidiout);wait(1);
midiOutClose(hMidiout);wait(1);
sys_exit(NULL);
}
|
|
|
Re: Midi Instruments
[Re: rojart]
#262292
04/22/09 23:50
04/22/09 23:50
|
Joined: Oct 2007
Posts: 5,210 Ä°stanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,210
Ä°stanbul, Turkey
|
awesome you should have contributed this before the no-resources contest, most could make use of this.
3333333333
|
|
|
|