SamplingConfig
SamplingConfig represents the sampling frequency of Modulation or STM.
The sampling frequency must be the ultrasound frequency (40 kHz) divided by an integer.
SamplingConfig::new(NonZeroU16::new(10).unwrap());SamplingConfig::new(4. * kHz);SamplingConfig::new(Duration::from_micros(250));SamplingConfig::new(Nearest(4. * kHz));SamplingConfig::new(Nearest(Duration::from_micros(250)));SamplingConfig(10)SamplingConfig(4.0 * kHz)SamplingConfig(Duration.from_micros(250))SamplingConfig(Nearest(4.0 * kHz))SamplingConfig(Nearest(Duration.from_micros(250)))new SamplingConfig(10);new SamplingConfig(4.0f * kHz);new SamplingConfig(TimeSpan.FromMicroseconds(250));new SamplingConfig(Nearest(4.0f * kHz));new SamplingConfig(Nearest(TimeSpan.FromMicroseconds(250)));SamplingConfig::new accepts NonZeroU16 / Freq<f32> / Duration / Nearest<Freq<f32>> / Nearest<Duration>.
All of the above represent 4 kHz (division ratio 10) and are equivalent to one another.
Internal Representation
Section titled “Internal Representation”SamplingConfig can be specified as one of the following. Internally, it is ultimately converted to a division ratio (u16).
| Specification method | Type |
|---|---|
| Division ratio | NonZeroU16 |
| Frequency | Freq<f32> |
| Period | Duration |
The relationship between the division ratio
When specified by frequency or period, it is an error if it does not evenly divide 40 kHz (i.e., does not yield an integer division ratio).
To round an indivisible value to the nearest division ratio, wrap the frequency/period in Nearest.
Presets
Section titled “Presets”Frequently used constants are provided in advance.
| Constant | Sampling frequency | Division ratio |
|---|---|---|
FREQ_40K |
40 kHz | 1 |
FREQ_4K |
4 kHz | 10 |