【光雅集】3

audio 时频绘图

yum -y install freetype-devel libxml2-devel expat-devel

[root@localhost mysoul]# ls
Cargo.lock  Cargo.toml  src  target  test

[root@localhost mysoul]# cat Cargo.toml 
[package]
name = "mysoul"
version = "0.1.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
png = "0.16.8"
minimp3 = "0.5.1"
audio-visualizer = "0.2.2"

[root@localhost mysoul]# cat src/main.rs 
use minimp3::{Decoder as Mp3Decoder, Frame as Mp3Frame, Error as Mp3Error};
use audio_visualizer::ChannelInterleavement;
use audio_visualizer::Channels;
use audio_visualizer::waveform::staticc::png_file::waveform_static_png_visualize;
use std::path::PathBuf;
use std::fs::File;
use std::collections::BTreeMap;
use audio_visualizer::spectrum::staticc::png_file::spectrum_static_png_visualize;

fn main() {
    let mut path = PathBuf::new();
    path.push("test/samples");
    path.push("mysoul.mp3");
    let mut decoder = Mp3Decoder::new(File::open(path).unwrap());

    let mut lrlr_mp3_samples = vec![];
    loop {
        match decoder.next_frame() {
            Ok(Mp3Frame { data: samples_of_frame, .. }) => {
                for sample in samples_of_frame {
                    lrlr_mp3_samples.push(sample);
                }
            }
            Err(Mp3Error::Eof) => break,
            Err(e) => panic!("{:?}", e),
        }
    }

    waveform_static_png_visualize(
        &lrlr_mp3_samples,
        Channels::Stereo(ChannelInterleavement::LRLR),
        "test/out",
        "mysoul_waveform.png"
    );

    let mut spec = BTreeMap::new();

    spectrum_static_png_visualize(
        &spec,
        "test/out",
        "mysoul_spectrum.png",
        &[]
    );
}

[root@localhost mysoul]# ls test
out  samples

左右声道可见

rightmysoulwaveform.png

leftmysoulwaveform.png

频率不可见

mysoulspectrum.png

使用 spek 可见

mysoul.png

对比频率图表

以 A4=440Hz 为准

Note Frequency (Hz) Wavelength (cm)
C0 16.35 2109.89
C^#^0 /D^b^ 0 17.32 1991.47
D0 18.35 1879.69
D^#^0 /E^b^ 0 19.45 1774.20
E0 20.60 1674.62
F0 21.83 1580.63
F^#^0 /G^b^ 0 23.12 1491.91
G0 24.50 1408.18
G^#^0 /A^b^ 0 25.96 1329.14
A0 27.50 1254.55
A^#^0 /B^b^ 0 29.14 1184.13
B0 30.87 1117.67
C1 32.70 1054.94
C^#^1 /D^b^ 1 34.65 995.73
D1 36.71 939.85
D^#^1 /E^b^ 1 38.89 887.10
E1 41.20 837.31
F1 43.65 790.31
F^#^1 /G^b^ 1 46.25 745.96
G1 49.00 704.09
G^#^1 /A^b^ 1 51.91 664.57
A1 55.00 627.27
A^#^1 /B^b^ 1 58.27 592.07
B1 61.74 558.84
C2 65.41 527.47
C^#^2 /D^b^ 2 69.30 497.87
D2 73.42 469.92
D^#^2 /E^b^ 2 77.78 443.55
E2 82.41 418.65
F2 87.31 395.16
F^#^2 /G^b^ 2 92.50 372.98
G2 98.00 352.04
G^#^2 /A^b^ 2 103.83 332.29
A2 110.00 313.64
A^#^2 /B^b^ 2 116.54 296.03
B2 123.47 279.42
C3 130.81 263.74
C^#^3 /D^b^ 3 138.59 248.93
D3 146.83 234.96
D^#^3 /E^b^ 3 155.56 221.77
E3 164.81 209.33
F3 174.61 197.58
F^#^3 /G^b^ 3 185.00 186.49
G3 196.00 176.02
G^#^3 /A^b^ 3 207.65 166.14
A3 220.00 156.82
A^#^3 /B^b^ 3 233.08 148.02
B3 246.94 139.71
C4 261.63 131.87
C^#^4 /D^b^ 4 277.18 124.47
D4 293.66 117.48
D^#^4 /E^b^ 4 311.13 110.89
E4 329.63 104.66
F4 349.23 98.79
F^#^4 /G^b^ 4 369.99 93.24
G4 392.00 88.01
G^#^4 /A^b^ 4 415.30 83.07
A4 440.00 78.41
A^#^4 /B^b^ 4 466.16 74.01
B4 493.88 69.85
C5 523.25 65.93
C^#^5 /D^b^ 5 554.37 62.23
D5 587.33 58.74
D^#^5 /E^b^ 5 622.25 55.44
E5 659.25 52.33
F5 698.46 49.39
F^#^5 /G^b^ 5 739.99 46.62
G5 783.99 44.01
G^#^5 /A^b^ 5 830.61 41.54
A5 880.00 39.20
A^#^5 /B^b^ 5 932.33 37.00
B5 987.77 34.93
C6 1046.50 32.97
C^#^6 /D^b^ 6 1108.73 31.12
D6 1174.66 29.37
D^#^6 /E^b^ 6 1244.51 27.72
E6 1318.51 26.17
F6 1396.91 24.70
F^#^6 /G^b^ 6 1479.98 23.31
G6 1567.98 22.00
G^#^6 /A^b^ 6 1661.22 20.77
A6 1760.00 19.60
A^#^6 /B^b^ 6 1864.66 18.50
B6 1975.53 17.46
C7 2093.00 16.48
C^#^7 /D^b^ 7 2217.46 15.56
D7 2349.32 14.69
D^#^7 /E^b^ 7 2489.02 13.86
E7 2637.02 13.08
F7 2793.83 12.35
F^#^7 /G^b^ 7 2959.96 11.66
G7 3135.96 11.00
G^#^7 /A^b^ 7 3322.44 10.38
A7 3520.00 9.80
A^#^7 /B^b^ 7 3729.31 9.25
B7 3951.07 8.73
C8 4186.01 8.24
C^#^8 /D^b^ 8 4434.92 7.78
D8 4698.63 7.34
D^#^8 /E^b^ 8 4978.03 6.93
E8 5274.04 6.54
F8 5587.65 6.17
F^#^8 /G^b^ 8 5919.91 5.83
G8 6271.93 5.50
G^#^8 /A^b^ 8 6644.88 5.19
A8 7040.00 4.90
A^#^8 /B^b^ 8 7458.62 4.63
B8 7902.13 4.37

🙋
如何表格中上色?

  • 游戏

    沉迷游戏伤身,强撸灰飞烟灭。

    121 引用 • 780 回帖

广告 我要投放

欢迎来到这里!

我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。

注册 关于
请输入回帖内容 ...