]>
code.delx.au - virtualtones/blob - midiengine.h
1 // midiengine.h - Class to play to a sequencer or write to a MIDI file
2 // Written by James Bunton <james@delx.net.au>
3 // Licensed under the GPL, see COPYING.txt for more details
15 class MidiEngine
: public QObject
19 /* initSuccess() - returns true if the object is ready to be used */
22 /* getError() - returns an error message describing why the object isn't ready */
27 /* setPatch() - Allows you to set the instrument
28 'num' - the number of the patchset you wish to use
29 Note: The patchset had better exist!
31 virtual void setInstrument(int num
)=0;
34 /* playNote() - Plays a midi note
35 'num' - the note to play (between 0 and 127. 69 in middle C)
36 'vel' - the note volume (between 0 and 127), if 0 then the note is stopped
37 'len' - the duration in milliseconds, if 0, then note will play until stopped
38 returns false if it received incorrect parameters
40 virtual bool playNote(int num
, int vel
, int len
)=0;
43 /* stopNote() - Stops a midi note
44 'num' - the note to stop
46 bool stopNote(int num
);
49 /* stopAll() - Stops all currently playing MIDI notes */
53 virtual void timerEvent(QTimerEvent
*);
55 // For dealing with errors
59 // For turning notes off
60 long int noteEndings
[128];
61 long int timer
; // In milliseconds, only approximate
65 class MidiReal
: public MidiEngine
73 void setInstrument(int num
);
74 bool playNote(int num
, int vel
, int len
);
83 class MidiFile
: public MidiEngine
{
86 MidiFile(QString outFile
);
90 void setInstrument(int num
);
91 bool playNote(int num
, int vel
, int len
);