annotate yeti/plotfile.yeti @ 80:872fc9dc0321

Start on inverse code, fix up forward interface a bit
author Chris Cannam <c.cannam@qmul.ac.uk>
date Tue, 29 Apr 2014 08:36:47 +0100
parents 642df7b3346f
children
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@80 26 bigM = mat.concatHorizontal cq.cqSpectrogram;
c@72 27 finish = System#currentTimeMillis();
c@72 28 eprintln "Done, that part took \(finish-middle)ms, all CQ stuff took \(finish-start)ms";
c@66 29 eprintln "Plotting...";
c@66 30 \() (plot.plot [Contour bigM]));
c@66 31
c@66 32 usage () =
c@66 33 (eprintln "\nUsage: plotfile file.wav";
c@72 34 eprintln "\n Loads audio from file.wav and plots a \(binsPerOctave)bpo Constant-Q spectrogram";
c@72 35 eprintln " from \(minFreq)Hz up to 1/\(maxRateDivisor) of the file samplerate");
c@66 36
c@66 37 case (list _argv) of
c@66 38 file::[]: plotfile file;
c@66 39 _: usage ();
c@66 40 esac;
c@66 41