MIDI - can I send MIDI notes/data using ZExternalLibrary ?

If there is something important you think is missing in the current version of ZGameEditor then you can post a feature request here!

Moderator: Moderators

Post Reply
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

MIDI - can I send MIDI notes/data using ZExternalLibrary ?

Post by jph_wacheski »

Wondering if this is currently possible to do using the ZExternalLibrary component,. and some Windows API voodoo,.. . ? (also is it possible for Android?)

I am building a "linear feedback bit-shifting long cycle sequencer" or that is what I am calling it,. the idea is based largely on the Triadex Muse; http://m.matrixsynth.com/2011/07/triade ... music.html

although I come to it from the interest in this one; http://musicthing.co.uk/modular/?page_id=21

My version f the simple one attached. The larger system is coming along, howevr not posted yet..,

So basically I am finding that looping bit-shit registers with digital feedback are rather interesting for making patterns.

Currently these are playing zge/sunvox sounds, but it could be cool to try sending MIDI notes outside,.

Anyway, MIDI input and output from ZGE could be interesting for sound/graphics control experiments and stuff.
Attachments
FlippinBits_001.zip
.zgeproj and .exe
(40.15 KiB) Downloaded 414 times
iterationGAMES.com
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Re: MIDI - can I send MIDI notes/data using ZExternalLibrary

Post by Kjell »

Hi jph,
jph_wacheski wrote:Wondering if this is currently possible to do using the ZExternalLibrary component and some Windows API voodoo?
Sure :)

http://msdn.microsoft.com/en-us/library ... 98495.aspx

K
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

Cool thanks Kjell, exactly what I was looking for!

ok so I got this;

Code: Select all

ZZDC<?xml version="1.0" encoding="iso-8859-1" ?>
<ZExternalLibrary ModuleName="winmm">
  <Source>
<![CDATA[
  // simple MIDI
int midiOutOpen( int lphMidiOut, int uDeviceID, int dwCallback, int dwInstance, int dwFlags ) {}
int midiOutClose( int hMidiOut ) {}

int midiOutShortMsg( int hMidiOut, int dwMsg ) {}]]>
  </Source>
</ZExternalLibrary>
and figuring that we need this;

Code: Select all

//set up to play a MIDI note
   int note = 60;       //for C. C# = 61, etc.
   int event = 144;     //event 144 = play on channel 1
   int loWord = (note*256)+event;
   int velocity = 127;
   int hiWord = velocity*256*256;
   int dwMsg = loWord + hiWord;
So we can set note and velocity here. What I can not find/figure out is how to get hMidiOut ?

Seems this is the needed 'handle' to the midi device the windows driver has,. not sure how to get it??
iterationGAMES.com
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi jph,
jph_wacheski wrote:What I can not find/figure out is how to get hMidiOut ?
As mentioned on MSDN; LPHMIDIOUT lphmo is a ..
Pointer to an HMIDIOUT handle. This location is filled with a handle identifying the opened MIDI output device.
So, make sure to define lphMidiOut in the function prototype as ref / xptr ( see below ) .. then the handle will be written to the passed variable / array ( ZGE only accepts arrays for xptr arguments ).

Code: Select all

int midiOutOpen(ref int lphmo, int uDeviceID, xptr dwCallback, xptr dwCallbackInstance, int dwFlags){}
And you should use bit-shifting instead of multiplication. Use "note << 8" instead of "note * 256" and "velocity << 16" instead of "velocity * 256 * 256" :wink:

K
Post Reply