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

source§

fn clone(&self) -> playdate_sound

Returns a copy of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for playdate_sound

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for playdate_sound

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Hash for playdate_sound

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given [Hasher]. Read more
1.3.0§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given [Hasher]. Read more
source§

impl Ord for playdate_sound

source§

fn cmp(&self, other: &playdate_sound) -> Ordering

This method returns an [Ordering] between self and other. Read more
1.21.0§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for playdate_sound

source§

fn eq(&self, other: &playdate_sound) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for playdate_sound

source§

fn partial_cmp(&self, other: &playdate_sound) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Copy for playdate_sound

source§

impl Eq for playdate_sound

source§

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 T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

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