Fir
Fir
では任意のModulation
FIRフィルタを適用することができる.
以下は, サンプリング周波数, タップ数, カットオフ周波数のLPFを適用する例である.
use autd3::prelude::*;
use autd3::modulation::Fir;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let _ =
Fir {
target: Sine {
freq: 150. * Hz,
option: SineOption {
sampling_config: SamplingConfig::new(20.0 * kHz),
..Default::default()
},
},
coef: vec![
-0.000009, -0.000013, -0.000016, -0.000021, -0.000025, -0.000030, -0.000036,
-0.000042, -0.000049, -0.000056, -0.000064, -0.000072, -0.000080, -0.000088,
-0.000096, -0.000105, -0.000113, -0.000120, -0.000128, -0.000134, -0.000139,
-0.000143, -0.000146, -0.000146, -0.000145, -0.000141, -0.000135, -0.000124,
-0.000111, -0.000093, -0.000071, -0.000044, -0.000012, 0.000026, 0.000071,
0.000122, 0.000180, 0.000247, 0.000321, 0.000405, 0.000497, 0.000599, 0.000712,
0.000835, 0.000968, 0.001113, 0.001270, 0.001439, 0.001619, 0.001812, 0.002018,
0.002236, 0.002467, 0.002711, 0.002968, 0.003237, 0.003518, 0.003812, 0.004118,
0.004435, 0.004764, 0.005103, 0.005452, 0.005811, 0.006178, 0.006554, 0.006937,
0.007326, 0.007720, 0.008119, 0.008521, 0.008925, 0.009331, 0.009737, 0.010141,
0.010543, 0.010941, 0.011335, 0.011722, 0.012101, 0.012472, 0.012833, 0.013183,
0.013520, 0.013843, 0.014152, 0.014445, 0.014720, 0.014978, 0.015217, 0.015435,
0.015633, 0.015810, 0.015964, 0.016096, 0.016204, 0.016289, 0.016350, 0.016386,
0.016399, 0.016386, 0.016350, 0.016289, 0.016204, 0.016096, 0.015964, 0.015810,
0.015633, 0.015435, 0.015217, 0.014978, 0.014720, 0.014445, 0.014152, 0.013843,
0.013520, 0.013183, 0.012833, 0.012472, 0.012101, 0.011722, 0.011335, 0.010941,
0.010543, 0.010141, 0.009737, 0.009331, 0.008925, 0.008521, 0.008119, 0.007720,
0.007326, 0.006937, 0.006554, 0.006178, 0.005811, 0.005452, 0.005103, 0.004764,
0.004435, 0.004118, 0.003812, 0.003518, 0.003237, 0.002968, 0.002711, 0.002467,
0.002236, 0.002018, 0.001812, 0.001619, 0.001439, 0.001270, 0.001113, 0.000968,
0.000835, 0.000712, 0.000599, 0.000497, 0.000405, 0.000321, 0.000247, 0.000180,
0.000122, 0.000071, 0.000026, -0.000012, -0.000044, -0.000071, -0.000093,
-0.000111, -0.000124, -0.000135, -0.000141, -0.000145, -0.000146, -0.000146,
-0.000143, -0.000139, -0.000134, -0.000128, -0.000120, -0.000113, -0.000105,
-0.000096, -0.000088, -0.000080, -0.000072, -0.000064, -0.000056, -0.000049,
-0.000042, -0.000036, -0.000030, -0.000025, -0.000021, -0.000016, -0.000013,
-0.000009,
],
};
Ok(())
}
#include<autd3.hpp>
#include <autd3/modulation/fir.hpp>
int main() {
using namespace autd3;
modulation::Fir(
Sine(150 * Hz,
SineOption{
.sampling_config = SamplingConfig(20.0f * kHz),
}),
std::vector{
-0.000009f, -0.000013f, -0.000016f, -0.000021f, -0.000025f, -0.000030f,
-0.000036f, -0.000042f, -0.000049f, -0.000056f, -0.000064f, -0.000072f,
-0.000080f, -0.000088f, -0.000096f, -0.000105f, -0.000113f, -0.000120f,
-0.000128f, -0.000134f, -0.000139f, -0.000143f, -0.000146f, -0.000146f,
-0.000145f, -0.000141f, -0.000135f, -0.000124f, -0.000111f, -0.000093f,
-0.000071f, -0.000044f, -0.000012f, 0.000026f, 0.000071f, 0.000122f,
0.000180f, 0.000247f, 0.000321f, 0.000405f, 0.000497f, 0.000599f,
0.000712f, 0.000835f, 0.000968f, 0.001113f, 0.001270f, 0.001439f,
0.001619f, 0.001812f, 0.002018f, 0.002236f, 0.002467f, 0.002711f,
0.002968f, 0.003237f, 0.003518f, 0.003812f, 0.004118f, 0.004435f,
0.004764f, 0.005103f, 0.005452f, 0.005811f, 0.006178f, 0.006554f,
0.006937f, 0.007326f, 0.007720f, 0.008119f, 0.008521f, 0.008925f,
0.009331f, 0.009737f, 0.010141f, 0.010543f, 0.010941f, 0.011335f,
0.011722f, 0.012101f, 0.012472f, 0.012833f, 0.013183f, 0.013520f,
0.013843f, 0.014152f, 0.014445f, 0.014720f, 0.014978f, 0.015217f,
0.015435f, 0.015633f, 0.015810f, 0.015964f, 0.016096f, 0.016204f,
0.016289f, 0.016350f, 0.016386f, 0.016399f, 0.016386f, 0.016350f,
0.016289f, 0.016204f, 0.016096f, 0.015964f, 0.015810f, 0.015633f,
0.015435f, 0.015217f, 0.014978f, 0.014720f, 0.014445f, 0.014152f,
0.013843f, 0.013520f, 0.013183f, 0.012833f, 0.012472f, 0.012101f,
0.011722f, 0.011335f, 0.010941f, 0.010543f, 0.010141f, 0.009737f,
0.009331f, 0.008925f, 0.008521f, 0.008119f, 0.007720f, 0.007326f,
0.006937f, 0.006554f, 0.006178f, 0.005811f, 0.005452f, 0.005103f,
0.004764f, 0.004435f, 0.004118f, 0.003812f, 0.003518f, 0.003237f,
0.002968f, 0.002711f, 0.002467f, 0.002236f, 0.002018f, 0.001812f,
0.001619f, 0.001439f, 0.001270f, 0.001113f, 0.000968f, 0.000835f,
0.000712f, 0.000599f, 0.000497f, 0.000405f, 0.000321f, 0.000247f,
0.000180f, 0.000122f, 0.000071f, 0.000026f, -0.000012f, -0.000044f,
-0.000071f, -0.000093f, -0.000111f, -0.000124f, -0.000135f, -0.000141f,
-0.000145f, -0.000146f, -0.000146f, -0.000143f, -0.000139f, -0.000134f,
-0.000128f, -0.000120f, -0.000113f, -0.000105f, -0.000096f, -0.000088f,
-0.000080f, -0.000072f, -0.000064f, -0.000056f, -0.000049f, -0.000042f,
-0.000036f, -0.000030f, -0.000025f, -0.000021f, -0.000016f, -0.000013f,
-0.000009f});
return 0; }
using AUTD3Sharp;
using AUTD3Sharp.Modulation;
using static AUTD3Sharp.Units;
new Fir(
target: new Sine(freq: 150u * Hz, option: new SineOption
{
SamplingConfig = new SamplingConfig(20f * kHz)
}),
coef: [-0.000009f, -0.000013f, -0.000016f, -0.000021f, -0.000025f,
-0.000030f, -0.000036f, -0.000042f, -0.000049f, -0.000056f,
-0.000064f, -0.000072f, -0.000080f, -0.000088f, -0.000096f,
-0.000105f, -0.000113f, -0.000120f, -0.000128f, -0.000134f,
-0.000139f, -0.000143f, -0.000146f, -0.000146f, -0.000145f,
-0.000141f, -0.000135f, -0.000124f, -0.000111f, -0.000093f,
-0.000071f, -0.000044f, -0.000012f, 0.000026f, 0.000071f,
0.000122f, 0.000180f, 0.000247f, 0.000321f, 0.000405f,
0.000497f, 0.000599f, 0.000712f, 0.000835f, 0.000968f,
0.001113f, 0.001270f, 0.001439f, 0.001619f, 0.001812f,
0.002018f, 0.002236f, 0.002467f, 0.002711f, 0.002968f,
0.003237f, 0.003518f, 0.003812f, 0.004118f, 0.004435f,
0.004764f, 0.005103f, 0.005452f, 0.005811f, 0.006178f,
0.006554f, 0.006937f, 0.007326f, 0.007720f, 0.008119f,
0.008521f, 0.008925f, 0.009331f, 0.009737f, 0.010141f,
0.010543f, 0.010941f, 0.011335f, 0.011722f, 0.012101f,
0.012472f, 0.012833f, 0.013183f, 0.013520f, 0.013843f,
0.014152f, 0.014445f, 0.014720f, 0.014978f, 0.015217f,
0.015435f, 0.015633f, 0.015810f, 0.015964f, 0.016096f,
0.016204f, 0.016289f, 0.016350f, 0.016386f, 0.016399f,
0.016386f, 0.016350f, 0.016289f, 0.016204f, 0.016096f,
0.015964f, 0.015810f, 0.015633f, 0.015435f, 0.015217f,
0.014978f, 0.014720f, 0.014445f, 0.014152f, 0.013843f,
0.013520f, 0.013183f, 0.012833f, 0.012472f, 0.012101f,
0.011722f, 0.011335f, 0.010941f, 0.010543f, 0.010141f,
0.009737f, 0.009331f, 0.008925f, 0.008521f, 0.008119f,
0.007720f, 0.007326f, 0.006937f, 0.006554f, 0.006178f,
0.005811f, 0.005452f, 0.005103f, 0.004764f, 0.004435f,
0.004118f, 0.003812f, 0.003518f, 0.003237f, 0.002968f,
0.002711f, 0.002467f, 0.002236f, 0.002018f, 0.001812f,
0.001619f, 0.001439f, 0.001270f, 0.001113f, 0.000968f,
0.000835f, 0.000712f, 0.000599f, 0.000497f, 0.000405f,
0.000321f, 0.000247f, 0.000180f, 0.000122f, 0.000071f,
0.000026f, -0.000012f, -0.000044f, -0.000071f, -0.000093f,
-0.000111f, -0.000124f, -0.000135f, -0.000141f, -0.000145f,
-0.000146f, -0.000146f, -0.000143f, -0.000139f, -0.000134f,
-0.000128f, -0.000120f, -0.000113f, -0.000105f, -0.000096f,
-0.000088f, -0.000080f, -0.000072f, -0.000064f, -0.000056f,
-0.000049f, -0.000042f, -0.000036f, -0.000030f, -0.000025f,
-0.000021f, -0.000016f, -0.000013f, -0.000009f]
);
from pyautd3 import Hz, Sine, SineOption, kHz, SamplingConfig
from pyautd3.modulation import Fir
Fir(
target=Sine(
freq=150 * Hz,
option=SineOption(
sampling_config=SamplingConfig(20.0 * kHz),
),
),
coef=[
-0.000009, -0.000013, -0.000016, -0.000021, -0.000025, -0.000030, -0.000036,
-0.000042, -0.000049, -0.000056, -0.000064, -0.000072, -0.000080, -0.000088,
-0.000096, -0.000105, -0.000113, -0.000120, -0.000128, -0.000134, -0.000139,
-0.000143, -0.000146, -0.000146, -0.000145, -0.000141, -0.000135, -0.000124,
-0.000111, -0.000093, -0.000071, -0.000044, -0.000012, 0.000026, 0.000071,
0.000122, 0.000180, 0.000247, 0.000321, 0.000405, 0.000497, 0.000599, 0.000712,
0.000835, 0.000968, 0.001113, 0.001270, 0.001439, 0.001619, 0.001812, 0.002018,
0.002236, 0.002467, 0.002711, 0.002968, 0.003237, 0.003518, 0.003812, 0.004118,
0.004435, 0.004764, 0.005103, 0.005452, 0.005811, 0.006178, 0.006554, 0.006937,
0.007326, 0.007720, 0.008119, 0.008521, 0.008925, 0.009331, 0.009737, 0.010141,
0.010543, 0.010941, 0.011335, 0.011722, 0.012101, 0.012472, 0.012833, 0.013183,
0.013520, 0.013843, 0.014152, 0.014445, 0.014720, 0.014978, 0.015217, 0.015435,
0.015633, 0.015810, 0.015964, 0.016096, 0.016204, 0.016289, 0.016350, 0.016386,
0.016399, 0.016386, 0.016350, 0.016289, 0.016204, 0.016096, 0.015964, 0.015810,
0.015633, 0.015435, 0.015217, 0.014978, 0.014720, 0.014445, 0.014152, 0.013843,
0.013520, 0.013183, 0.012833, 0.012472, 0.012101, 0.011722, 0.011335, 0.010941,
0.010543, 0.010141, 0.009737, 0.009331, 0.008925, 0.008521, 0.008119, 0.007720,
0.007326, 0.006937, 0.006554, 0.006178, 0.005811, 0.005452, 0.005103, 0.004764,
0.004435, 0.004118, 0.003812, 0.003518, 0.003237, 0.002968, 0.002711, 0.002467,
0.002236, 0.002018, 0.001812, 0.001619, 0.001439, 0.001270, 0.001113, 0.000968,
0.000835, 0.000712, 0.000599, 0.000497, 0.000405, 0.000321, 0.000247, 0.000180,
0.000122, 0.000071, 0.000026, -0.000012, -0.000044, -0.000071, -0.000093,
-0.000111, -0.000124, -0.000135, -0.000141, -0.000145, -0.000146, -0.000146,
-0.000143, -0.000139, -0.000134, -0.000128, -0.000120, -0.000113, -0.000105,
-0.000096, -0.000088, -0.000080, -0.000072, -0.000064, -0.000056, -0.000049,
-0.000042, -0.000036, -0.000030, -0.000025, -0.000021, -0.000016, -0.000013,
-0.000009,
],
)