The OpenD Programming Language

MidiOutputThreadImplementation

Undocumented in source.

Constructors

this
this(string device, bool startSuspended)

If you use the device string "DUMMY", it will still give you a timed thread with callbacks, but will not actually write to any midi device. You might use this if you want, for example, to display notes visually but not play them so a student can follow along with the computer.

Members

Functions

exit
void exit()

Exits the thread. The object is not usable again after calling this.

injectEvent
void injectEvent(ubyte a, ubyte b, ubyte c)
void injectEvent(MidiEvent event)

Injects a midi event to the stream. It will be triggered as soon as possible and will NOT trigger you callback.

loadStream
void loadStream(const(PlayStreamEvent)[] pendingStream)

If you want to use only injected events as a play stream, you might use arsd.midi.longWait here and just inject things as they come.

pause
void pause()

Pauses the midi playback. Will send a silence notes controller message to all channels, but otherwise leaves everything in place for a future call to unpause.

play
void play()

Instructs the player to start playing - unsuspend if suspended, unpause if paused. If it is already playing, it will do nothing.

setCallback
void setCallback(bool delegate(const PlayStreamEvent) callback)

Set this if you want to filter or otherwise respond to events.

setSpeed
void setSpeed(float multiplier)

Changes the speed of the playback clock to the given multiplier. So passing 2.0 will play at double real time. Calling it again will still play a double real time; the multiplier is always relative to real time and will not stack.

setStreamFinishedCallback
void setStreamFinishedCallback(void delegate() callback)

Set this to customize what happens when a stream finishes.

stop
void stop()

Stops the current playback stream. Will call the callback you set in setCallback.

suspend
void suspend()

Stops playback and closes the midi device, but keeps the thread waiting for an unsuspend call.

togglePause
void togglePause()
unpause
void unpause()

Pauses the midi playback. Will send a silence notes controller message to all channels, but otherwise leaves everything in place for a future call to unpause.

unsuspend
void unsuspend()

Stops playback and closes the midi device, but keeps the thread waiting for an unsuspend call.

Inherited Members

From Thread

~this
~this()

Cleans up any remaining resources used by this object.

getThis
Thread getThis()

Provides a reference to the calling thread.

start
Thread start()

Starts the thread and invokes the function or delegate passed upon construction.

join
Throwable join(bool rethrow)

Waits for this thread to complete. If the thread terminated as the result of an unhandled exception, this exception will be rethrown.

PRIORITY_MIN
int PRIORITY_MIN [@property getter]

//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////

PRIORITY_MAX
const(int) PRIORITY_MAX [@property getter]

//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////

PRIORITY_DEFAULT
int PRIORITY_DEFAULT [@property getter]

//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////

PRIORITY_MIN
int PRIORITY_MIN [@property getter]

The minimum scheduling priority that may be set for a thread. On systems where multiple scheduling policies are defined, this value represents the minimum valid priority for the scheduling policy of the process.

PRIORITY_MAX
const(int) PRIORITY_MAX [@property getter]

The maximum scheduling priority that may be set for a thread. On systems where multiple scheduling policies are defined, this value represents the maximum valid priority for the scheduling policy of the process.

PRIORITY_DEFAULT
int PRIORITY_DEFAULT [@property getter]

The default scheduling priority that is set for a thread. On systems where multiple scheduling policies are defined, this value represents the default priority for the scheduling policy of the process.

priority
int priority [@property getter]

Gets the scheduling priority for the associated thread.

priority
int priority [@property setter]

Sets the scheduling priority for the associated thread.

isRunning
bool isRunning [@property getter]

Tests whether this thread is running.

sleep
void sleep(Duration val)

Suspends the calling thread for at least the supplied period. This may result in multiple OS calls if period is greater than the maximum sleep duration supported by the operating system.

yield
void yield()

Forces a context switch to occur away from the calling thread.

Meta