pub trait DspFormatBase: Sized + Copy + Default + Send {
    type Sample: DspType<Self>;
    type Note: DspType<Self>;
    type NoteOffset: DspType<Self>;
    type Frequency: DspType<Self>;
    type Scalar: DspType<Self>;
    type IScalar: DspType<Self>;
    type EnvParam: DspType<Self>;
    type EnvSignal: EnvType<Self> + Send;
    type Phase: DspType<Self>;
    type LfoFreq: DspType<Self>;
    type WideSample: Copy + Default + Add<Self::WideSample, Output = Self::WideSample>;
    type Context: Send + GetContext;

    // Required methods
    fn default_note() -> Self::Note;
    fn note_to_freq(note: Self::Note) -> Self::Frequency;
    fn sample_from_fixed(value: IScalarFxP) -> Self::Sample;
    fn sample_to_float(value: Self::Sample) -> f32;
    fn widen_sample(smp: Self::Sample) -> Self::WideSample;
    fn narrow_sample(wide_smp: Self::WideSample) -> Self::Sample;
    fn note_from_scalar(scalar: Self::Scalar) -> Self::Note;
    fn apply_note_offset(
        note: Self::Note,
        offset: Self::NoteOffset
    ) -> Self::Note;
}
Expand description

Type aliases defining the data types of various internal signals within the synthesizer. This is primariliy to be generic over fixed/floating point

Required Associated Types§

source

type Sample: DspType<Self>

A type representing a sample of audio data

source

type Note: DspType<Self>

A type representing a MIDI note number

source

type NoteOffset: DspType<Self>

A type representing an offset to a MIDI note number

source

type Frequency: DspType<Self>

A type representing a frequency

source

type Scalar: DspType<Self>

A type representing a value between 0 and 1

source

type IScalar: DspType<Self>

A type representing a value between -1 and 1

source

type EnvParam: DspType<Self>

A type representing a parameter to an envelope

source

type EnvSignal: EnvType<Self> + Send

A type representing internal envelope signal levels

source

type Phase: DspType<Self>

A type representing the phase of a sinusoid

source

type LfoFreq: DspType<Self>

A type representing the frequency of a LFO

source

type WideSample: Copy + Default + Add<Self::WideSample, Output = Self::WideSample>

A type representing a sample that may have higher precision/range

source

type Context: Send + GetContext

Type-specific context information

Required Methods§

source

fn default_note() -> Self::Note

Provide a value of the default note, definied as A440 (MIDI NN #69)

source

fn note_to_freq(note: Self::Note) -> Self::Frequency

Convert a midi Note into a Frequency

source

fn sample_from_fixed(value: IScalarFxP) -> Self::Sample

Convert a signed scalar to a Sample

source

fn sample_to_float(value: Self::Sample) -> f32

Convert a sample to a 32 bit float

source

fn widen_sample(smp: Self::Sample) -> Self::WideSample

Widen a sample to a WideSample

source

fn narrow_sample(wide_smp: Self::WideSample) -> Self::Sample

Narrow a WideSample to a Sample

source

fn note_from_scalar(scalar: Self::Scalar) -> Self::Note

Convert a Scalar to a Note (where 0 maps to the lowest representable note, and 1 maps to the highest)

source

fn apply_note_offset(note: Self::Note, offset: Self::NoteOffset) -> Self::Note

Apply a note offset

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl DspFormatBase for i16

Implementors§

source§

impl<T> DspFormatBase for T
where T: From<IScalarFxP> + From<NoteFxP> + Float + Send,

§

type Sample = T

§

type Note = T

§

type NoteOffset = T

§

type Frequency = T

§

type Scalar = T

§

type IScalar = T

§

type EnvParam = T

§

type EnvSignal = T

§

type Phase = T

§

type LfoFreq = T

§

type WideSample = T

§

type Context = Context<T>