This is the development version of the documentation. It may change before the next release. See 0.6.x for the latest release.
fourier
srcfourier generates an amplitude modulation synthesized from multiple sine-wave components. Each component is computed in the same way as sine, and they are summed into a single waveform.
fourier(&components, &option, &mut dst)?;fourier(components, option, dst)Modulation.Fourier(components, option, dst);| Parameter | Type | Description |
|---|---|---|
components |
&[SineComponent<S>] |
array of sine-wave components to synthesize |
option |
&FourierOption |
additional options (see below) |
dst |
&mut Vec<u8> |
output buffer |
Each SineComponent is a pair of a frequency freq and a SineOption.
The sampling_config of all components must be identical, otherwise an error occurs.
The length of the synthesized waveform is the least common multiple of the periods of the components.
Each sample is the sum of all components multiplied by a scale scale_factor), plus an offset offset).
SineComponent
Section titled “SineComponent”| Field | Type | Description |
|---|---|---|
freq |
Freq<u32> etc. |
frequency of the component |
option |
SineOption |
per-component sine Option |
SineComponent { freq: 100 * Hz, option: SineOption::default(),};SineComponent( 100.0 * Hz, SineOption(),)new SineComponent( 100 * Hz, new SineOption());FourierOption
Section titled “FourierOption”FourierOption { scale_factor, clamp, offset,}FourierOption( scale_factor, clamp, offset,)new FourierOption( scaleFactor, clamp, offset)| Field | Type | Default | Description |
|---|---|---|---|
scale_factor |
Option<f32> |
None |
scale applied to the synthesized value. If None, the reciprocal of the number of components |
clamp |
bool |
false |
whether to clamp out-of-range values to [0, 255] |
offset |
u8 |
0 |
DC offset added after synthesis |
Example
Section titled “Example”use autd3_rs::units::Hz;use autd3_rs_modulation::{FourierOption, SineComponent, SineOption, fourier};
let mut dst = Vec::new();
fourier( &[SineComponent { freq: 100 * Hz, option: SineOption::default(), }], &FourierOption { scale_factor: None, clamp: false, offset: 0x00, }, &mut dst,)?;from autd3.units import Hzfrom autd3_modulation import ( FourierOption, SineComponent, SineOption, fourier, modulation_buffer,)
dst = modulation_buffer()
fourier( [ SineComponent( freq=100 * Hz, option=SineOption(), ) ], FourierOption( scale_factor=None, clamp=False, offset=0x00, ), dst,)using AUTD3;using static AUTD3.Units;
var dst = Modulation.ModulationBuffer();
Modulation.Fourier( new[] { new SineComponent( 100 * Hz, new SineOption() ), }, new FourierOption( scaleFactor: null, clamp: false, offset: 0x00 ), dst);