これは開発版のドキュメントである. 内容は次のリリースまでに変更される可能性がある. 最新のリリース版は 0.6.x を参照.
square
srcsquare は矩形波の振幅変調を生成する. 指定周波数 freq で high と low の 2 値を切り替える.
freq = 200 Hz
square(freq, &option, &mut dst)?;square(freq, option, dst)Modulation.Square(freq, option, dst);| 引数 | 型 | 説明 |
|---|---|---|
freq |
Freq<u32> 等 |
変調周波数 |
option |
&SquareOption |
追加オプション (下記参照) |
dst |
&mut Vec<u8> |
出力バッファ |
freq の指定方法は sine と同じ.
SquareOption
Section titled “SquareOption”SquareOption { low, high, duty, sampling_config,}SquareOption( low, high, duty, sampling_config,)new SquareOption( low, high, duty, samplingConfig)| フィールド | 型 | デフォルト | 説明 |
|---|---|---|---|
low |
u8 |
u8::MIN |
低レベルの振幅 |
high |
u8 |
u8::MAX |
高レベルの振幅 |
duty |
f32 |
0.5 |
1 周期に占める high の割合 |
sampling_config |
SamplingConfig |
SamplingConfig::FREQ_4K |
サンプリング設定 |
1 周期のうち duty の割合が high, 残りが low になる.
duty が duty を low, high になる.
Example
Section titled “Example”use autd3_rs::units::Hz;use autd3_rs::value::SamplingConfig;use autd3_rs_modulation::{SquareOption, square};
let mut dst = Vec::new();
square( 150 * Hz, &SquareOption { low: u8::MIN, high: u8::MAX, duty: 0.5, sampling_config: SamplingConfig::FREQ_4K, }, &mut dst,)?;from autd3.units import Hzfrom autd3.value import SamplingConfigfrom autd3_modulation import SquareOption, modulation_buffer, square
dst = modulation_buffer()
square( 150 * Hz, SquareOption( low=0x00, high=0xFF, duty=0.5, sampling_config=SamplingConfig.FREQ_4K, ), dst,)using AUTD3;using static AUTD3.Units;
var dst = Modulation.ModulationBuffer();
Modulation.Square( 150 * Hz, new SquareOption( low: byte.MinValue, high: byte.MaxValue, duty: 0.5f, samplingConfig: SamplingConfig.Freq4k ), dst);