Loading...
Searching...
No Matches
gx_pitch_tracker.h
Go to the documentation of this file.
/*
* Copyright (C) 2009, 2010 Hermann Meyer, James Warden, Andreas Degert
* Copyright (C) 2011 Pete Shorthose
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* --------------------------------------------------------------------------
*/
/* ------- This is the guitarix Engine namespace ------- */
#pragma once
#ifndef SRC_HEADERS_GX_PITCH_TRACKER_H_
#define SRC_HEADERS_GX_PITCH_TRACKER_H_
#include <fftw3.h>
namespace gx_engine {
/* ------------- Pitch Tracker ------------- */
class PitchTracker {
public:
PitchTracker();
~PitchTracker();
void init(int priority, int policy, unsigned int samplerate);
void add(int count, float *input);
float get_estimated_freq() { return m_freq < 0 ? 0 : m_freq; }
float get_estimated_note();
void stop_thread();
void reset();
void set_fast_note_detection(bool v);
sigc::signal<void > new_freq;
private:
bool setParameters(int priority, int policy, int sampleRate, int fftSize );
void run();
static void *static_run(void* p);
void start_thread(int policy, int priority);
void copy();
bool error;
volatile bool busy;
int tick;
sem_t m_trig;
pthread_t m_pthr;
Resampler resamp;
int m_sampleRate;
int fixed_sampleRate;
float m_freq;
// Value of the threshold above which
// the processing is activated.
float signal_threshold_on;
// Value of the threshold below which
// the input audio signal is deactivated.
float signal_threshold_off;
// Time between frequency estimates (in seconds)
float tracker_period;
// number of samples in input buffer
int m_buffersize;
// Size of the FFT window.
int m_fftSize;
// The audio buffer that stores the input signal.
float *m_buffer;
// Index of the first empty position in the buffer.
int m_bufferIndex;
// buffer for input signal
float *m_input;
// Whether or not the input level is high enough.
bool m_audioLevel;
// Support buffer used to store signals in the time domain.
float *m_fftwBufferTime;
// Support buffer used to store signals in the frequency domain.
float *m_fftwBufferFreq;
// Plan to compute the FFT of a given signal.
fftwf_plan m_fftwPlanFFT;
// Plan to compute the IFFT of a given signal (with additional zero-padding).
fftwf_plan m_fftwPlanIFFT;
};
}
#endif // SRC_HEADERS_GX_PITCH_TRACKER_H_
gx_engine::PitchTracker::busy
volatile bool busy
Definition gx_pitch_tracker.h:52
gx_engine::PitchTracker::m_buffersize
int m_buffersize
Definition gx_pitch_tracker.h:69
gx_engine::PitchTracker::m_fftwBufferTime
float * m_fftwBufferTime
Definition gx_pitch_tracker.h:81
gx_engine::PitchTracker::m_pthr
pthread_t m_pthr
Definition gx_pitch_tracker.h:55
gx_engine::PitchTracker::~PitchTracker
~PitchTracker()
gx_engine::PitchTracker::m_freq
float m_freq
Definition gx_pitch_tracker.h:59
gx_engine::PitchTracker::setParameters
bool setParameters(int priority, int policy, int sampleRate, int fftSize)
gx_engine::PitchTracker::m_trig
sem_t m_trig
Definition gx_pitch_tracker.h:54
gx_engine::PitchTracker::init
void init(int priority, int policy, unsigned int samplerate)
gx_engine::PitchTracker::m_input
float * m_input
Definition gx_pitch_tracker.h:77
gx_engine::PitchTracker::m_fftwPlanFFT
fftwf_plan m_fftwPlanFFT
Definition gx_pitch_tracker.h:85
gx_engine::PitchTracker::PitchTracker
PitchTracker()
gx_engine::PitchTracker::add
void add(int count, float *input)
gx_engine::PitchTracker::resamp
Resampler resamp
Definition gx_pitch_tracker.h:56
gx_engine::PitchTracker::m_audioLevel
bool m_audioLevel
Definition gx_pitch_tracker.h:79
gx_engine::PitchTracker::signal_threshold_on
float signal_threshold_on
Definition gx_pitch_tracker.h:62
gx_engine::PitchTracker::new_freq
sigc::signal< void > new_freq
Definition gx_pitch_tracker.h:44
gx_engine::PitchTracker::copy
void copy()
gx_engine::PitchTracker::m_fftwPlanIFFT
fftwf_plan m_fftwPlanIFFT
Definition gx_pitch_tracker.h:87
gx_engine::PitchTracker::stop_thread
void stop_thread()
gx_engine::PitchTracker::set_fast_note_detection
void set_fast_note_detection(bool v)
gx_engine::PitchTracker::run
void run()
gx_engine::PitchTracker::start_thread
void start_thread(int policy, int priority)
gx_engine::PitchTracker::static_run
static void * static_run(void *p)
gx_engine::PitchTracker::get_estimated_freq
float get_estimated_freq()
Definition gx_pitch_tracker.h:39
gx_engine::PitchTracker::m_sampleRate
int m_sampleRate
Definition gx_pitch_tracker.h:57
gx_engine::PitchTracker::m_bufferIndex
int m_bufferIndex
Definition gx_pitch_tracker.h:75
gx_engine::PitchTracker::m_fftwBufferFreq
float * m_fftwBufferFreq
Definition gx_pitch_tracker.h:83
gx_engine::PitchTracker::tick
int tick
Definition gx_pitch_tracker.h:53
gx_engine::PitchTracker::get_estimated_note
float get_estimated_note()
gx_engine::PitchTracker::reset
void reset()
gx_engine::PitchTracker::error
bool error
Definition gx_pitch_tracker.h:51
gx_engine::PitchTracker::m_fftSize
int m_fftSize
Definition gx_pitch_tracker.h:71
gx_engine::PitchTracker::fixed_sampleRate
int fixed_sampleRate
Definition gx_pitch_tracker.h:58
gx_engine::PitchTracker::tracker_period
float tracker_period
Definition gx_pitch_tracker.h:67
gx_engine::PitchTracker::m_buffer
float * m_buffer
Definition gx_pitch_tracker.h:73
gx_engine::PitchTracker::signal_threshold_off
float signal_threshold_off
Definition gx_pitch_tracker.h:65
gx_engine
Definition gx_convolver.h:37