Struct playdate_sys::ffi::playdate_sound_synth
source · #[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
impl Clone for playdate_sound_synth
source§fn clone(&self) -> playdate_sound_synth
fn clone(&self) -> playdate_sound_synth
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_synth
impl Debug for playdate_sound_synth
source§impl Default for playdate_sound_synth
impl Default for playdate_sound_synth
source§fn default() -> playdate_sound_synth
fn default() -> playdate_sound_synth
source§impl Hash for playdate_sound_synth
impl Hash for playdate_sound_synth
source§impl Ord for playdate_sound_synth
impl Ord for playdate_sound_synth
source§impl PartialEq for playdate_sound_synth
impl PartialEq for playdate_sound_synth
source§fn eq(&self, other: &playdate_sound_synth) -> bool
fn eq(&self, other: &playdate_sound_synth) -> bool
self and other values to be equal, and is used
by ==.source§impl PartialOrd for playdate_sound_synth
impl PartialOrd for playdate_sound_synth
impl Copy for playdate_sound_synth
impl Eq for playdate_sound_synth
impl StructuralEq for playdate_sound_synth
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 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: 104 bytes