36MidiOutput::MidiOutput (
const String& deviceName)
37 :
Thread (
"midi out"), name (deviceName)
75 m->next = firstMessage;
80 auto*
mm = firstMessage;
82 while (
mm->next !=
nullptr &&
mm->next->message.getTimeStamp() <=
eventTime)
97 while (firstMessage !=
nullptr)
99 auto*
m = firstMessage;
100 firstMessage = firstMessage->next;
115void MidiOutput::run()
123 PendingMessage* message;
127 message = firstMessage;
129 if (message !=
nullptr)
131 eventTime = (uint32) roundToInt (message->message.getTimeStamp());
140 firstMessage = message->next;
145 if (message !=
nullptr)
147 std::unique_ptr<PendingMessage> messageDeleter (message);
157 if (eventTime > now - 200)
162 jassert (timeToWait < 1000 * 30);
163 wait ((
int) timeToWait);
Holds a resizable array of primitive or copy-by-value objects.
Used to iterate through the events in a MidiBuffer.
bool getNextEvent(MidiMessage &result, int &samplePosition) noexcept
Retrieves a copy of the next event from the buffer.
Holds a sequence of time-stamped midi events.
Encapsulates a MIDI message.
double getTimeStamp() const noexcept
Returns the timestamp associated with this message.
void sendBlockOfMessagesNow(const MidiBuffer &buffer)
Sends out a sequence of MIDI messages immediately.
void stopBackgroundThread()
Stops the background thread, and clears any pending midi events.
void clearAllPendingMessages()
Gets rid of any midi messages that had been added by sendBlockOfMessages().
void startBackgroundThread()
Starts up a background thread so that the device can send blocks of data.
void sendMessageNow(const MidiMessage &message)
Sends out a MIDI message immediately.
void sendBlockOfMessages(const MidiBuffer &buffer, double millisecondCounterToStartAt, double samplesPerSecondForBuffer)
This lets you supply a block of messages that will be sent out at some point in the future.
void startThread()
Starts the thread running.
bool wait(int timeOutMilliseconds) const
Suspends the execution of this thread until either the specified timeout period has elapsed,...
bool threadShouldExit() const
Checks whether the thread has been told to stop running.
bool stopThread(int timeOutMilliseconds)
Attempts to stop the thread running.
void notify() const
Wakes up the thread.
bool isThreadRunning() const
Returns true if the thread is currently active.
static void waitForMillisecondCounter(uint32 targetTime) noexcept
Waits until the getMillisecondCounter() reaches a given value.
static uint32 getMillisecondCounter() noexcept
Returns the number of millisecs since a fixed event (usually system startup).