pub fn generate_frequency_response_plot<Processor>(
    filename: &str,
    plot_name: &str,
    audio_processor: &mut Processor,
) where
    Processor: AudioProcessor<SampleType = f32>,
{
    let mut settings = AudioProcessorSettings::default();
    settings.sample_rate = 22050.0;
    settings.input_channels = 1;
    settings.output_channels = 1;
    audio_processor.prepare(settings);
    let sample_rate = settings.sample_rate;

    let frequencies = get_test_frequencies();
    let responses = frequencies
        .iter()
        .map(|frequency| test_frequency_response(sample_rate, *frequency, audio_processor))
        .collect();
    let chart_model = build_frequency_response_chart_model(responses);

    let filename = Path::new(filename);
    let chart_filename = filename.with_file_name(format!(
        "{}--{}.svg",
        filename.file_name().unwrap().to_str().unwrap(),
        plot_name
    ));

    let svg_backend = SVGBackend::new(&chart_filename, (1000, 1000));
    let drawing_area = svg_backend.into_drawing_area();
    drawing_area.fill(&WHITE).unwrap();

    let mut chart = ChartBuilder::on(&drawing_area)
        .caption(plot_name, ("sans-serif", 20))
        .set_label_area_size(LabelAreaPosition::Left, 40)
        .set_label_area_size(LabelAreaPosition::Bottom, 40)
        .build_cartesian_2d(
            chart_model.x_range.0..chart_model.x_range.1,
            chart_model.y_range.0..chart_model.y_range.1,
        )
        .unwrap();

    chart.configure_mesh().draw().unwrap();

    chart
        .draw_series(LineSeries::new(chart_model.values, &RED))
        .unwrap();
    println!(">>> Wrote {} chart to {:?}", plot_name, chart_filename);
}
/// Generates a frequency response plot for a given audio processor
Generates a frequency response plot for a given audio processor
Generates a frequency response plot for a given audio processor
pub fn generate_frequency_response_plot<Processor>(
    filename: &str,
    plot_name: &str,
    audio_processor: &mut Processor,
) where
    Processor: AudioProcessor<SampleType = f32>,
{
    let mut settings = AudioProcessorSettings::default();
    settings.sample_rate = 22050.0;
    settings.input_channels = 1;
    settings.output_channels = 1;
    audio_processor.prepare(settings);
    let sample_rate = settings.sample_rate;
    let frequencies = get_test_frequencies();
    let responses = frequencies
        .iter()
        .map(|frequency| test_frequency_response(sample_rate, *frequency, audio_processor))
        .collect();
    let chart_model = build_frequency_response_chart_model(responses);
    let filename = Path::new(filename);
    let chart_filename = filename.with_file_name(format!(
        "{}--{}.svg",
        filename.file_name().unwrap().to_str().unwrap(),
        plot_name
    ));
    let svg_backend = SVGBackend::new(&chart_filename, (1000, 1000));
    let drawing_area = svg_backend.into_drawing_area();
    drawing_area.fill(&WHITE).unwrap();
    let mut chart = ChartBuilder::on(&drawing_area)
        .caption(plot_name, ("sans-serif", 20))
        .set_label_area_size(LabelAreaPosition::Left, 40)
        .set_label_area_size(LabelAreaPosition::Bottom, 40)
        .build_cartesian_2d(
            chart_model.x_range.0..chart_model.x_range.1,
            chart_model.y_range.0..chart_model.y_range.1,
        )
        .unwrap();
    chart.configure_mesh().draw().unwrap();
    chart
        .draw_series(LineSeries::new(chart_model.values, &RED))
        .unwrap();
    println!(">>> Wrote {} chart to {:?}", plot_name, chart_filename);
}
pub fn generate_frequency_response_plot < Processor > ( filename : & str , plot_name : & str , audio_processor : & mut Processor , ) where Processor : AudioProcessor < SampleType = f32 > , { let mut settings = AudioProcessorSettings :: default ( ) ; settings . sample_rate = 22050.0 ; settings . input_channels = 1 ; settings . output_channels = 1 ; audio_processor . prepare ( settings ) ; let sample_rate = settings . sample_rate ; let frequencies = get_test_frequencies ( ) ; let responses = frequencies . iter ( ) . map ( | frequency | test_frequency_response ( sample_rate , * frequency , audio_processor ) ) . collect ( ) ; let chart_model = build_frequency_response_chart_model ( responses ) ; let filename = Path :: new ( filename ) ; let chart_filename = filename . with_file_name ( format ! ( " " filename file_name ( ) unwrap ( ) to_str ( ) unwrap ( ) plot_name ) ) ; let svg_backend = SVGBackend :: new ( & chart_filename , ( 1000 , 1000 ) ) ; let drawing_area = svg_backend . into_drawing_area ( ) ; drawing_area . fill ( & WHITE ) . unwrap ( ) ; let mut chart = ChartBuilder :: on ( & drawing_area ) . caption ( plot_name , ( " " , 20 ) ) . set_label_area_size ( LabelAreaPosition :: Left , 40 ) . set_label_area_size ( LabelAreaPosition :: Bottom , 40 ) . build_cartesian_2d ( chart_model . x_range . 0 .. chart_model . x_range . 1 , chart_model . y_range . 0 .. chart_model . y_range . 1 , ) . unwrap ( ) ; chart . configure_mesh ( ) . draw ( ) . unwrap ( ) ; chart . draw_series ( LineSeries :: new ( chart_model . values , & RED ) ) . unwrap ( ) ; println ! ( " " plot_name chart_filename ) ; }
Generates a frequency response plot for a given audio processor
Generates a frequency response plot for a given audio processor
filename
&str
plot_name
&str
audio_processor
&mut Processor
filename
&str
plot_name
&str
audio_processor
&mut Processor