// Much from "Copyright (c) 2015-2016, XMOS Ltd, All rights reserved" // // ====================================================== // See "mic_array_conf.h" in lib_mic_array user guide PDF // ====================================================== // Teig: Taken from AN00220 #ifndef MIC_ARRAY_CONF_H_ #define MIC_ARRAY_CONF_H_ #ifndef APPLICATION_NOTE #error -DAPPLICATION_NOTE not defined in makefile #elif (WARNINGS==1) #if (APPLICATION_NOTE == 219) #warning AN00219 config inspired // AN00219_headset_output.xc #elif (APPLICATION_NOTE == 220) #warning AN00220 config inspired // AN00220_app_phase_aligned_example.xc #else #error Wrong value #endif #endif // ============================= // FOR lib_mic_array IN: // decimate_to_pcm_4ch.S asm // mic_array_frame.h // pdm_rx.S asm // #if (APPLICATION_NOTE == 219) // AN00219 config inspired #define MIC_ARRAY_MAX_FRAME_SIZE_LOG2 0 // Defines MIC_ARRAY_NUM_SAMPLES_PER_MIC in audio.data // #define MIC_ARRAY_NUM_MICS_LOG2 3 // 2exp3 = 8 = MIC_ARRAY_NUM_MICS #define MIC_ARRAY_NUM_MICS 8 // Must have "8 mics" (=7) since directive #elif (APPLICATION_NOTE == 220) // AN00220 config inspired // #define MIC_ARRAY_MAX_FRAME_SIZE_LOG2 3 // Defines MIC_ARRAY_NUM_SAMPLES_PER_MIC in audio.data (AN00220) #define MIC_ARRAY_MAX_FRAME_SIZE_LOG2 0 // Defines MIC_ARRAY_NUM_SAMPLES_PER_MIC in audio.data (AN00219) // #define MIC_ARRAY_NUM_MICS_LOG2 3 // 2exp3 = 8 = MIC_ARRAY_NUM_MICS #define MIC_ARRAY_NUM_MICS 8 // #elif (APPLICATION_NOTE == NONE) #define MIC_ARRAY_MAX_FRAME_SIZE_LOG2 0 // Defines MIC_ARRAY_NUM_SAMPLES_PER_MIC in audio.data // #define MIC_ARRAY_NUM_MICS_LOG2 3 // 2exp3 = 8 = MIC_ARRAY_NUM_MICS #define MIC_ARRAY_NUM_MICS 8 // Must have "8 mics" (=7) since directive #else #error APPLICATION_NOTE not defined in Makefile #endif // # MIC_ARRAY_MAX_FRAME_SIZE_LOG2 // 2 exp(0) = 1 MIC_ARRAY_NUM_SAMPLES_PER_MIC sample per microphone in audio.data in example (AN00219) // 2 exp(1) = 2 MIC_ARRAY_NUM_SAMPLES_PER_MIC samples per microphone in audio.data in example // 2 exp(2) = 4 MIC_ARRAY_NUM_SAMPLES_PER_MIC samples per microphone in audio.data in example // 2 exp(3) = 8 MIC_ARRAY_NUM_SAMPLES_PER_MIC samples per microphone in audio.data in example (AN00220) // ... // 2 exp(13) = 8192 MIC_ARRAY_NUM_SAMPLES_PER_MIC samples per microphone in audio.data in example // The four channel decimators (mic_array_pdm_rx()) output frames of either // time domain audio or FFT ready audio prepared for an FFT. The define // MIC_ARRAY_MAX_FRAME_SIZE_LOG2 (found in mic_array_conf.h) should be used // to allocate the arrays to store the frames. This means that all frames // structures will allocate enough memory to allow for a frame size of // two to the power of MIC_ARRAY_MAX_FRAME_SIZE_LOG2 regardless of the size // used in the decimator_config_common. // It is recommended that the frame_size_log2 field of decimator_config_common // is always set to MIC_ARRAY_MAX_FRAME_SIZE_LOG2. Equally, the define MIC_ARRAY_NUM_MICS // is used for allocating the memory for the frame structure. This must be set to a multiple of 4. // The mic_array board has 7 Infineon IM69D130 MEMS microphones // "Count of microphones(channels) must be set to a multiple of 4", ie 4 or 8 // If the decimation factor is changed the the coefs_array of mic_array_decimator_config_t // must also be changed. Done below /* ======================================================================== * THE REST OF THIS FILE IS PICKED UP BY APPLICATION IF lib_mic_array USED * Author: teig */ // ================ // HEADSET_OUT_PART // ================ #define TEST_SINE_480HZ 0 // 0 standard input from mics // 1 from sine table, 480Hz exactly only if SAMPLING_FREQUENCY_HZ is 48000 // Observe SINE_480HZ_DIV_FACTOR #if (APPLICATION_NOTE == 219) #define USE_BEAMFORMING 1 // Always associate with MIC_ARRAY_NUM_MICS==8. Meaningless with TEST_SINE_480HZ #define DECIMATION_FACTOR 2 // 48 kHz #elif (APPLICATION_NOTE == 220) #define USE_BEAMFORMING 0 // Always associate with MIC_ARRAY_NUM_MICS==4 #define DECIMATION_FACTOR 6 // 16 kHz #elif (APPLICATION_NOTE == NONE) #define USE_BEAMFORMING 0 // Always associate with MIC_ARRAY_NUM_MICS==8. Meaningless with TEST_SINE_480HZ #define DECIMATION_FACTOR 12 // 8 kHz #endif #define MIC_ARRAY_NUM_SAMPLES_PER_MIC (1 << MIC_ARRAY_MAX_FRAME_SIZE_LOG2) // 1,2,4,8.. #define DO_WAITS_IN_MIC_ARRAY_GET_NEXT_TIME_DOMAIN_FRAME 0 // 0: do some wait in task first // 1: wait in mic_array_get_next_time_domain_frame // From the PDF doc XM010267 // 48 kHz, 24 kHz, 16 kHz, 12 kHz and 8 kHz output sample rate by default (3.072MHz PDM clock) // Configurable frame size from 1 sample to 8192 samples plus 50% overlapping frames option, // chapter 11 "Four Channel Decimator" // // 96 kHz divided by 2, 4, 6, 8 or 12. See "fir_coefs.h" and "fir_coefs.xc" in lib_mic_array #if (DECIMATION_FACTOR == 2) // THIS IS THE ONLY ONE I HAVE THE CORRECT CODE FOR (as of 17Dec2021) #define COEF_ARRAYS g_third_stage_div_2_fir // [126] #define SAMPLING_FREQUENCY_HZ 48000 // 48 kHz =DAC_OUTPUT_SAMPLE_FREQUENCY_HZ Observe TEST_SINE_480HZ. #define USE_EVERY_N_SAMPLE 6 // SAMPLES_BUF_DIM == 264, even 256 is too much, 128 works #define FIR_GAIN_COMPENSATION FIR_COMPENSATOR_DIV_2 #elif (DECIMATION_FACTOR == 4) #define COEF_ARRAYS g_third_stage_div_4_fir // [252] #define SAMPLING_FREQUENCY_HZ 24000 // 24 kHz =DAC_OUTPUT_SAMPLE_FREQUENCY_HZ #define USE_EVERY_N_SAMPLE 1 #define FIR_GAIN_COMPENSATION FIR_COMPENSATOR_DIV_4 #elif (DECIMATION_FACTOR == 6) #define COEF_ARRAYS g_third_stage_div_6_fir // [378] #define SAMPLING_FREQUENCY_HZ 16000 // 16 kHz =DAC_OUTPUT_SAMPLE_FREQUENCY_HZ #define USE_EVERY_N_SAMPLE 1 #define FIR_GAIN_COMPENSATION FIR_COMPENSATOR_DIV_6 #elif (DECIMATION_FACTOR == 8) #define COEF_ARRAYS g_third_stage_div_8_fir // [504] #define SAMPLING_FREQUENCY_HZ 12000 // 12 kHz =DAC_OUTPUT_SAMPLE_FREQUENCY_HZ #define USE_EVERY_N_SAMPLE 1 #define FIR_GAIN_COMPENSATION FIR_COMPENSATOR_DIV_8 #elif (DECIMATION_FACTOR == 12) #define COEF_ARRAYS g_third_stage_div_12_fir // [756] #define SAMPLING_FREQUENCY_HZ 8000 // 8 kHz =DAC_OUTPUT_SAMPLE_FREQUENCY_HZ #define USE_EVERY_N_SAMPLE 1 #define FIR_GAIN_COMPENSATION FIR_COMPENSATOR_DIV_12 #else #error #endif // https://www.teigfam.net/oyvind/home/technology/219-my-beep-brrr-notes/#Ref16 // NUM_SAMPLES SAMPLING_FREQ_HZ FRAME_LENGTH_MS NUM_FFT_FREQ_BINS HZ_PER_BIN // 8192 8000 1024 4096 1.95 // 8192 12000 682.666.. 4096 2.92 // 4096 8000 512 2048 3.91 // 4096 12000 341.333.. 2048 5.86 // 2048 8000 256 1024 7.81 // 2048 12000 170.666.. 1024 11.72 #else #error NESTED .h FILE #endif