Spatio-Temporal Modulation

The SDK provides a feature for periodically switching sound fields called Spatio-Temporal Modulation (STM). The SDK supports FociSTM for single to eight focal points and GainSTM for arbitrary Gain. FociSTM and GainSTM use the timer on the AUTD3 hardware, providing high time precision but with some constraints.

Common API for FociSTM/GainSTM

Getting Sampling Configuration

You can get the sampling configuration with sampling_config.

use autd3::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let stm = FociSTM {
    foci: vec![Point3::origin(), Point3::origin()],
    config: 1.0 * Hz,
};
dbg!(stm.sampling_config()?.freq()?); // -> 2Hz
Ok(())
}
#include<iostream>
#include<autd3.hpp>
int main() {
using namespace autd3;
FociSTM stm(
    std::vector{
        Point3::origin(),
        Point3::origin(),
    },
    1.0f * Hz);
std::cout << stm.sampling_config().freq() << std::endl;  // -> 2Hz
                                                         return 0; }
using AUTD3Sharp;
using AUTD3Sharp.Utils;
using static AUTD3Sharp.Units;
var stm = new FociSTM(foci: [Point3.Origin, Point3.Origin], config: 1.0f * Hz);
Console.WriteLine(stm.SamplingConfig().Freq()); // -> 2 Hz
import numpy as np
from pyautd3 import FociSTM, Hz
stm = FociSTM(
    foci=[np.array([0.0, 0.0, 0.0]), np.array([0.0, 0.0, 0.0])],
    config=1.0 * Hz,
)
print(stm.sampling_config().freq())  # -> 2Hz

LoopBehavior

In FociSTM/GainSTM, you can control the loop behavior. The default is an infinite loop.

For details, refer to Segment/LoopBehavior.

Utilities

Only the Rust version provides utilities for generating linear and circular trajectories.

use autd3::prelude::*;
fn main() {
let start = Point3::origin();
let end = Point3::origin();
let center = Point3::origin();
let radius = 30.0 * mm;
let num_points = 50;
let n = Vector3::z_axis();
let intensity = EmitIntensity::MAX;
let _ = 
FociSTM {
    foci: Line {
        start,
        end,
        num_points,
        intensity,
    },
    config: 1.0 * Hz,
};

let _ = 
FociSTM {
    foci: Circle {
        center,
        radius,
        num_points,
        n, // normal vector to the plane where the circle is drawn
        intensity,
    },
    config: 1.0 * Hz,
};
}