1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// "pitch" - Licensed under the MIT LICENSE (see /LICENSE)
extern crate byteorder;
extern crate pitch;
use Cursor;
use ;
const RESOLUTION: usize = 2048; // size of buffer
/*
const A1: &[u8] = include_bytes!("a1.raw");
const A2: &[u8] = include_bytes!("a2.raw");
const A3: &[u8] = include_bytes!("a3.raw");
const A4: &[u8] = include_bytes!("a4.raw");
const SINE_A4: &[u8] = include_bytes!("sine.raw");
const SAW_A4: &[u8] = include_bytes!("sawtooth.raw");
const SQUARE_A4: &[u8] = include_bytes!("square.raw");
const BAD: &[u8] = include_bytes!("bad.raw");
const BAD2: &[u8] = include_bytes!("bad2.raw");
const BAD3: &[u8] = include_bytes!("bad3.raw");
const BAD4: &[u8] = include_bytes!("bad4.raw");
const BAD5: &[u8] = include_bytes!("bad5.raw");
const BAD6: &[u8] = include_bytes!("bad6.raw");
const BAD7: &[u8] = include_bytes!("bad7.raw");
const BAD8: &[u8] = include_bytes!("bad8.raw");
fn hz_of_raw(data: &[u8]) -> (f32, f32) {
// Read Sound Wave Data Into `samples`
let mut reader = Cursor::new(data);
let mut samples = [0.0f32; RESOLUTION];
for i in 0..RESOLUTION {
samples[i] = (reader.read_i16::<LittleEndian>().unwrap() as f32)
/ (::std::i16::MAX as f32);
}
pitch::detect(&samples)
}
*/