|
AudioDataLib
A C++ library of classes supporting a variety of audio-data tasks.
|
This class knows how to playback MIDI files. More...
#include <MidiPlayer.h>
Classes | |
| class | TrackPlayer |
Public Member Functions | |
| MidiPlayer (Timer *timer) | |
| virtual | ~MidiPlayer () |
| virtual bool | Setup (Error &error) override |
| virtual bool | Shutdown (Error &error) override |
| virtual bool | Process (Error &error) override |
| void | SetMidiData (const MidiData *midiData) |
| const MidiData * | GetMidiData () const |
| bool | NoMoreToPlay () |
| void | ConfigureToPlayAllTracks () const |
| std::set< uint32_t > & | GetTracksConfiguredToPlay () |
| Timer * | GetTimer () |
Public Member Functions inherited from AudioDataLib::MidiMsgSource | |
| MidiMsgSource () | |
| virtual | ~MidiMsgSource () |
| void | AddDestination (std::shared_ptr< MidiMsgDestination > destination) |
| void | Clear () |
| template<typename T > | |
| T * | FindDestination () |
Protected Member Functions | |
| void | Clear () |
| bool | SilenceAllChannels (Error &error) |
Protected Member Functions inherited from AudioDataLib::MidiMsgSource | |
| bool | BroadcastMidiMessage (double deltaTimeSeconds, const uint8_t *messageBuffer, uint64_t messageBufferSize, Error &error) |
Protected Attributes | |
| const MidiData * | midiData |
| Timer * | timer |
| std::vector< TrackPlayer * > * | trackPlayerArray |
| std::set< uint32_t > * | tracksToPlaySet |
Protected Attributes inherited from AudioDataLib::MidiMsgSource | |
| std::vector< std::shared_ptr< MidiMsgDestination > > * | destinationArray |
This class knows how to playback MIDI files.
Again, since a goal of AudioDataLib is to depend at most on the C++ standard library, we are not sending MIDI message directly to a MIDI port for sound synthesis. Rather, we are sending them (in proper sequence and time) to any connected MidiMsgDestination classes which, in turn, may send them to a MIDI port, or be used to synthesize the MIDI messages into sound (such as is the case with any MidiSynth derivative.)
| MidiPlayer::MidiPlayer | ( | Timer * | timer | ) |
Construct a MIDI player to use the given timer for timing.
| [in] | timer | A heap allocation for a Timer class derivative. This class takes ownership of the memory. |
|
virtual |
|
protected |
| void MidiPlayer::ConfigureToPlayAllTracks | ( | ) | const |
While a subset of the set of all MIDI tracks of the given MidiData can be configured to play, this method insures that all tracks are configured to play.
|
inline |
Return the MidiData class instance being used for playback by this player.
|
inline |
Return a pointer to the Timer instance keeping time during playback. This could be used by the caller to know where (in time) playback is currently at.
|
inline |
Return a reference to the set of tracks that should play during playback. The caller can then modify this set as they see fit before playback begins. Once playback begins, this doing so does nothing.
| bool MidiPlayer::NoMoreToPlay | ( | ) |
At any time, this can be called to determine if the player is still playing.
|
overridevirtual |
This is called once per frame in a program's main loop, and should do any necessary processing of the MIDI message source (e.g., poll messages from a port), but should also call the base-class method here to process each connected MidiMsgDestination class.
Reimplemented from AudioDataLib::MidiMsgSource.
|
inline |
Set the MidiData class instance containing the MIDI data that will be played back by this player. Note that we do not take ownership of the memory, and we assume that the given pointer will not go stale before this class goes out of scope.
|
overridevirtual |
Perform any setup that is required, but also call this base-class method as it will attempt to initialize each MidiMsgDestination added to this class instance. If any one of those fails, then setup should fail.
Reimplemented from AudioDataLib::MidiMsgSource.
|
overridevirtual |
Perform any shutdown that is required, but also call this base-class method as it will shutdown each MidiMsgDestination added to this class instance. Though setup and shutdown routines (or, using alternative terms, initialization and finalization routines) have the same signature, it is convention that shutdown routines always succeed, at least as far as doing any clean-up needed to reclaim the state of the program after a successful or failed initialization. Still failure can be returned here if it's useful, and error information can be provided, but the return value is usually not checked.
Reimplemented from AudioDataLib::MidiMsgSource.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |