#[repr(C)]
pub struct playdate_sound_synth {
Show 26 fields pub newSynth: Option<unsafe extern "C" fn() -> *mut PDSynth>, pub freeSynth: Option<unsafe extern "C" fn(synth: *mut PDSynth)>, pub setWaveform: Option<unsafe extern "C" fn(synth: *mut PDSynth, wave: SoundWaveform)>, pub setGenerator: Option<unsafe extern "C" fn(synth: *mut PDSynth, stereo: c_int, render: synthRenderFunc, noteOn: synthNoteOnFunc, release: synthReleaseFunc, setparam: synthSetParameterFunc, dealloc: synthDeallocFunc, userdata: *mut c_void)>, pub setSample: Option<unsafe extern "C" fn(synth: *mut PDSynth, sample: *mut AudioSample, sustainStart: u32, sustainEnd: u32)>, pub setAttackTime: Option<unsafe extern "C" fn(synth: *mut PDSynth, attack: c_float)>, pub setDecayTime: Option<unsafe extern "C" fn(synth: *mut PDSynth, decay: c_float)>, pub setSustainLevel: Option<unsafe extern "C" fn(synth: *mut PDSynth, sustain: c_float)>, pub setReleaseTime: Option<unsafe extern "C" fn(synth: *mut PDSynth, release: c_float)>, pub setTranspose: Option<unsafe extern "C" fn(synth: *mut PDSynth, halfSteps: c_float)>, pub setFrequencyModulator: Option<unsafe extern "C" fn(synth: *mut PDSynth, mod_: *mut PDSynthSignalValue)>, pub getFrequencyModulator: Option<unsafe extern "C" fn(synth: *mut PDSynth) -> *mut PDSynthSignalValue>, pub setAmplitudeModulator: Option<unsafe extern "C" fn(synth: *mut PDSynth, mod_: *mut PDSynthSignalValue)>, pub getAmplitudeModulator: Option<unsafe extern "C" fn(synth: *mut PDSynth) -> *mut PDSynthSignalValue>, pub getParameterCount: Option<unsafe extern "C" fn(synth: *mut PDSynth) -> c_int>, pub setParameter: Option<unsafe extern "C" fn(synth: *mut PDSynth, parameter: c_int, value: c_float) -> c_int>, pub setParameterModulator: Option<unsafe extern "C" fn(synth: *mut PDSynth, parameter: c_int, mod_: *mut PDSynthSignalValue)>, pub getParameterModulator: Option<unsafe extern "C" fn(synth: *mut PDSynth, parameter: c_int) -> *mut PDSynthSignalValue>, pub playNote: Option<unsafe extern "C" fn(synth: *mut PDSynth, freq: c_float, vel: c_float, len: c_float, when: u32)>, pub playMIDINote: Option<unsafe extern "C" fn(synth: *mut PDSynth, note: MIDINote, vel: c_float, len: c_float, when: u32)>, pub noteOff: Option<unsafe extern "C" fn(synth: *mut PDSynth, when: u32)>, pub stop: Option<unsafe extern "C" fn(synth: *mut PDSynth)>, pub setVolume: Option<unsafe extern "C" fn(synth: *mut PDSynth, left: c_float, right: c_float)>, pub getVolume: Option<unsafe extern "C" fn(synth: *mut PDSynth, left: *mut c_float, right: *mut c_float)>, pub isPlaying: Option<unsafe extern "C" fn(synth: *mut PDSynth) -> c_int>, pub getEnvelope: Option<unsafe extern "C" fn(synth: *mut PDSynth) -> *mut PDSynthEnvelope>,
}

Fields§

§newSynth: Option<unsafe extern "C" fn() -> *mut PDSynth>

PDSynth* playdate->sound->synth->newSynth(void)

Creates a new synth object.

§freeSynth: Option<unsafe extern "C" fn(synth: *mut PDSynth)>

void playdate->sound->synth->freeSynth(PDSynth* synth)

Frees a synth object, first removing it from the sound engine if needed.

§setWaveform: Option<unsafe extern "C" fn(synth: *mut PDSynth, wave: SoundWaveform)>

void playdate->sound->synth->setWaveform(PDSynth* synth, SoundWaveform wave)

Sets the waveform of the synth. The SoundWaveform enum contains the following values:

SoundWaveform

typedef enum
{
	kWaveformSquare,
	kWaveformTriangle,
	kWaveformSine,
	kWaveformNoise,
	kWaveformSawtooth,
	kWaveformPOPhase,
	kWaveformPODigital,
	kWaveformPOVosim
} SoundWaveform;
§setGenerator: Option<unsafe extern "C" fn(synth: *mut PDSynth, stereo: c_int, render: synthRenderFunc, noteOn: synthNoteOnFunc, release: synthReleaseFunc, setparam: synthSetParameterFunc, dealloc: synthDeallocFunc, userdata: *mut c_void)>

void playdate->sound->synth->setGenerator(PDSynth* synth, int stereo, synthRenderFunc* render, synthNoteOnFunc* noteOn, synthReleaseFunc* release, synthSetParameterFunc* setparam, synthDeallocFunc* dealloc, void* userdata)

GeneratorCallbacks

typedef int (*synthRenderFunc)(void* userdata, int32_t* left, int32_t* right, int nsamples, uint32_t rate, int32_t drate);
typedef void (*synthNoteOnFunc)(void* userdata, MIDINote note, float velocity, float len); // len == -1 if indefinite
typedef void (*synthReleaseFunc)(void* userdata, int ended);
typedef int (*synthSetParameterFunc)(void* userdata, int parameter, float value);
typedef void (*synthDeallocFunc)(void* userdata);

Provides custom waveform generator functions for the synth. synthRenderFunc, the data provider callback, is the only required function. left (and right if setGenerator() was called with the stereo flag set) are sample buffers in Q8.24 format. rate is the amount to change a (Q32) phase accumulator each sample, and drate is the amount to change rate each sample. Custom synths can safely ignore this and use the note paramter in the noteOn function to handle pitch, but synth→setFrequencyModulator() won’t work as expected. These functions are called on the audio render thread, so they should return as quickly as possible.

§setSample: Option<unsafe extern "C" fn(synth: *mut PDSynth, sample: *mut AudioSample, sustainStart: u32, sustainEnd: u32)>

void playdate->sound->synth->setSample(PDSynth* synth, AudioSample* sample, uint32_t sustainStart, uint32_t sustainEnd)

Provides a sample for the synth to play. Sample data must be uncompressed PCM, not ADPCM.

§setAttackTime: Option<unsafe extern "C" fn(synth: *mut PDSynth, attack: c_float)>

void playdate->sound->synth->setAttackTime(PDSynth* synth, float attack)

§setDecayTime: Option<unsafe extern "C" fn(synth: *mut PDSynth, decay: c_float)>

void playdate->sound->synth->setDecayTime(PDSynth* synth, float decay)

§setSustainLevel: Option<unsafe extern "C" fn(synth: *mut PDSynth, sustain: c_float)>

void playdate->sound->synth->setSustainLevel(PDSynth* synth, float sustain)

§setReleaseTime: Option<unsafe extern "C" fn(synth: *mut PDSynth, release: c_float)>

void playdate->sound->synth->setReleaseTime(PDSynth* synth, float release)

Sets the parameters of the synth’s ADSR envelope.

§setTranspose: Option<unsafe extern "C" fn(synth: *mut PDSynth, halfSteps: c_float)>

void playdate->sound->synth->setTranspose(PDSynth* synth, float halfSteps)

Transposes the synth’s output by the given number of half steps. For example, if the transpose is set to 2 and a C note is played, the synth will output a D instead.

§setFrequencyModulator: Option<unsafe extern "C" fn(synth: *mut PDSynth, mod_: *mut PDSynthSignalValue)>

void playdate->sound->synth->setFrequencyModulator(PDSynth* synth, PDSynthSignalValue* mod)

§getFrequencyModulator: Option<unsafe extern "C" fn(synth: *mut PDSynth) -> *mut PDSynthSignalValue>

PDSynthSignalValue* playdate->sound->synth->getFrequencyModulator(PDSynth* synth)

Sets or gets a signal to modulate the synth’s frequency. The signal is scaled so that a value of 1 doubles the synth pitch (i.e. an octave up) and -1 halves it (an octave down).

§setAmplitudeModulator: Option<unsafe extern "C" fn(synth: *mut PDSynth, mod_: *mut PDSynthSignalValue)>

void playdate->sound->synth->setAmplitudeModulator(PDSynth* synth, PDSynthSignalValue* mod)

§getAmplitudeModulator: Option<unsafe extern "C" fn(synth: *mut PDSynth) -> *mut PDSynthSignalValue>

PDSynthSignalValue* playdate->sound->synth->getAmplitudeModulator(PDSynth* synth)

Sets or gets a signal to modulate the synth’s output amplitude.

§getParameterCount: Option<unsafe extern "C" fn(synth: *mut PDSynth) -> c_int>

int playdate->sound->synth->getParameterCount(PDSynth* synth)

Returns the number of parameters advertised by the synth.

§setParameter: Option<unsafe extern "C" fn(synth: *mut PDSynth, parameter: c_int, value: c_float) -> c_int>

int playdate->sound->synth->setParameter(PDSynth* synth, int num, float value)

Sets the (1-based) parameter at position num to the given value. Returns 0 if num is not a valid parameter index.

§setParameterModulator: Option<unsafe extern "C" fn(synth: *mut PDSynth, parameter: c_int, mod_: *mut PDSynthSignalValue)>

int playdate->sound->synth->setParameterModulator(PDSynth* synth, int num, PDSynthSignalValue* mod)

§getParameterModulator: Option<unsafe extern "C" fn(synth: *mut PDSynth, parameter: c_int) -> *mut PDSynthSignalValue>

PDSynthSignalValue* playdate->sound->synth->newSynth(PDSynth* synth, int num)

Sets or gets a signal to modulate the parameter at index num.

§playNote: Option<unsafe extern "C" fn(synth: *mut PDSynth, freq: c_float, vel: c_float, len: c_float, when: u32)>

void playdate->sound->synth->playNote(PDSynth* synth, float freq, float vel, float len, uint32_t when)

Plays a note on the synth, at the given frequency. Specify len = -1 to leave the note playing until a subsequent noteOff() call. If when is 0, the note is played immediately, otherwise the note is scheduled for the given time. Use playdate→sound→getCurrentTime() to get the current time.

§playMIDINote: Option<unsafe extern "C" fn(synth: *mut PDSynth, note: MIDINote, vel: c_float, len: c_float, when: u32)>

void playdate->sound->synth->playMIDINote(PDSynth* synth, MIDINote note, float vel, float len, uint32_t when)

The same as playNote but uses MIDI note (where 60 = C4) instead of frequency.

§noteOff: Option<unsafe extern "C" fn(synth: *mut PDSynth, when: u32)>

void playdate->sound->synth->noteOff(PDSynth* synth, uint32_t when)

Sends a note off event to the synth, either immediately (when = 0) or at the scheduled time.

§stop: Option<unsafe extern "C" fn(synth: *mut PDSynth)>§setVolume: Option<unsafe extern "C" fn(synth: *mut PDSynth, left: c_float, right: c_float)>

void playdate->sound->synth->setVolume(PDSynth* synth, float lvol, float rvol)

§getVolume: Option<unsafe extern "C" fn(synth: *mut PDSynth, left: *mut c_float, right: *mut c_float)>

void playdate->sound->synth->getVolume(PDSynth* synth, float* outlvol, float* outrvol)

Sets and gets the playback volume (0.0 - 1.0) for left and right channels of the synth. This is equivalent to

playdate->sound->source->setVolume((SoundSource*)synth, lvol, rvol);
playdate->sound->source->getVolume((SoundSource*)synth, &lvol, &rvol);
§isPlaying: Option<unsafe extern "C" fn(synth: *mut PDSynth) -> c_int>

int playdate->sound->synth->isPlaying(PDSynth* synth)

Returns 1 if the synth is currently playing.

§getEnvelope: Option<unsafe extern "C" fn(synth: *mut PDSynth) -> *mut PDSynthEnvelope>

PDSynthEnvelope* playdate->sound->synth->getEnvelope(PDSynth* synth)

Returns the synth’s envelope. The PDSynth object owns this envelope, so it must not be freed.

Trait Implementations§

source§

impl Clone for playdate_sound_synth

source§

fn clone(&self) -> playdate_sound_synth

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_synth

source§

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

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

impl Default for playdate_sound_synth

source§

fn default() -> playdate_sound_synth

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

impl Hash for playdate_sound_synth

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_synth

source§

fn cmp(&self, other: &playdate_sound_synth) -> 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_synth

source§

fn eq(&self, other: &playdate_sound_synth) -> 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_synth

source§

fn partial_cmp(&self, other: &playdate_sound_synth) -> 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_synth

source§

impl Eq for playdate_sound_synth

source§

impl StructuralEq for playdate_sound_synth

source§

impl StructuralPartialEq for playdate_sound_synth

Auto Trait Implementations§

§

impl RefUnwindSafe for playdate_sound_synth

§

impl Send for playdate_sound_synth

§

impl Sync for playdate_sound_synth

§

impl Unpin for playdate_sound_synth

§

impl UnwindSafe for playdate_sound_synth

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: 104 bytes