<jupyter_start><jupyter_text>upsampling<jupyter_code>:dep plotters = { version = "0.3.1", default_features = false, features = ["evcxr", "line_series", "point_series"] }
// :dep libymfm = { path = "/home/hiromasa/devel/amd64/libymfm.wasm" }

extern crate plotters;
// extern crate libymfm;

use plotters::prelude::*;
use plotters::series::*;
use std::f32::consts::PI;

// use libymfm::sound::SoundStream;
// let _stream = SoundStream::new(44100, 96000);

let figure = evcxr_figure((1280, 600), |root| {

    let sampling_rate = 96000_f32;
    let length = sampling_rate / 440_f32;

    root.fill(&WHITE);
    let mut chart = ChartBuilder::on(&root)
        .caption("UpSampling", ("Arial", 20).into_font())
        .margin(5)
        .x_label_area_size(30)
        .y_label_area_size(30)
        .build_cartesian_2d(0f32..length, -1f32..1f32)?;

    chart.configure_mesh().draw()?;

    let rate = 440_f32 * 2_f32;
    let sample_22020: Vec<(f32, f32)> = (0_f32..(22010_f32 / 440_f32)).step(1_f32).values().map(|n| (n, 0.8_f32 * ((2.0_f32 * PI * rate * n) / 22020_f32).sin())).collect();
    let sample_96000: Vec<(f32, f32)> = (0_f32..length).step(1_f32).values().map(|n| (n, 0.8_f32 * ((2.0_f32 * PI * rate * n) / 96000_f32).sin())).collect();

    chart.draw_series(LineSeries::new(
        sample_22020.clone(),
        &RED,
    ))?.label("22020Hz").legend(|(x, y)| PathElement::new(vec![(x, y), (x + 20, y)], &RED));

    chart.draw_series(LineSeries::new(
        sample_96000.clone(),
        &BLUE,
    ))?.label("96000Hz").legend(|(x, y)| PathElement::new(vec![(x, y), (x + 20, y)], &BLUE));

    chart.configure_series_labels()
        .background_style(&WHITE.mix(0.8))
        .border_style(&BLACK)
        .draw()?;
    Ok(())
});
figure<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2038180797304885, 'fraction_numerical': 0.0892756878158338, 'mean_word_length': 3.6527415143603132, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '414293', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 805, 'n_tokens_neox': 702, 'n_words': 115, 'path': 'docs/notebook/test.ipynb', 'repo_name': 'h1romas4/libymfm.wasm', 'size': '1781'}