Files
Work/guitar/backup/20030501/Sequencer.hpp
2024-08-07 09:16:27 -04:00

96 lines
1.7 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
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