annotate 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
rev   line source
c@66 1
c@66 2 program plotfile;
c@66 3
c@66 4 af = load may.stream.audiofile;
c@66 5 plot = load may.plot;
c@66 6 cm = load may.matrix.complex;
c@66 7 mat = load may.matrix;
c@66 8
c@66 9 { cqt } = load cqt;
c@66 10
c@72 11 minFreq = 27.5;
c@72 12 maxRateDivisor = 3;
c@72 13 binsPerOctave = 60;
c@72 14
c@66 15 plotfile f =
c@66 16 (testStream = af.open f;
c@66 17 eprintln "Opened file stream...";
c@72 18 start = System#currentTimeMillis();
c@66 19 cq = cqt {
c@72 20 maxFreq = testStream.sampleRate/maxRateDivisor,
c@72 21 minFreq,
c@72 22 binsPerOctave
c@66 23 } testStream;
c@72 24 middle = System#currentTimeMillis();
c@72 25 eprintln "Generated kernel \(cm.size cq.kernel.kernel) and primed transform (\(cq.octaves) octaves), took \(middle-start)ms, now calculating...";
c@72 26 bigM = case (cq.output (Spectrogram ())) of
c@72 27 Real s: mat.concatHorizontal s;
c@72 28 _: failWith "Real expected";
c@72 29 esac;
c@72 30 finish = System#currentTimeMillis();
c@72 31 eprintln "Done, that part took \(finish-middle)ms, all CQ stuff took \(finish-start)ms";
c@66 32 eprintln "Plotting...";
c@66 33 \() (plot.plot [Contour bigM]));
c@66 34
c@66 35 usage () =
c@66 36 (eprintln "\nUsage: plotfile file.wav";
c@72 37 eprintln "\n Loads audio from file.wav and plots a \(binsPerOctave)bpo Constant-Q spectrogram";
c@72 38 eprintln " from \(minFreq)Hz up to 1/\(maxRateDivisor) of the file samplerate");
c@66 39
c@66 40 case (list _argv) of
c@66 41 file::[]: plotfile file;
c@66 42 _: usage ();
c@66 43 esac;
c@66 44