Sources: add comments and details fixes
This commit is contained in:
parent
986f736b68
commit
e75e79bb2d
5 changed files with 42 additions and 13 deletions
|
@ -58,6 +58,8 @@ Tuner::Tuner()
|
|||
note = octave = 0;
|
||||
found = false;
|
||||
count_found = count_not_found = 0;
|
||||
nb_sample_running = 0;
|
||||
note_found = octave_found = -1;
|
||||
|
||||
if (filename_record) file_record.open(filename_record);
|
||||
|
||||
|
@ -98,7 +100,9 @@ Tuner::~Tuner()
|
|||
delete high_filter;
|
||||
delete cross;
|
||||
delete recorder;
|
||||
delete probe;
|
||||
delete scale;
|
||||
delete temperaments;
|
||||
}
|
||||
|
||||
void Tuner::Start()
|
||||
|
@ -208,25 +212,30 @@ void Tuner::AudioAnalyse(const int16_t *ptr, int nb_frame)
|
|||
{
|
||||
nb_sample_running += nb_frame;
|
||||
|
||||
// record in file is needed
|
||||
if (filename_record && file_record.is_open()) file_record.write((char*) ptr, nb_frame * sizeof(int16_t));
|
||||
|
||||
// compute every audio frame
|
||||
while (nb_frame--) ComputeFrame(*ptr++);
|
||||
|
||||
// update frequency
|
||||
if (freq != cross->Freq()) {
|
||||
freq = cross->Freq();
|
||||
freqChanged();
|
||||
|
||||
if (freq) {
|
||||
int n, o;
|
||||
double d;
|
||||
n = scale->FindNote(freq, o, d);
|
||||
SetFound(n, o, d);
|
||||
}
|
||||
else { // no freq
|
||||
SetNotFound();
|
||||
}
|
||||
}
|
||||
|
||||
// find note, octave, deviation
|
||||
if (freq) {
|
||||
int n, o = 0;
|
||||
double d = 0;
|
||||
n = scale->FindNote(freq, o, d);
|
||||
SetFound(n, o, d);
|
||||
}
|
||||
else { // no freq
|
||||
SetNotFound();
|
||||
}
|
||||
|
||||
// prevent screen blanking
|
||||
if (nb_sample_running >= nbSamplePreventRunning && running) {
|
||||
nb_sample_running = 0;
|
||||
blank_prevent(true);
|
||||
|
|
|
@ -27,11 +27,21 @@ template<typename A> class LinearFilter {
|
|||
double *backx, *backy;
|
||||
|
||||
public:
|
||||
/**
|
||||
* filter constructor
|
||||
*
|
||||
* @param order Order of filter (2 = biquads)
|
||||
* @param a Array of a coefficiants
|
||||
* @param b Array of b coefficiants
|
||||
*/
|
||||
LinearFilter(int order, double *a, double *b);
|
||||
~LinearFilter();
|
||||
|
||||
/// Clear audio stream
|
||||
void Clear();
|
||||
/// Compute one audio sample
|
||||
A operator() (A x);
|
||||
/// Compute an audio buffer in place
|
||||
void operator() (A *ptr, int nbFrame);
|
||||
};
|
||||
|
||||
|
|
|
@ -53,10 +53,14 @@ template<typename sample_t> class ZeroCross {
|
|||
|
||||
public:
|
||||
ZeroCross(const Config &config);
|
||||
/// analyse audio buffer
|
||||
double operator() (sample_t *ptr, int nbFrame);
|
||||
/// analyse one audio sample
|
||||
void operator() (sample_t v);
|
||||
|
||||
/// Clear stream analyse
|
||||
void Clear();
|
||||
/// Get current frequency computed
|
||||
double Freq();
|
||||
};
|
||||
|
||||
|
|
|
@ -105,8 +105,11 @@ bool Temperaments::SetTemperament(unsigned int index)
|
|||
qDebug() << __func__ << "index" << index << "out of range";
|
||||
return false;
|
||||
}
|
||||
current = index;
|
||||
return CheckoutTemperament(list[current]);
|
||||
if (CheckoutTemperament(list[index])) {
|
||||
current = index;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Temperaments::SetTemperament(const QString name)
|
||||
|
|
|
@ -42,14 +42,17 @@ class Temperaments {
|
|||
std::vector<temp_t> list;
|
||||
double notes[nb_notes];
|
||||
|
||||
/// Check data files in directory
|
||||
void GetDir(const QString & dirname);
|
||||
/// Check temperaments in file
|
||||
void CheckFile(const QString & filename);
|
||||
/// Load given temperament
|
||||
bool CheckoutTemperament(const temp_t & temperament);
|
||||
|
||||
public:
|
||||
/// constructor with dir name to find data files
|
||||
Temperaments(const QString & dirname);
|
||||
~Temperaments();
|
||||
~Temperaments() {}
|
||||
|
||||
/// set current temperament
|
||||
bool SetTemperament(const QString name);
|
||||
|
|
Loading…
Reference in a new issue