Struct playdate_sys::ffi::playdate_sound
source · #[repr(C)]pub struct playdate_sound {Show 24 fields
pub channel: *const playdate_sound_channel,
pub fileplayer: *const playdate_sound_fileplayer,
pub sample: *const playdate_sound_sample,
pub sampleplayer: *const playdate_sound_sampleplayer,
pub synth: *const playdate_sound_synth,
pub sequence: *const playdate_sound_sequence,
pub effect: *const playdate_sound_effect,
pub lfo: *const playdate_sound_lfo,
pub envelope: *const playdate_sound_envelope,
pub source: *const playdate_sound_source,
pub controlsignal: *const playdate_control_signal,
pub track: *const playdate_sound_track,
pub instrument: *const playdate_sound_instrument,
pub getCurrentTime: Option<unsafe extern "C" fn() -> u32>,
pub addSource: Option<unsafe extern "C" fn(callback: AudioSourceFunction, context: *mut c_void, stereo: c_int) -> *mut SoundSource>,
pub getDefaultChannel: Option<unsafe extern "C" fn() -> *mut SoundChannel>,
pub addChannel: Option<unsafe extern "C" fn(channel: *mut SoundChannel) -> c_int>,
pub removeChannel: Option<unsafe extern "C" fn(channel: *mut SoundChannel) -> c_int>,
pub setMicCallback: Option<unsafe extern "C" fn(callback: RecordCallback, context: *mut c_void, source: MicSource) -> c_int>,
pub getHeadphoneState: Option<unsafe extern "C" fn(headphone: *mut c_int, headsetmic: *mut c_int, changeCallback: Option<unsafe extern "C" fn(headphone: c_int, mic: c_int)>)>,
pub setOutputsActive: Option<unsafe extern "C" fn(headphone: c_int, speaker: c_int)>,
pub removeSource: Option<unsafe extern "C" fn(source: *mut SoundSource) -> c_int>,
pub signal: *const playdate_sound_signal,
pub getError: Option<unsafe extern "C" fn() -> *const c_char>,
}
Fields§
§channel: *const playdate_sound_channel
§fileplayer: *const playdate_sound_fileplayer
§sample: *const playdate_sound_sample
§sampleplayer: *const playdate_sound_sampleplayer
§synth: *const playdate_sound_synth
§sequence: *const playdate_sound_sequence
§effect: *const playdate_sound_effect
§lfo: *const playdate_sound_lfo
§envelope: *const playdate_sound_envelope
§source: *const playdate_sound_source
§controlsignal: *const playdate_control_signal
§track: *const playdate_sound_track
§instrument: *const playdate_sound_instrument
§getCurrentTime: Option<unsafe extern "C" fn() -> u32>
uint32_t playdate->sound->getCurrentTime(void)
Returns the sound engine’s current time value, in units of sample frames, 44,100 per second.
Equivalent to playdate.sound.getCurrentTime()
in the Lua API.
addSource: Option<unsafe extern "C" fn(callback: AudioSourceFunction, context: *mut c_void, stereo: c_int) -> *mut SoundSource>
SoundSource* playdate->sound->addSource(AudioSourceFunction* callback, void* context, int stereo)
The callback function you pass in will be called every audio render cycle.
AudioSourceFunction
int AudioSourceFunction(void* context, int16_t* left, int16_t* right, int len)
This function should fill the passed-in left buffer (and right if it’s a stereo source) with len samples each and return 1, or return 0 if the source is silent through the cycle.
getDefaultChannel: Option<unsafe extern "C" fn() -> *mut SoundChannel>
SoundChannel* playdate->sound->getDefaultChannel(void)
Returns the default channel, where sound sources play if they haven’t been explicity assigned to a different channel.
addChannel: Option<unsafe extern "C" fn(channel: *mut SoundChannel) -> c_int>
int playdate->sound->addChannel(SoundChannel* channel)
Adds the given channel to the sound engine. Returns 1 if the channel was added, 0 if it was already in the engine.
removeChannel: Option<unsafe extern "C" fn(channel: *mut SoundChannel) -> c_int>
int playdate->sound->removeChannel(SoundChannel* channel)
Removes the given channel from the sound engine. Returns 1 if the channel was successfully removed, 0 if the channel is the default channel or hadn’t been previously added.
setMicCallback: Option<unsafe extern "C" fn(callback: RecordCallback, context: *mut c_void, source: MicSource) -> c_int>
int playdate->sound->setMicCallback(AudioInputFunction* callback, void* context, enum MicSource source)
The callback you pass in will be called every audio cycle.
AudioInputFunction
int AudioInputFunction(void* context, int16_t* data, int len)
enum MicSource
enum MicSource {
kMicInputAutodetect = 0,
kMicInputInternal = 1,
kMicInputHeadset = 2
};
Your input callback will be called with the recorded audio data, a monophonic stream of samples. The function should return 1 to continue recording, 0 to stop recording.
The Playdate hardware has a circuit that attempts to autodetect the presence of a headset mic, but there are cases where you may want to override this. For instance, if you’re using a headphone splitter to wire an external source to the mic input, the detector may not always see the input. Setting the source to kMicInputHeadset
forces recording from the headset. Using kMicInputInternal
records from the device mic even when a headset with a mic is plugged in. And kMicInputAutodetect
uses a headset mic if one is detected, otherwise the device microphone. setMicCallback()
returns which source the function used, internal or headset, or 0 on error.
getHeadphoneState: Option<unsafe extern "C" fn(headphone: *mut c_int, headsetmic: *mut c_int, changeCallback: Option<unsafe extern "C" fn(headphone: c_int, mic: c_int)>)>
void playdate->sound->getHeadphoneState(int* headphone, int* mic, void (*changeCallback)(int headphone, int mic))
If headphone contains a pointer to an int, the value is set to 1 if headphones are currently plugged in. Likewise, mic is set if the headphones include a microphone. If changeCallback is provided, it will be called when the headset or mic status changes, and audio output will not automatically switch from speaker to headphones when headphones are plugged in (and vice versa). In this case, the callback should use playdate→sound→setOutputsActive()
to change the output if needed.
Equivalent to playdate.sound.getHeadphoneState()
in the Lua API.
setOutputsActive: Option<unsafe extern "C" fn(headphone: c_int, speaker: c_int)>
void playdate->sound->setOutputsActive(int headphone, int speaker)
Force audio output to the given outputs, regardless of headphone status.
Equivalent to playdate.sound.setOutputsActive()
in the Lua API.
removeSource: Option<unsafe extern "C" fn(source: *mut SoundSource) -> c_int>
int playdate->sound->removeSource(SoundSource* source)
Removes the given SoundSource object from its channel, whether it’s in the default channel or a channel created with playdate→sound→addChannel(). Returns 1 if a source was removed, 0 if the source wasn’t in a channel.
signal: *const playdate_sound_signal
§getError: Option<unsafe extern "C" fn() -> *const c_char>
Trait Implementations§
source§impl Clone for playdate_sound
impl Clone for playdate_sound
source§fn clone(&self) -> playdate_sound
fn clone(&self) -> playdate_sound
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for playdate_sound
impl Debug for playdate_sound
source§impl Default for playdate_sound
impl Default for playdate_sound
source§impl Hash for playdate_sound
impl Hash for playdate_sound
source§impl Ord for playdate_sound
impl Ord for playdate_sound
source§impl PartialEq for playdate_sound
impl PartialEq for playdate_sound
source§fn eq(&self, other: &playdate_sound) -> bool
fn eq(&self, other: &playdate_sound) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for playdate_sound
impl PartialOrd for playdate_sound
impl Copy for playdate_sound
impl Eq for playdate_sound
impl StructuralPartialEq for playdate_sound
Auto Trait Implementations§
impl Freeze for playdate_sound
impl RefUnwindSafe for playdate_sound
impl !Send for playdate_sound
impl !Sync for playdate_sound
impl Unpin for playdate_sound
impl UnwindSafe for playdate_sound
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere
U: From<T>,
§impl<T> ToOwned for Twhere
T: Clone,
impl<T> ToOwned for Twhere
T: Clone,
§impl<T, U> TryFrom<U> for Twhere
U: Into<T>,
impl<T, U> TryFrom<U> for Twhere
U: Into<T>,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 96 bytes