From: gfoot AT mc31 DOT merton DOT ox DOT ac DOT uk (George Foot) Newsgroups: comp.os.msdos.djgpp Subject: Re: midi sound detecting in Allegro?? Date: 11 Mar 1997 23:04:40 GMT Organization: Oxford University Lines: 46 Distribution: world Message-ID: <5g4oe8$8pg@news.ox.ac.uk> References: NNTP-Posting-Host: mc31.merton.ox.ac.uk To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp 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 Merton College, Oxford.