annotate yeti/plotfile.yeti @ 66:3d165bf186f1

Add little program to plot cq of an audio file
author Chris Cannam <c.cannam@qmul.ac.uk>
date Fri, 14 Feb 2014 14:24:37 +0000
parents
children 642df7b3346f
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@66 11 plotfile f =
c@66 12 (testStream = af.open f;
c@66 13 eprintln "Opened file stream...";
c@66 14 cq = cqt {
c@66 15 maxFreq = testStream.sampleRate/2,
c@66 16 minFreq = 50,
c@66 17 binsPerOctave = 24
c@66 18 } testStream;
c@66 19 eprintln "Generated kernel and primed transform, now calculating...";
c@66 20 bigM = mat.concatHorizontal (map cm.magnitudes cq.output);
c@66 21 eprintln "Plotting...";
c@66 22 \() (plot.plot [Contour bigM]));
c@66 23
c@66 24 usage () =
c@66 25 (eprintln "\nUsage: plotfile file.wav";
c@66 26 eprintln "\n Loads audio from file.wav and plots a 24bpo Constant-Q spectrogram";
c@66 27 eprintln " from 50Hz up to half the file samplerate");
c@66 28
c@66 29 case (list _argv) of
c@66 30 file::[]: plotfile file;
c@66 31 _: usage ();
c@66 32 esac;
c@66 33