112 lines
2.8 KiB
C++
112 lines
2.8 KiB
C++
#ifndef _GUITAR_SEQUENCER_HPP_
|
|
#define _GUITAR_SEQUENCER_HPP_
|
|
#ifndef _MIDISEQ_MIDIOUTDEVICE_HPP_
|
|
#include <midiseq/midiout.hpp>
|
|
#endif
|
|
#ifndef _MIDISEQ_PROGRAMCHANGE_HPP_
|
|
#include <midiseq/ProgramChange.hpp>
|
|
#endif
|
|
#ifndef _MIDISEQ_CHANNELMODEMESSAGE_HPP_
|
|
#include <midiseq/ChannelModeMessage.hpp>
|
|
#endif
|
|
#ifndef _GUITAR_REGISTRY_HPP_
|
|
#include <guitar/registry.hpp>
|
|
#endif
|
|
#ifndef _GUITAR_GLOBALDEFS_HPP_
|
|
#include <guitar/GlobalDefs.hpp>
|
|
#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()
|
|
: MIDIOutputDevice(Registry().getMIDIOutputDevice())
|
|
{
|
|
Registry registry;
|
|
GlobalDefs::outDebug(String("[Sequencer::Sequencer] Sequencer()")+registry.getMIDIOutputDevice(),GlobalDefs::Info);
|
|
changeProgram();
|
|
}
|
|
|
|
inline
|
|
Sequencer::~Sequencer()
|
|
{
|
|
GlobalDefs::outDebug("[Sequencer::Sequencer] Sequencer()",GlobalDefs::Info);
|
|
closeDevice();
|
|
}
|
|
|
|
inline
|
|
bool Sequencer::midiEvent(const PureEvent &somePureEvent)
|
|
{
|
|
GlobalDefs::outDebug(String("[Sequencer::midiEvent] ")+somePureEvent.toString(),GlobalDefs::Info);
|
|
return MIDIOutputDevice::midiEvent(somePureEvent);
|
|
}
|
|
|
|
inline
|
|
bool Sequencer::hasDevice(void)const
|
|
{
|
|
GlobalDefs::outDebug(String("[Sequencer::hasDevice] "),GlobalDefs::Info);
|
|
return MIDIOutputDevice::hasDevice();
|
|
}
|
|
|
|
inline
|
|
void Sequencer::closeDevice(void)
|
|
{
|
|
GlobalDefs::outDebug(String("[Sequencer::closeDevice] "),GlobalDefs::Info);
|
|
MIDIOutputDevice::closeDevice();
|
|
}
|
|
|
|
inline
|
|
bool Sequencer::openDevice(void)
|
|
{
|
|
Registry registry;
|
|
|
|
GlobalDefs::outDebug(String("[Sequencer::openDevice] registry.getMIDIOutputDevice()")+registry.getMIDIOutputDevice(),GlobalDefs::Info);
|
|
if(!MIDIOutputDevice::openDevice(registry.getMIDIOutputDevice()))return false;
|
|
changeProgram();
|
|
return true;
|
|
}
|
|
|
|
inline
|
|
bool Sequencer::clearNotes(void)
|
|
{
|
|
GlobalDefs::outDebug(String("[Sequencer::clearNotes]"),GlobalDefs::Info);
|
|
return midiEvent(ChannelModeMessage(ChannelModeMessage::AllNotesOff).getEvent());
|
|
}
|
|
|
|
inline
|
|
MIDIOutputDevice &Sequencer::getDevice(void)
|
|
{
|
|
Registry registry;
|
|
|
|
GlobalDefs::outDebug(String("[Sequencer::getDevice]"),GlobalDefs::Info);
|
|
if(!hasDevice())
|
|
{
|
|
GlobalDefs::outDebug(String("[Sequencer::getDevice] OpenDevice"),GlobalDefs::Info);
|
|
MIDIOutputDevice::openDevice(registry.getMIDIOutputDevice());
|
|
changeProgram();
|
|
}
|
|
return (MIDIOutputDevice&)*this;
|
|
}
|
|
|
|
inline
|
|
void Sequencer::changeProgram(void)
|
|
{
|
|
Registry registry;
|
|
GlobalDefs::outDebug(String("[Sequencer::changeProgram]"),GlobalDefs::Info);
|
|
midiEvent(ProgramChange(registry.getInstrument()).getEvent());
|
|
}
|
|
#endif
|