Mail Archives: djgpp/1997/03/11/19:34:14
David Jenkins (me AT jenkinsdavid DOT demon DOT co DOT uk) wrote:
: I've found the line he's refering to, but I don't know what to add.
: I figure the idea is to add some global variables which I could monitor
: in MY main().
: If anybody wants to "walk" me through what I should add, I'd be
: grateful.
I'm sorry I don't have time to test this, or to walk you through it really,
but I think a versatile approach would be as follows:
Declare a function-pointer in allegro.h:
> void (*midi_note_func)(int,int,int);
Then put in where Shawn suggested:
> if ((vol>0)&&(midi_note_func)) midi_note_func(channel,pitch,vol);
(check the above line; I've cut the example Shawn gave).
Now add to the midi initialisation function:
> midi_note_func=NULL;
Having done this, rebuild the Allegro library (might be a good idea to keep
the original ZIP in case it doesn't work). Now you should be able to
initialise the midi player (can't remember how offhand), then set the
function-pointer midi_note_func to your own function, whatever it is. Make
sure your function takes the same three parameters (int channel, int pitch,
int vol) as midi_note_func, and then you just write:
> midi_node_func=function_to_call_when_note_is_played;
After this, whenever a note is played your function will be called with
the three parameters given above. This approach is more versatile than
Shawn's, I think, which required you to embed your function into the
Allegro code.
Again, I apologise for not having time to actually test this first; it
involves rebuilding the library which is somewhat painful in dosemu.
--
George Foot <gfoot AT mc31 DOT merton DOT ox DOT ac DOT uk>
Merton College, Oxford.
- Raw text -