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.

ChangeModulationBank

ChangeModulationBank is a low-level command that switches the Modulation bank to be played.

ChangeModulationBank {
bank,
transition_mode,
};
Field Type Description
bank ModulationBank Destination bank
transition_mode TransitionMode Behavior on switching
Immediate Immediate
SyncIdx When the playback index next becomes 0
SysTime(DcSysTime, margin) At the specified DC system time (margin is optional, see below)
Gpio(GpioIn) Trigger on the specified GPIO input pin
Ext Extended mode (automatically switches to the next bank when playback within the bank finishes)
Later Does not transition (only writes to the bank)

SysTime rejects a time earlier than “now + margin” with a MISS_TRANSITION_TIME error, because the FPGA may miss a transition whose time is too close. The margin defaults to 10 ms.

Later means “only write to the bank, do not transition”. Specifying it as the transition_mode of Modulation / FociStm / PatternStm writes and configures the bank without sending the trailing bank change. Specifying it on ChangeModulationBank / ChangePatternBank themselves, which are the transition commands, is a build-time error. Because Later never transitions, it is also exempt from the LoopBehavior combination constraint.

See GPIO pins for details on Gpio(GpioIn).

When switching to the same bank, the TransitionMode and LoopBehavior settings have no effect. For details on bank operation see the bank switching tutorial.

ChangeModulationBank is sent after preparing the bank with WriteModulationBuffer + ConfigModulation to switch the playback target.

use autd3_rs::commands::{ChangeModulationBank, ConfigModulation, WriteModulationBuffer};
use autd3_rs::geometry::{Autd3, Geometry};
use autd3_rs::units::Hz;
use autd3_rs::value::{LoopBehavior, ModulationBank, SamplingConfig, TransitionMode};
use autd3_rs::{Client, ClientConfig};
use autd3_rs_link_nop::Nop;
use autd3_rs_modulation::{SineOption, modulation_buffer, sine};
let geometry = Geometry::new(vec![Autd3::default()]);
let client = Client::open(&geometry, Nop, ClientConfig::default()).await?;
let mut data = modulation_buffer();
sine(150 * Hz, &SineOption::default(), &mut data)?;
let bank = ModulationBank::B0;
let mut builder = client.datagram_builder();
builder.push(WriteModulationBuffer {
bank,
offset: 0,
data: &data,
});
builder.push(ConfigModulation {
bank,
config: SamplingConfig::FREQ_4K,
size: data.len(),
loop_behavior: LoopBehavior::Infinite,
});
builder.push(ChangeModulationBank {
bank,
transition_mode: TransitionMode::Immediate,
});
let frames = builder.build()?;
for frame in &frames {
client.send_checked(frame).await?;
}
client.close().await?;