Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 684 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
get MIDI into GS? #277217
07/08/09 11:21
07/08/09 11:21
Joined: Jul 2009
Posts: 40
E
enrike Offline OP
Newbie
enrike  Offline OP
Newbie
E

Joined: Jul 2009
Posts: 40
hi there

is there any way to receive MIDI messages into Game Studio? i am searching the forum but i canot see anything in that direction.

thanks

enrike

Re: get MIDI into GS? [Re: enrike] #277258
07/08/09 14:37
07/08/09 14:37
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline
Expert
Rei_Ayanami  Offline
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
MIDI message? do you mean a sound?
Yeah, use
code:
media_play("your_midi.mid", NULL, 100);

Re: get MIDI into GS? [Re: Rei_Ayanami] #277413
07/09/09 08:26
07/09/09 08:26
Joined: Jul 2009
Posts: 40
E
enrike Offline OP
Newbie
enrike  Offline OP
Newbie
E

Joined: Jul 2009
Posts: 40
no i dont want to play MIDI files. i mean i want to receive realtime MIDI messages into GS, for example using a MIDI controller like a MIDI piano
http://en.wikipedia.org/wiki/MIDI_keyboard
Those controllers send MIDI messages to the computer. I want to be able to receive those messages inside game studio. Lets say i want to be able to control my game player using a MIDI keyboard instead of a joystick.

Re: get MIDI into GS? [Re: enrike] #277520
07/09/09 13:34
07/09/09 13:34
Joined: Apr 2009
Posts: 33
Germany
B
Bunsen Offline
Newbie
Bunsen  Offline
Newbie
B

Joined: Apr 2009
Posts: 33
Germany
You could use the multimedia API functions:

Code:
#include <acknex.h>
#include <windows.h>

#define MIDIIN_DEVID 0

void* WINAPI midiInOpen(void **, UINT, DWORD, DWORD, DWORD);
int   WINAPI midiInClose(void*);
int   WINAPI midiInStart(void*);

//-----------------------------------------------------------------------------------------------
void CALLBACK MidiInProc(void* hmi, UINT wMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2)
{
	if (wMsg == MIM_DATA)
	{
		// Put your code inside here:
		//
		// dwParam1 is the midi message, where
		//	(dwParam1 & 0xF) is midi channel,
		//	(dwParam1 & 0xF0) is status byte (note on = 0x90, note off = 0x80, ...),
		//	((dwParam1 >> 8) & 0x7F) is data1, eg key,
		//	((dwParam1 >> 16) & 0x7F) is data2, eg velocity 
		//
		// dwParam2 is timestamp
				
	}
}

//-----------------------------------------------------------------------------------------------
void *hmi = NULL; // MidiIn handle

//-----------------------------------------------------------------------------------------------
function main()
{
	if (0 == midiInOpen(&hmi, MIDIIN_DEVID, (DWORD)MidiInProc, 0, CALLBACK_FUNCTION))
	{
		printf("MidiIn successfully opened! Press 'x' to close device");
		midiInStart(hmi); // Ready to receive midi messages
	
		while (! key_x)
		{
			wait(10);
		}
	}
	else
		printf("Failed to open MidiIn!");
	
	if (hmi)
		midiInClose(hmi);
	
	printf("Exit");
}



Re: get MIDI into GS? [Re: Bunsen] #277673
07/10/09 05:46
07/10/09 05:46
Joined: Jul 2009
Posts: 40
E
enrike Offline OP
Newbie
enrike  Offline OP
Newbie
E

Joined: Jul 2009
Posts: 40
thanks!!! i will try this

Re: get MIDI into GS? [Re: enrike] #277675
07/10/09 05:51
07/10/09 05:51
Joined: Dec 2008
Posts: 528
Wagga, Australia
the_mehmaster Offline
User
the_mehmaster  Offline
User

Joined: Dec 2008
Posts: 528
Wagga, Australia
This is very interesting. I was going to do something similar..
Thanks Bunsen!


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1