|
-
-
- #ifndef AudioTuner_h_
- #define AudioTuner_h_
-
- #include "AudioStream.h"
-
- #define SAMPLE_RATE_DIVIDE_BY_1 1
- #define SAMPLE_RATE_DIVIDE_BY_2 2
- #define SAMPLE_RATE_DIVIDE_BY_4 4
- #define SAMPLE_RATE_DIVIDE_BY_8 8
- #define SAMPLE_RATE_DIVIDE_BY_16 16
- #define SAMPLE_RATE_DIVIDE_BY_32 32
-
-
-
- #define NUM_SAMPLES 2048
-
-
-
-
- #define SAMPLE_SKIP SAMPLE_RATE_DIVIDE_BY_2
-
-
- class AudioTuner : public AudioStream
- {
- public:
- AudioTuner( void ) : AudioStream( 1, inputQueueArray ),
- enabled( false ), new_output(false),
- next_buffer(1), process_buffer(false),
- running_sum(0), block_count(0),
- yin_idx(1)
- {
-
- set_params( 0.05f );
- }
-
-
-
- void set_params( float thresh );
-
-
-
- bool available( void );
-
-
- float read( void );
-
-
-
- float probability( void );
-
-
- virtual void update( void );
- private:
-
-
- uint16_t estimate( int64_t *yin, int64_t *rs, uint16_t head, uint16_t tau );
-
- int16_t buffer[NUM_SAMPLES*2] __attribute__ ( ( aligned ( 4 ) ) );
- float periodicity, threshold, data;
- int64_t rs_buffer[5], yin_buffer[5];
- uint64_t running_sum;
- uint16_t block_count, tau_global;
- uint8_t next_buffer, yin_idx;
- bool enabled, process_buffer;
- volatile bool new_output;
- audio_block_t *inputQueueArray[1];
- };
- #endif
|