annotate constant-q-cpp/misc/yeti/plotfile.yeti @ 372:af71cbdab621 tip

Update bqvec code
author Chris Cannam
date Tue, 19 Nov 2019 10:13:32 +0000
parents 5d0a2ebb4d17
children
rev   line source
Chris@366 1
Chris@366 2 program plotfile;
Chris@366 3
Chris@366 4 af = load may.stream.audiofile;
Chris@366 5 plot = load may.plot;
Chris@366 6 cm = load may.matrix.complex;
Chris@366 7 mat = load may.matrix;
Chris@366 8
Chris@366 9 { cqt } = load cqt;
Chris@366 10
Chris@366 11 minFreq = 27.5;
Chris@366 12 maxRateDivisor = 3;
Chris@366 13 binsPerOctave = 60;
Chris@366 14
Chris@366 15 plotfile f =
Chris@366 16 (testStream = af.open f;
Chris@366 17 eprintln "Opened file stream...";
Chris@366 18 start = System#currentTimeMillis();
Chris@366 19 cq = cqt {
Chris@366 20 maxFreq = testStream.sampleRate/maxRateDivisor,
Chris@366 21 minFreq,
Chris@366 22 binsPerOctave
Chris@366 23 } testStream;
Chris@366 24 middle = System#currentTimeMillis();
Chris@366 25 eprintln "Generated kernel \(cm.size cq.kernel.kernel) and primed transform (\(cq.octaves) octaves), took \(middle-start)ms, now calculating...";
Chris@366 26 bigM = mat.concatHorizontal cq.cqSpectrogram;
Chris@366 27 finish = System#currentTimeMillis();
Chris@366 28 eprintln "Done, that part took \(finish-middle)ms, all CQ stuff took \(finish-start)ms";
Chris@366 29 eprintln "Plotting...";
Chris@366 30 \() (plot.plot [Contour bigM]));
Chris@366 31
Chris@366 32 usage () =
Chris@366 33 (eprintln "\nUsage: plotfile file.wav";
Chris@366 34 eprintln "\n Loads audio from file.wav and plots a \(binsPerOctave)bpo Constant-Q spectrogram";
Chris@366 35 eprintln " from \(minFreq)Hz up to 1/\(maxRateDivisor) of the file samplerate");
Chris@366 36
Chris@366 37 case (list _argv) of
Chris@366 38 file::[]: plotfile file;
Chris@366 39 _: usage ();
Chris@366 40 esac;
Chris@366 41