aboutsummaryrefslogtreecommitdiff
path: root/src/midi_sequencer.hpp
diff options
context:
space:
mode:
authorWohlstand <admin@wohlnet.ru>2019-12-03 15:34:39 +0300
committerWohlstand <admin@wohlnet.ru>2019-12-03 15:34:39 +0300
commitc5e9ca56d446819bfd42615d2398e3817a286ef9 (patch)
tree9f536bb29b5eaf489e4f69876bfe2c76cbb78e14 /src/midi_sequencer.hpp
parent84af1cde8d624100b4396173688743368db64b58 (diff)
downloadlibADLMIDI-c5e9ca56d446819bfd42615d2398e3817a286ef9.tar.gz
libADLMIDI-c5e9ca56d446819bfd42615d2398e3817a286ef9.tar.bz2
libADLMIDI-c5e9ca56d446819bfd42615d2398e3817a286ef9.zip
MidiSequencer: Added PCM streaming code
This code piece should simplify a dealing with MIDI libraries TODO: Modify some content of adl_playFormat() to use this feature
Diffstat (limited to 'src/midi_sequencer.hpp')
-rw-r--r--src/midi_sequencer.hpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/midi_sequencer.hpp b/src/midi_sequencer.hpp
index 1eb5873..6832492 100644
--- a/src/midi_sequencer.hpp
+++ b/src/midi_sequencer.hpp
@@ -511,6 +511,34 @@ private:
//! Common error string
std::string m_errorString;
+ struct SequencerTime
+ {
+ //! Time buffer
+ double timeRest;
+ //! Sample rate
+ uint32_t sampleRate;
+ //! Size of one frame in bytes
+ uint32_t frameSize;
+ //! Minimum possible delay, granuality
+ double minDelay;
+ //! Last delay
+ double delay;
+
+ void init()
+ {
+ sampleRate = 44100;
+ frameSize = 2;
+ reset();
+ }
+
+ void reset()
+ {
+ timeRest = 0.0;
+ minDelay = 1.0 / static_cast<double>(sampleRate);
+ delay = 0.0;
+ }
+ } m_time;
+
public:
BW_MidiSequencer();
virtual ~BW_MidiSequencer();
@@ -522,6 +550,14 @@ public:
void setInterface(const BW_MidiRtInterface *intrf);
/**
+ * @brief Runs ticking in a sync with audio streaming. Use this together with onPcmRender hook to easily play MIDI.
+ * @param stream pointer to the output PCM stream
+ * @param length length of the buffer in bytes
+ * @return Count of recorded data in bytes
+ */
+ int playStream(uint8_t *stream, size_t length);
+
+ /**
* @brief Returns file format type of currently loaded file
* @return File format type enumeration
*/