34 MidiDeviceListConnection::Key add (
std::function<
void()> callback)
37 return callbacks.
emplace (key++, std::move (callback)).first->first;
40 void remove (
const MidiDeviceListConnection::Key k)
55 for (
auto it = callbacks.
begin();
it != callbacks.
end();)
56 NullCheckedInvocation::invoke ((
it++)->second);
76 auto tie()
const {
return std::tie (ins, outs); }
79 bool operator== (
const State&
other)
const {
return tie() ==
other.tie(); }
80 bool operator!= (
const State&
other)
const {
return tie() !=
other.tie(); }
83 void handleAsyncUpdate()
override
89 State lastNotifiedState;
90 MidiDeviceListConnection::Key key = 0;
94MidiDeviceListConnection::~MidiDeviceListConnection() noexcept
96 if (broadcaster !=
nullptr)
97 broadcaster->remove (key);
139 if (firstMessage ==
nullptr || firstMessage->message.getTimeStamp() > eventTime)
141 m->next = firstMessage;
146 auto*
mm = firstMessage;
148 while (
mm->next !=
nullptr &&
mm->next->message.getTimeStamp() <= eventTime)
163 while (firstMessage !=
nullptr)
165 auto* m = firstMessage;
166 firstMessage = firstMessage->next;
181void MidiOutput::run()
189 PendingMessage* message;
193 message = firstMessage;
195 if (message !=
nullptr)
199 if (eventTime > now + 20)
206 firstMessage = message->next;
211 if (message !=
nullptr)
223 if (eventTime > now - 200)
Holds a resizable array of primitive or copy-by-value objects.
Has a callback method that is triggered asynchronously.
void triggerAsyncUpdate()
Causes the callback to be triggered at a later time.
void cancelPendingUpdate() noexcept
This will stop any pending updates from happening.
Automatically locks and unlocks a mutex object.
static MessageManager * getInstance()
Returns the global instance of the MessageManager.
Holds a sequence of time-stamped midi events.
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.
static Array< MidiDeviceInfo > getAvailableDevices()
Returns a list of the available midi output devices.
bool startThread()
Attempts to start a new thread with default ('Priority::normal') priority.
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).
#define JUCE_ASSERT_MESSAGE_THREAD
This macro is used to catch unsafe use of functions which expect to only be called on the message thr...
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
unsigned int uint32
A platform-independent 32-bit unsigned integer type.
unsigned char uint8
A platform-independent 8-bit unsigned integer type.
int roundToInt(const FloatType value) noexcept
Fast floating-point-to-integer conversion.