Skip to main content

FmSynth

Struct FmSynth 

Source
pub struct FmSynth<T: Transcendental, const N: usize> { /* private fields */ }
Expand description

Многооператорный FM синтезатор

Реализует архитектуру, аналогичную Yamaha DX7:

  • N операторов (обычно 4 или 6)
  • Каждый оператор может быть carrier или modulator
  • Гибкая матрица маршрутов модуляции
  • Индивидуальные индексы модуляции

§Пример

use rill_core_dsp::generators::*;
use rill_core_dsp::Algorithm;

// 6-операторный FM (как в DX7)
let frequencies = [440.0, 880.0, 1320.0, 1760.0, 2200.0, 2640.0];
let algorithm = [
    [false, true,  false, false, false, false],
    [false, false, true,  false, false, false],
    [false, false, false, true,  false, false],
    [false, false, false, false, true,  false],
    [false, false, false, false, false, true],
    [false, false, false, false, false, false],
];

let mut fm = FmSynth::<f32, 6>::new(frequencies, algorithm);
fm.init(44100.0);

Implementations§

Source§

impl<T: Transcendental, const N: usize> FmSynth<T, N>

Source

pub fn new(frequencies: [f32; N], algorithm: [[bool; N]; N]) -> Self

Создать новый FM синтезатор

§Arguments
  • frequencies - массив частот для каждого оператора
  • algorithm - матрица маршрутов модуляции N x N
Source

pub fn new_with_freq(frequency: f32, algorithm: [[bool; N]; N]) -> Self

Создать новый FM синтезатор со всеми операторами на одной частоте

Source

pub fn set_waveform(&mut self, index: usize, waveform: Waveform)

Установить форму волны для оператора

Source

pub fn set_frequency(&mut self, index: usize, freq: f32)

Установить частоту для оператора

Source

pub fn set_modulation_index(&mut self, index: usize, idx: T)

Установить индекс модуляции для оператора

Source

pub fn peek_operator(&self, index: usize) -> T

Получить текущее значение оператора (без обработки)

Source

pub fn reset_all(&mut self)

Сбросить все операторы

Trait Implementations§

Source§

impl<T: Transcendental, const N: usize> Algorithm<T> for FmSynth<T, N>

Source§

fn init(&mut self, sample_rate: f32)

Initialise the algorithm with a sample rate. Read more
Source§

fn reset(&mut self)

Reset the algorithm to its initial state. Read more
Source§

fn process( &mut self, input: Option<&[T]>, output: &mut [T], _ctx: &ActionContext<'_>, ) -> ProcessResult<()>

Process one block of audio. Read more
Source§

fn metadata(&self) -> AlgorithmMetadata

Descriptive metadata (defaults to empty).
Source§

fn apply_command(&mut self, _value: T)

Receive a real-time command value from the control path. Read more

Auto Trait Implementations§

§

impl<T, const N: usize> Freeze for FmSynth<T, N>
where T: Freeze,

§

impl<T, const N: usize> RefUnwindSafe for FmSynth<T, N>
where T: RefUnwindSafe,

§

impl<T, const N: usize> Send for FmSynth<T, N>

§

impl<T, const N: usize> Sync for FmSynth<T, N>

§

impl<T, const N: usize> Unpin for FmSynth<T, N>
where T: Unpin,

§

impl<T, const N: usize> UnsafeUnpin for FmSynth<T, N>
where T: UnsafeUnpin,

§

impl<T, const N: usize> UnwindSafe for FmSynth<T, N>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsAny for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert to &dyn std::any::Any
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert to &mut dyn std::any::Any
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.