|
-
-
- #ifndef AudioTuner_h_
- #define AudioTuner_h_
-
- #include "AudioStream.h"
-
- #define SAMPLE_RATE_44100 1
- #define SAMPLE_RATE_22050 2
- #define SAMPLE_RATE_11025 4
-
-
-
-
- #define NUM_SAMPLES 2048
-
-
- #define SAMPLE_RATE SAMPLE_RATE_22050
-
-
- class AudioTuner : public AudioStream
- {
- public:
-
-
- AudioTuner( void ) : AudioStream( 1, inputQueueArray ), enabled( false ), new_output(false) {
- digitalWriteFast(2, LOW);
- }
-
-
- void initialize( float threshold, uint8_t cpu_max);
-
-
-
- void threshold( float p );
-
-
-
- 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, yin_threshold, data;
- int64_t rs_buffer[5], yin_buffer[5];
- uint64_t running_sum;
- uint16_t tau_global, count_global, tau_cycles, cpu_usage_max;
- uint8_t next_buffer, yin_idx;
- bool enabled, process_buffer;
- volatile bool new_output;
- audio_block_t *inputQueueArray[1];
- };
- #endif
|