#ifndef _GUITAR_SEQUENCER_HPP_ #define _GUITAR_SEQUENCER_HPP_ #ifndef _MIDISEQ_MIDIOUTDEVICE_HPP_ #include #endif #ifndef _MIDISEQ_PROGRAMCHANGE_HPP_ #include #endif #ifndef _MIDISEQ_CHANNELMODEMESSAGE_HPP_ #include #endif #ifndef _GUITAR_REGISTRY_HPP_ #include #endif class Sequencer : private MIDIOutputDevice { public: Sequencer(); virtual ~Sequencer(); bool midiEvent(const PureEvent &somePureEvent); bool clearNotes(void); bool hasDevice(void)const; void closeDevice(void); bool openDevice(void); MIDIOutputDevice &getDevice(void); private: void changeProgram(void); }; inline Sequencer::Sequencer() { changeProgram(); } inline Sequencer::~Sequencer() { closeDevice(); } inline bool Sequencer::midiEvent(const PureEvent &somePureEvent) { return MIDIOutputDevice::midiEvent(somePureEvent); } inline bool Sequencer::hasDevice(void)const { return MIDIOutputDevice::hasDevice(); } inline void Sequencer::closeDevice(void) { MIDIOutputDevice::closeDevice(); } inline bool Sequencer::openDevice(void) { Registry registry; if(!MIDIOutputDevice::openDevice(registry.getMIDIOutputDevice()))return false; // if(!MIDIOutputDevice::openDevice())return false; changeProgram(); return true; } inline bool Sequencer::clearNotes(void) { return midiEvent(ChannelModeMessage(ChannelModeMessage::AllNotesOff).getEvent()); } inline MIDIOutputDevice &Sequencer::getDevice(void) { if(!hasDevice()) { openDevice(); changeProgram(); } return (MIDIOutputDevice&)*this; } inline void Sequencer::changeProgram(void) { Registry registry; midiEvent(ProgramChange(registry.getInstrument()).getEvent()); } #endif