Last active
January 14, 2019 10:03
-
-
Save SibeeshVenu/988b564861b20768e0b124337663fa25 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Constants and variables- Start// | |
enum AppState | |
{ | |
APPSTATE_Init, | |
APPSTATE_Error, | |
APPSTATE_Recording | |
}; | |
static AppState appstate; | |
// These numbers need to match the compiled ELL models. | |
const int SAMPLE_RATE = 16000; | |
const int SAMPLE_BIT_DEPTH = 16; | |
const int FEATURIZER_INPUT_SIZE = 512; | |
const int FRAME_RATE = 33; // assumes a "shift" of 512 and 512/16000 = 0.032ms per frame. | |
const int FEATURIZER_OUTPUT_SIZE = 80; | |
const int CLASSIFIER_OUTPUT_SIZE = 31; | |
const float THRESHOLD = 0.9; | |
static int scaled_input_buffer_pos = 0; | |
static float scaled_input_buffer[FEATURIZER_INPUT_SIZE]; // raw audio converted to float | |
const int MAX_FEATURE_BUFFERS = 10; // set to buffer up to 1 second of audio in circular buffer | |
static float featurizer_input_buffers[MAX_FEATURE_BUFFERS][FEATURIZER_INPUT_SIZE]; // input to featurizer | |
static int featurizer_input_buffer_read = -1; // next read pos | |
static int featurizer_input_buffer_write = 0; // next write pos | |
static int dropped_frames = 0; | |
static float featurizer_output_buffer[FEATURIZER_OUTPUT_SIZE]; // 40 channels | |
static float classifier_output_buffer[CLASSIFIER_OUTPUT_SIZE]; // 31 classes | |
static int raw_audio_count = 0; | |
static char raw_audio_buffer[AUDIO_CHUNK_SIZE]; | |
static int prediction_count = 0; | |
static int last_prediction = 0; | |
static int last_confidence = 0; // as a percentage between 0 and 100. | |
static uint8_t maxGain = 0; | |
static uint8_t minGain = 0; | |
int decibels = 0; | |
float min_level = 100; | |
float max_level = 0; | |
RGB_LED rgbLed; | |
static bool hasWifi = false; | |
static bool messageSending = true; | |
static uint64_t send_interval_ms; | |
int messageCount = 0; // holds ID | |
bool messageReceived = false; | |
char device_id[6]; | |
AudioClass &Audio = AudioClass::getInstance(); | |
//Constants and variables- End// | |
//************************************// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment