www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Midi in D

reply Adma <Adma_member pathlink.com> writes:
Just wondering if D has Midi capabilities, Currently I work with C++ and use
MidiOutShortMsg... etc, functions like that, does D have any midi functions or
another sound library that can output variable frequencies or notes?
Jan 24 2006
parent reply clayasaurus <clayasaurus gmail.com> writes:
It looks like those are C functions, all of which can be accessed by D.

My suggestion is to load winmm.dll functions at runtime and then use 
them in D like you would in C++.

This takes a little bit of work as you have to declare the functions and 
then load them through winmm.dll in your code. The Derelict project is a 
good example of how to do this ( 
http://svn.dsource.org/projects/derelict/trunk/DerelictSDLMixer/
erelict/sdl/mixer.d 
for how you can declare C functions that you can load and use) and ( 
http://svn.dsource.org/projects/derelict/trunk/DerelictUtil/derelict/util/ 
  for how you can load these functions).

Or you could find a Midi library in C or C++ and create D headers and 
wrappers for them.

Adma wrote:
 Just wondering if D has Midi capabilities, Currently I work with C++ and use
 MidiOutShortMsg... etc, functions like that, does D have any midi functions or
 another sound library that can output variable frequencies or notes?
 

Jan 24 2006
parent James Dunne <james.jdunne gmail.com> writes:
clayasaurus wrote:
 It looks like those are C functions, all of which can be accessed by D.
 
 My suggestion is to load winmm.dll functions at runtime and then use 
 them in D like you would in C++.
 
 This takes a little bit of work as you have to declare the functions and 
 then load them through winmm.dll in your code. The Derelict project is a 
 good example of how to do this ( 
 http://svn.dsource.org/projects/derelict/trunk/DerelictSDLMixer/
erelict/sdl/mixer.d 
 for how you can declare C functions that you can load and use) and ( 
 http://svn.dsource.org/projects/derelict/trunk/DerelictUtil/derelict/util/ 
  for how you can load these functions).
 
 Or you could find a Midi library in C or C++ and create D headers and 
 wrappers for them.
 
 Adma wrote:
 
 Just wondering if D has Midi capabilities, Currently I work with C++ 
 and use
 MidiOutShortMsg... etc, functions like that, does D have any midi 
 functions or
 another sound library that can output variable frequencies or notes?


Don't forget about ALSA's sequencer API, or possibly OSS's sequencer support. Now, if you're wondering about loading Standard MIDI File formats, I think I can help you there. Or, gut some code out from the free timidity++ project (straight C code - easy to extract), which is what I did.
Jan 24 2006