Skip to content
This is the development version of the documentation. It may change before the next release. See 0.6.x for the latest release.

fourier

src

fourier 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)?;
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).

Field Type Description
freq Freq<u32> etc. frequency of the component
option SineOption per-component sine Option
SineComponent {
freq: 100 * Hz,
option: SineOption::default(),
};
FourierOption {
scale_factor,
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
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,
)?;