comparison yeti/plotfile.yeti @ 72:642df7b3346f

Support returning a magnitude spectrum (dense) etc
author Chris Cannam <c.cannam@qmul.ac.uk>
date Thu, 20 Mar 2014 16:15:43 +0000
parents 3d165bf186f1
children 872fc9dc0321
comparison
equal deleted inserted replaced
71:4767faa6726f 72:642df7b3346f
6 cm = load may.matrix.complex; 6 cm = load may.matrix.complex;
7 mat = load may.matrix; 7 mat = load may.matrix;
8 8
9 { cqt } = load cqt; 9 { cqt } = load cqt;
10 10
11 minFreq = 27.5;
12 maxRateDivisor = 3;
13 binsPerOctave = 60;
14
11 plotfile f = 15 plotfile f =
12 (testStream = af.open f; 16 (testStream = af.open f;
13 eprintln "Opened file stream..."; 17 eprintln "Opened file stream...";
18 start = System#currentTimeMillis();
14 cq = cqt { 19 cq = cqt {
15 maxFreq = testStream.sampleRate/2, 20 maxFreq = testStream.sampleRate/maxRateDivisor,
16 minFreq = 50, 21 minFreq,
17 binsPerOctave = 24 22 binsPerOctave
18 } testStream; 23 } testStream;
19 eprintln "Generated kernel and primed transform, now calculating..."; 24 middle = System#currentTimeMillis();
20 bigM = mat.concatHorizontal (map cm.magnitudes cq.output); 25 eprintln "Generated kernel \(cm.size cq.kernel.kernel) and primed transform (\(cq.octaves) octaves), took \(middle-start)ms, now calculating...";
26 bigM = case (cq.output (Spectrogram ())) of
27 Real s: mat.concatHorizontal s;
28 _: failWith "Real expected";
29 esac;
30 finish = System#currentTimeMillis();
31 eprintln "Done, that part took \(finish-middle)ms, all CQ stuff took \(finish-start)ms";
21 eprintln "Plotting..."; 32 eprintln "Plotting...";
22 \() (plot.plot [Contour bigM])); 33 \() (plot.plot [Contour bigM]));
23 34
24 usage () = 35 usage () =
25 (eprintln "\nUsage: plotfile file.wav"; 36 (eprintln "\nUsage: plotfile file.wav";
26 eprintln "\n Loads audio from file.wav and plots a 24bpo Constant-Q spectrogram"; 37 eprintln "\n Loads audio from file.wav and plots a \(binsPerOctave)bpo Constant-Q spectrogram";
27 eprintln " from 50Hz up to half the file samplerate"); 38 eprintln " from \(minFreq)Hz up to 1/\(maxRateDivisor) of the file samplerate");
28 39
29 case (list _argv) of 40 case (list _argv) of
30 file::[]: plotfile file; 41 file::[]: plotfile file;
31 _: usage (); 42 _: usage ();
32 esac; 43 esac;