13 #ifndef __MIDIEVENTMANAGER_H__74C2A3BA_DFCF_4048_BC1D_20E9E04E809A__
14 #define __MIDIEVENTMANAGER_H__74C2A3BA_DFCF_4048_BC1D_20E9E04E809A__
16 #include "jdkmidi/sequencer.h"
24 unsigned short m_nCurrentTrack;
25 unsigned short m_nCurrentLayer;
27 enum { MAX_CHANNELS = 16, MAX_LAYERS = 16 };
29 unsigned short m_CurrentLayer[MAX_CHANNELS];
30 unsigned long m_Time[MAX_CHANNELS][MAX_LAYERS];
32 jdkmidi::MIDIMultiTrack m_Tracks;
34 jdkmidi::MIDISequencer m_Sequencer;
41 m_Tracks.SetClksPerBeat(24);
49 inline jdkmidi::MIDISequencer*
GetSequencer() {
return &m_Sequencer; }
52 inline jdkmidi::MIDIMultiTrack*
GetTracks() {
return &m_Tracks; }
59 memset(m_CurrentLayer, 0,
sizeof(m_CurrentLayer));
60 memset(m_Time, 0,
sizeof(m_Time));
64 m_Sequencer.ResetAllTracks();
71 m_nCurrentTrack = nTrack;
74 inline void SetCurrentLayer(
unsigned short nLayer)
76 m_CurrentLayer[m_nCurrentTrack] = nLayer;
84 return m_Time[m_nCurrentTrack][m_CurrentLayer[m_nCurrentTrack]];
92 m_Time[m_nCurrentTrack][m_CurrentLayer[m_nCurrentTrack]] = lNewTime;
100 m_Time[m_nCurrentTrack][m_CurrentLayer[m_nCurrentTrack]] += lDuration;
109 jdkmidi::MIDITimedBigMessage msg;
111 msg.SetChannelPressure((
unsigned char)m_nCurrentTrack, uPressure);
112 m_Tracks.GetTrack(m_nCurrentTrack)->PutEvent(msg);
122 jdkmidi::MIDITimedBigMessage msg;
124 msg.SetControlChange((
unsigned char)m_nCurrentTrack, uControlIndex, uControlValue);
125 m_Tracks.GetTrack(m_nCurrentTrack)->PutEvent(msg);
135 jdkmidi::MIDITimedBigMessage msg;
137 msg.SetKeySig(nKeySig, MajMin);
138 m_Tracks.GetTrack(m_nCurrentTrack)->PutEvent(msg);
148 jdkmidi::MIDITimedBigMessage msg;
150 msg.SetPitchBend((
unsigned char)m_nCurrentTrack, uLowByte, uHighByte);
151 m_Tracks.GetTrack(m_nCurrentTrack)->PutEvent(msg);
161 jdkmidi::MIDITimedBigMessage msg;
163 msg.SetPolyPressure((
unsigned char)m_nCurrentTrack, uKey, uPressure);
164 m_Tracks.GetTrack(m_nCurrentTrack)->PutEvent(msg);
173 jdkmidi::MIDITimedBigMessage msg;
175 msg.SetProgramChange((
unsigned char)m_nCurrentTrack, nInstrumentID);
176 m_Tracks.GetTrack(m_nCurrentTrack)->PutEvent(msg);
185 jdkmidi::MIDITimedBigMessage msg;
187 msg.SetTempo32(nTempo * 32);
188 m_Tracks.GetTrack(m_nCurrentTrack)->PutEvent(msg);
202 inline void AddNoteEvent(
int noteValue,
int attackVel,
int decayVel,
long lNoteDuration,
bool addNoteOn,
bool addNoteOff)
206 jdkmidi::MIDITimedBigMessage msg;
210 msg.SetNoteOn((
unsigned char)m_nCurrentTrack, (
unsigned char) noteValue, (
unsigned char) attackVel);
212 m_Tracks.GetTrack(m_nCurrentTrack)->PutEvent(msg);
219 jdkmidi::MIDITimedBigMessage msg;
223 msg.SetNoteOff((
unsigned char)m_nCurrentTrack, (
unsigned char)noteValue, (
unsigned char)decayVel);
225 m_Tracks.GetTrack(m_nCurrentTrack)->PutEvent(msg);
232 #endif // __MIDIEVENTMANAGER_H__74C2A3BA_DFCF_4048_BC1D_20E9E04E809A__
void AddChannelPressureEvent(unsigned char uPressure)
unsigned long GetTrackTime() const
jdkmidi::MIDISequencer * GetSequencer()
Returns the Sequencer holding the collection of tracks
void AddTempoEvent(unsigned short nTempo)
void AdvanceTrackTime(unsigned long lDuration)
void AddProgramChangeEvent(unsigned char nInstrumentID)
void SetCurrentTrack(unsigned short nTrack)
void SetTrackTime(unsigned long lNewTime)
Takes care of MIDI Events, Tracks and Sequencing
void AddPolyphonicPressureEvent(unsigned char uKey, unsigned char uPressure)
void AddControllerEvent(unsigned char uControlIndex, unsigned char uControlValue)
jdkmidi::MIDIMultiTrack * GetTracks()
Returns the Multitrack object
void AddPitchBendEvent(unsigned char uLowByte, unsigned char uHighByte)
void AddNoteEvent(int noteValue, int attackVel, int decayVel, long lNoteDuration, bool addNoteOn, bool addNoteOff)
void AddKeySignatureEvent(signed char nKeySig, unsigned char MajMin)