Chris@366: Chris@366: program plotfile; Chris@366: Chris@366: af = load may.stream.audiofile; Chris@366: plot = load may.plot; Chris@366: cm = load may.matrix.complex; Chris@366: mat = load may.matrix; Chris@366: Chris@366: { cqt } = load cqt; Chris@366: Chris@366: minFreq = 27.5; Chris@366: maxRateDivisor = 3; Chris@366: binsPerOctave = 60; Chris@366: Chris@366: plotfile f = Chris@366: (testStream = af.open f; Chris@366: eprintln "Opened file stream..."; Chris@366: start = System#currentTimeMillis(); Chris@366: cq = cqt { Chris@366: maxFreq = testStream.sampleRate/maxRateDivisor, Chris@366: minFreq, Chris@366: binsPerOctave Chris@366: } testStream; Chris@366: middle = System#currentTimeMillis(); Chris@366: eprintln "Generated kernel \(cm.size cq.kernel.kernel) and primed transform (\(cq.octaves) octaves), took \(middle-start)ms, now calculating..."; Chris@366: bigM = mat.concatHorizontal cq.cqSpectrogram; Chris@366: finish = System#currentTimeMillis(); Chris@366: eprintln "Done, that part took \(finish-middle)ms, all CQ stuff took \(finish-start)ms"; Chris@366: eprintln "Plotting..."; Chris@366: \() (plot.plot [Contour bigM])); Chris@366: Chris@366: usage () = Chris@366: (eprintln "\nUsage: plotfile file.wav"; Chris@366: eprintln "\n Loads audio from file.wav and plots a \(binsPerOctave)bpo Constant-Q spectrogram"; Chris@366: eprintln " from \(minFreq)Hz up to 1/\(maxRateDivisor) of the file samplerate"); Chris@366: Chris@366: case (list _argv) of Chris@366: file::[]: plotfile file; Chris@366: _: usage (); Chris@366: esac; Chris@366: