HomeForumSourceResearchGuide
Sign in to contribute to source. how it works
Type definition file io.audio.AudioOut by barry
expand copy to clipboardexpand
uses AudioFormat
uses AudioTrack

/* {"description" : "Data type to report audio track events."} */
data TrackEvent {
	AudioTrack track
}

/* {"description" : "This API supports basic audio output. AudioTrack objects submitted to play on an output instance must contain audio frames in a format that matches the AudioFormat with which an AudioOut object is instantiated (no format conversion is performed)."} */
interface AudioOut {
	/* {"@description" : "An event of this type is emitted when a track finishes playing (due to its last frame being output)."} */
	event trackFinished(TrackEvent e)
	/* {"@description" : "Create a new audio output instance with a given format."} */
	AudioOut(store AudioFormat format)
	/* {"@description" : "Check if the audio output device is ready for playback. This should be checked after instantiation. A device may initially take some time to become ready for use, so periodic polling of ready() may be required. Once the device becomes ready it will remain ready until destroyed."} */
	bool ready()
	/* {"@description" : "Play the audio frames in an audio track. The audio frames must match the audio format with which this instance has been constructed (such as channel counts)."} */
	bool play(store AudioTrack track)
	/* {"@description" : "Stop an in-progress track, removing it from output."} */
	void stop(AudioTrack track)
	/* {"@description" : "Stop all audio playback from this output instance."} */
	void stopAll()
}
Revision history
To propose a new revision to this entity, use dana source put -ut your/new/version.dn -n io.audio.AudioOut -m "reason for update" -u yourUsername
Version 5 by barry
Version 4 by barry
Version 3 (this version) by barry
Notes for this version: Adds ready-check function, needed in some asynchronous platforms
Version 2 by barry
Version 1 by barry