Guitarix
gx_pitch_tracker.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2009, 2010 Hermann Meyer, James Warden, Andreas Degert
3 * Copyright (C) 2011 Pete Shorthose
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 * --------------------------------------------------------------------------
19 */
20
21/* ------- This is the guitarix Engine namespace ------- */
22
23#pragma once
24
25#ifndef SRC_HEADERS_GX_PITCH_TRACKER_H_
26#define SRC_HEADERS_GX_PITCH_TRACKER_H_
27
28#include <fftw3.h>
29
30namespace gx_engine {
31/* ------------- Pitch Tracker ------------- */
32
34 public:
37 void init(int priority, int policy, unsigned int samplerate);
38 void add(int count, float *input);
39 float get_estimated_freq() { return m_freq < 0 ? 0 : m_freq; }
42 void reset();
44 Glib::Dispatcher new_freq;
45 private:
46 bool setParameters(int priority, int policy, int sampleRate, int fftSize );
47 void run();
48 static void *static_run(void* p);
49 void start_thread(int policy, int priority);
50 void copy();
51 bool error;
52 volatile bool busy;
53 int tick;
54 sem_t m_trig;
55 pthread_t m_pthr;
56 Resampler resamp;
59 float m_freq;
60 // Value of the threshold above which
61 // the processing is activated.
63 // Value of the threshold below which
64 // the input audio signal is deactivated.
66 // Time between frequency estimates (in seconds)
68 // number of samples in input buffer
70 // Size of the FFT window.
72 // The audio buffer that stores the input signal.
73 float *m_buffer;
74 // Index of the first empty position in the buffer.
76 // buffer for input signal
77 float *m_input;
78 // Whether or not the input level is high enough.
80 // Support buffer used to store signals in the time domain.
82 // Support buffer used to store signals in the frequency domain.
84 // Plan to compute the FFT of a given signal.
85 fftwf_plan m_fftwPlanFFT;
86 // Plan to compute the IFFT of a given signal (with additional zero-padding).
87 fftwf_plan m_fftwPlanIFFT;
88};
89
90}
91#endif // SRC_HEADERS_GX_PITCH_TRACKER_H_
bool setParameters(int priority, int policy, int sampleRate, int fftSize)
void init(int priority, int policy, unsigned int samplerate)
void add(int count, float *input)
void set_fast_note_detection(bool v)
void start_thread(int policy, int priority)
static void * static_run(void *p)
Glib::Dispatcher new_freq