Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (dr_panther, VoroneTZ, AndrewAMD), 834 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Midi Instruments #262130
04/22/09 03:40
04/22/09 03:40
Joined: Oct 2004
Posts: 900
Lgh
rojart Offline OP
User
rojart  Offline 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.

Code:
  //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);
}



Regards, Robert

Quote
Everything should be made as simple as possible, but not one bit simpler.
by Albert Einstein

PhysX Preview of Cloth, Fluid and Soft Body

A8.47.1P
Re: Midi Instruments [Re: rojart] #262144
04/22/09 06:17
04/22/09 06:17

M
mercuryus
Unregistered
mercuryus
Unregistered
M



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 Offline OP
User
rojart  Offline 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

Code:
//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);
}



Regards, Robert

Quote
Everything should be made as simple as possible, but not one bit simpler.
by Albert Einstein

PhysX Preview of Cloth, Fluid and Soft Body

A8.47.1P
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 Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
Ä°stanbul, Turkey
awesome laugh you should have contributed this before the no-resources contest, most could make use of this.


3333333333
Re: Midi Instruments [Re: Quad] #262293
04/23/09 00:33
04/23/09 00:33
Joined: Oct 2004
Posts: 900
Lgh
rojart Offline OP
User
rojart  Offline OP
User

Joined: Oct 2004
Posts: 900
Lgh
Thanks and yes, you´re right, I forgot to add on one Panel from Vaders entry, but have already used as sound for it. wink


Regards, Robert

Quote
Everything should be made as simple as possible, but not one bit simpler.
by Albert Einstein

PhysX Preview of Cloth, Fluid and Soft Body

A8.47.1P
Re: Midi Instruments [Re: rojart] #262515
04/24/09 08:51
04/24/09 08:51
Joined: May 2008
Posts: 331
Lithuania, Vilnius
Jaxas Offline
Senior Member
Jaxas  Offline
Senior Member

Joined: May 2008
Posts: 331
Lithuania, Vilnius
realy good contribution smile must have in my example collection smile


The smaller the bug, the harder it is to kill.
_________________________________________
Forklift DEMO (3dgs)
Re: Midi Instruments [Re: Jaxas] #262554
04/24/09 15:23
04/24/09 15:23
Joined: Oct 2006
Posts: 873
S
Shadow969 Offline
User
Shadow969  Offline
User
S

Joined: Oct 2006
Posts: 873
nice one! thumbs up smile

Re: Midi Instruments [Re: Shadow969] #262723
04/25/09 14:15
04/25/09 14:15
Joined: Aug 2002
Posts: 3,258
Mainz
oliver2s Offline
Expert
oliver2s  Offline
Expert

Joined: Aug 2002
Posts: 3,258
Mainz
Really nice. Thank you smile

Re: Midi Instruments [Re: oliver2s] #262773
04/25/09 20:35
04/25/09 20:35
Joined: Apr 2009
Posts: 298
Southern Oceans
KiwiBoy Offline
Member
KiwiBoy  Offline
Member

Joined: Apr 2009
Posts: 298
Southern Oceans
How would I use this?
Been looking for a way to make a synthisiser of sorts so thought maybe this could be an option.


Use the 'manual' Luke, the manual is your friend. 'Self reminder' smile

My WebPage
Re: Midi Instruments [Re: KiwiBoy] #263148
04/28/09 01:14
04/28/09 01:14
Joined: Oct 2004
Posts: 900
Lgh
rojart Offline OP
User
rojart  Offline OP
User

Joined: Oct 2004
Posts: 900
Lgh
Thank you all for the kind words!
After Spring contest 2009 I´ll describe all the Midi functions with an example as a simple synthesiser


Regards, Robert

Quote
Everything should be made as simple as possible, but not one bit simpler.
by Albert Einstein

PhysX Preview of Cloth, Fluid and Soft Body

A8.47.1P
Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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