X-Git-Url: https://git.sesse.net/?p=pitch;a=blobdiff_plain;f=pitch.cpp;h=421c2f24cea126da2dc786f4a918624dd459ac41;hp=6ec6155cde18b4c479340d9cf824c6d705240c14;hb=abee20b74fec255942d42656047e371979ef0fcf;hpb=f08b6405c3248dc9c4852bf93d82f87a8c45a179 diff --git a/pitch.cpp b/pitch.cpp index 6ec6155..421c2f2 100644 --- a/pitch.cpp +++ b/pitch.cpp @@ -9,16 +9,15 @@ #include "pitchdetector.h" void print_spectrogram(double freq, double amp); -void write_sine(int dsp_fd, double freq, unsigned num_samples); int main() { PitchDetector pd(SAMPLE_RATE, FFT_LENGTH, PAD_FACTOR, OVERLAP); - int fd = get_dsp_fd(SAMPLE_RATE, FFT_LENGTH, OVERLAP); + snd_pcm_t *pcm = get_dsp_handle(SAMPLE_RATE); for ( ;; ) { short buf[FFT_LENGTH / PAD_FACTOR / OVERLAP]; - read_chunk(fd, buf, FFT_LENGTH / PAD_FACTOR / OVERLAP); + read_chunk(pcm, buf, FFT_LENGTH / PAD_FACTOR / OVERLAP); std::pair peak = pd.detect_pitch(buf); if (peak.first < 50.0 || peak.second - log10(FFT_LENGTH) < 0.0) {