├── .gitattributes ├── .gitignore ├── Arduino ├── ActiveNoiseCancelation │ ├── ANC_feedback │ │ └── ANC_feedback.ino │ └── ANC_feedback_LP_Comp │ │ └── ANC_feedback_LP_Comp.ino ├── Audio Processing Benchmarking │ ├── 2017-07-09 FFT Speed Results.xlsx │ ├── 2017-10-19 FFT Speed Results.xlsx │ ├── ARM_FFT_Valid_N │ │ └── ARM_FFT_Valid_N.ino │ ├── FFT Speed Results.xlsx │ ├── FIR Speed Results.xlsx │ ├── FIR_FFT_Benchmarking │ │ ├── FIR_FFT_Benchmarking.ino │ │ ├── _kiss_fft_guts.h │ │ ├── do_arm_fft.h │ │ ├── do_arm_fir.h │ │ ├── do_kiss_fft.h │ │ ├── do_naive_fir.h │ │ ├── fft_fir_const.h │ │ ├── kiss_fft.c │ │ └── kiss_fft.h │ ├── FLOPS_test │ │ └── FLOPS_test.ino │ ├── Notes - Arduino Maple.txt │ └── Old │ │ ├── FFT_Benchmarking_ARM │ │ └── FFT_Benchmarking_ARM.ino │ │ ├── FFT_Benchmarking_C_physionet │ │ ├── FFT_Benchmarking_C_physionet.ino │ │ └── types.h │ │ ├── FFT_Benchmarking_IntFFT_AnyN │ │ ├── FFT_Benchmarking_IntFFT_AnyN.ino │ │ ├── integer_fft.ino │ │ └── mytypes.h │ │ ├── FFT_Benchmarking_IntFFT_N1024 │ │ ├── FFT_Benchmarking_IntFFT_N1024.ino │ │ ├── integer_fft.Readme.txt │ │ ├── integer_fft.ino │ │ └── mytypes.h │ │ ├── FFT_Benchmarking_KissFFT │ │ ├── FFT_Benchmarking_KissFFT.ino │ │ ├── _kiss_fft_guts.h │ │ ├── kiss_fft.c │ │ ├── kiss_fft.h │ │ ├── kiss_fft.h~ │ │ └── mytypes.h │ │ ├── FIR_Benchmarking │ │ ├── FIR_Benchmarking.ino │ │ └── types.h │ │ ├── FIR_Benchmarking_Maple │ │ ├── FIR_Benchmarking_Maple.pde │ │ └── types.h │ │ ├── FIR_Benchmarking_Python │ │ └── FIR_benchmarking.py │ │ ├── FIR_Benchmarking_multiN │ │ ├── FIR_Benchmarking_multiN.ino │ │ └── types.h │ │ └── Int_vs_Long │ │ └── Int_vs_Long.ino ├── Sample Rate Exploration │ ├── BasicCompressor_Float_newFS │ │ └── BasicCompressor_Float.ino │ ├── BasicGain_Float_newFS │ │ ├── AudioStream_Mod.h │ │ ├── BasicGain_Float_newFS.ino │ │ └── SampleRateFuncs.h │ ├── ChangeBitDepth │ │ └── ChangeBitDepth.ino │ └── TestCpuCycles │ │ ├── AudioEffectTestCycles.h │ │ └── TestCpuCycles.ino ├── Teensy Frequency Domain │ ├── FrequencyDomainDemo │ │ ├── AudioEffectFreqDomain.h │ │ └── FrequencyDomainDemo.ino │ ├── FrequencyDomainDemo1 │ │ ├── AudioEffectFreqDomain_F32.h │ │ ├── FrequencyDomainDemo1.ino │ │ └── MyFFT_F32.h │ ├── MoreOverlapDemo_FD │ │ ├── AudioEffectLowpassFD_F32.h │ │ ├── FreqDomainProcessing - CPU.png │ │ ├── MoreOverlapDemo_FD.ino │ │ └── Tympan Frequency Domain CPU.xlsx │ └── TestFFT │ │ ├── TestFFT.ino │ │ ├── exploreData.m │ │ ├── exploreData_both.m │ │ ├── output_f10_armFFT_DC0.5.txt │ │ ├── output_f10_bothFFT_DC0.5.txt │ │ ├── output_f1_armFFT.txt │ │ ├── output_f2_armFFT.txt │ │ ├── output_halff10_bothFFT_DC0.5.txt │ │ └── rfft.c ├── Teensy Time Domain Audio │ ├── BasicGain_Float_wMeasurements │ │ └── BasicGain_Float_wMeasurements.ino │ ├── ChangeBlockLength │ │ ├── AudioStream.h │ │ └── ChangeBlockLength.ino │ ├── GainAndEQ │ │ └── GainAndEQ.ino │ ├── GainOnly │ │ ├── AudioControlSGTL5000_Extended.h │ │ └── GainOnly.ino │ ├── MultiBandCompressor_Float │ │ ├── AudioStream_Mod.h │ │ ├── MultiBandCompressor_Float.ino │ │ ├── effect_WDRcompressor_f32.h │ │ ├── filtCoeff_64NFIR_8chan_fs24000Hz.h │ │ └── filter_fir_f32.h │ ├── NoiseTesting │ │ └── NoiseTesting.ino │ ├── PassThrough_LineIn │ │ └── PassThrough_LineIn.ino │ ├── Recorder_SD_vs_SdFat │ │ └── Recorder_SD_vs_SdFat.ino │ ├── TestHeadphone_ToneAndSweep │ │ └── TestHeadphone_ToneAndSweep.ino │ ├── Tympan_BasicTest │ │ └── Tympan_BasicTest.ino │ ├── Tympan_ExpCompLim │ │ ├── AudioEffectExpCompLim.h │ │ ├── SerialManager.h │ │ └── Tympan_ExpCompLim.ino │ ├── Tympan_Expander │ │ ├── AudioEffectExpander.h │ │ └── Tympan_Expander.ino │ └── Tympan_Expander_MultiBand │ │ ├── AudioEffectExpander.h │ │ ├── SerialManager.h │ │ └── Tympan_Expander_MultiBand.ino ├── Teensy Tympan RevD │ └── TrebleBoost_RevD │ │ └── TrebleBoost_RevD.ino └── Teensy Tympan │ ├── Estimating CPU Time (WDRC).xlsx │ ├── Pipe_Listener │ └── Pipe_Listener.ino │ ├── SdFat_Tester │ └── SdFat_Tester.ino │ ├── StereoAudioToSD │ ├── SDAudioWriter.h │ ├── StereoAudioToSD.ino │ ├── example_serial_log.txt │ └── plotSDTiming.m │ ├── StereoAudioToSD_SdFatLibrary │ ├── SDAudioWriter_SdFat.h │ └── StereoAudioToSD_SdFatLibrary.ino │ ├── ToneGeneration_Serial_BT │ ├── SerialManager.h │ └── ToneGeneration_Serial_BT.ino │ ├── TrebleBoost_toSD_test │ ├── MyWriteAudioToSD.h │ └── TrebleBoost_toSD_test.ino │ ├── TympanI2SMics │ ├── AudioEffectGain.h │ ├── Tympan RevD3 w I2S Mics.pptx │ ├── TympanI2SMics.ino │ │ ├── AudioEffectGain.h │ │ └── TympanI2SMics.ino.ino │ ├── Typman RevC with 2nd AIC.png │ ├── Typman RevC with 2nd AIC.pptx │ └── ~$Tympan RevD3 w I2S Mics.pptx │ ├── TympanI2SMicsQuad │ ├── AudioEffectGain.h │ └── TympanI2SMicsQuad.ino │ ├── TympanPDMMics │ ├── AudioEffectGain.h │ ├── Tympan RevD3 w I2S and PDM Mics.pptx │ └── TympanPDMMics.ino │ ├── TympanQuad │ ├── Tympan RevD3 w I2S Mics.pptx │ ├── TympanQuad.ino │ ├── Typman RevC with 2nd AIC.png │ └── Typman RevC with 2nd AIC.pptx │ ├── Tympan_Ultrasound │ └── Tympan_Ultrasound.ino │ └── Tympan_Ultrasound_Comp │ └── Tympan_Ultrasound_Comp.ino ├── Docs ├── Getting Started │ ├── Starting From Scratch.md │ └── Starting with Audio.md └── Programming Algorithms │ ├── Computing Filter Coefficients.md │ └── Using DSP Exentions.md ├── Hardware ├── Breadboard #1 │ └── 2016-10 Teensy Breadboard Wiring.pptx ├── Breadboard #2 │ └── 2016-12-02 BB#2 for BTNRH.pptx ├── Design Files │ └── Tympan_RevA │ │ ├── 7146-0013_Assembly_Top_Rev-A.pdf │ │ ├── ERRORS.txt │ │ ├── Tympan_BOM_Rev-A.pdf │ │ └── Tympan_Sch_Rev-A.pdf ├── Phantom Power 48V │ ├── 1.2A High Voltage Boost Converter in 2x2mm2 QFN Package (Rev. D).url │ ├── 2017-12-18 Voltage Doubling.pptx │ ├── 48V StepUp PCB │ │ └── LT8330 StepUp PCB.fzz │ ├── Solutions - LT8330 3V to 6V Input, 48V Boost Converter.url │ ├── Solutions - LTC3872 High Efficiency 5V Input, 48V Output Boost Converter.url │ ├── Voltage Multiplier and Voltage Doubler Circuit.url │ └── phantsch.gif (1118×920).url ├── Tympan A Board │ ├── 2017-02-10 Tympan A.pptx │ ├── Creare Audio Board - Ideas.pptx │ ├── Creare Mockup-small.JPG │ ├── Creare Notional Layout 2016-12-06.png │ ├── Notional Layout of Creare Audio Board.pptx │ ├── Old │ │ ├── Creare Notional Layout 2016-12-01.png │ │ └── Creare Notional Layout 2016-12-05.png │ ├── Tympan Packaging.pptx │ ├── Tympan Silk.png │ └── Typan Silk.pdf ├── Tympan E (Notional) │ ├── 2018-03-01 Tympan Mini.pptx │ └── Old │ │ ├── 2017-12-13 Tympan Mini.pptx │ │ └── 2018-01-17 Tympan Mini.pptx └── Tympan Mic Bias Config.pptx └── Kinetis Design Studio ├── Audio Processing Benchmarking ├── 2016-08 Notes on Kinetis Design Studio.txt └── FIR_FFT_Benchmarking │ ├── CMSIS │ └── Include │ │ ├── arm_common_tables.h │ │ ├── arm_const_structs.h │ │ ├── arm_math.h │ │ ├── cmsis_armcc.h │ │ ├── cmsis_armcc_V6.h │ │ ├── cmsis_gcc.h │ │ ├── core_cm4.h │ │ ├── core_cmFunc.h │ │ ├── core_cmInstr.h │ │ └── core_cmSimd.h │ ├── board.c │ ├── board.h │ ├── clock_config.c │ ├── clock_config.h │ ├── devices │ └── MK66F18 │ │ ├── MK66F18.h │ │ ├── MK66F18_features.h │ │ ├── drivers │ │ ├── fsl_adc16.c │ │ ├── fsl_adc16.h │ │ ├── fsl_clock.c │ │ ├── fsl_clock.h │ │ ├── fsl_cmp.c │ │ ├── fsl_cmp.h │ │ ├── fsl_cmt.c │ │ ├── fsl_cmt.h │ │ ├── fsl_common.c │ │ ├── fsl_common.h │ │ ├── fsl_crc.c │ │ ├── fsl_crc.h │ │ ├── fsl_dac.c │ │ ├── fsl_dac.h │ │ ├── fsl_dmamux.c │ │ ├── fsl_dmamux.h │ │ ├── fsl_dspi.c │ │ ├── fsl_dspi.h │ │ ├── fsl_dspi_edma.c │ │ ├── fsl_dspi_edma.h │ │ ├── fsl_edma.c │ │ ├── fsl_edma.h │ │ ├── fsl_enet.c │ │ ├── fsl_enet.h │ │ ├── fsl_ewm.c │ │ ├── fsl_ewm.h │ │ ├── fsl_flash.c │ │ ├── fsl_flash.h │ │ ├── fsl_flexbus.c │ │ ├── fsl_flexbus.h │ │ ├── fsl_flexcan.c │ │ ├── fsl_flexcan.h │ │ ├── fsl_ftm.c │ │ ├── fsl_ftm.h │ │ ├── fsl_gpio.c │ │ ├── fsl_gpio.h │ │ ├── fsl_i2c.c │ │ ├── fsl_i2c.h │ │ ├── fsl_i2c_edma.c │ │ ├── fsl_i2c_edma.h │ │ ├── fsl_llwu.c │ │ ├── fsl_llwu.h │ │ ├── fsl_lmem_cache.c │ │ ├── fsl_lmem_cache.h │ │ ├── fsl_lptmr.c │ │ ├── fsl_lptmr.h │ │ ├── fsl_lpuart.c │ │ ├── fsl_lpuart.h │ │ ├── fsl_lpuart_edma.c │ │ ├── fsl_lpuart_edma.h │ │ ├── fsl_mpu.c │ │ ├── fsl_mpu.h │ │ ├── fsl_pdb.c │ │ ├── fsl_pdb.h │ │ ├── fsl_pit.c │ │ ├── fsl_pit.h │ │ ├── fsl_pmc.c │ │ ├── fsl_pmc.h │ │ ├── fsl_port.h │ │ ├── fsl_rcm.c │ │ ├── fsl_rcm.h │ │ ├── fsl_rnga.c │ │ ├── fsl_rnga.h │ │ ├── fsl_rtc.c │ │ ├── fsl_rtc.h │ │ ├── fsl_sai.c │ │ ├── fsl_sai.h │ │ ├── fsl_sai_edma.c │ │ ├── fsl_sai_edma.h │ │ ├── fsl_sdhc.c │ │ ├── fsl_sdhc.h │ │ ├── fsl_sdramc.c │ │ ├── fsl_sdramc.h │ │ ├── fsl_sim.c │ │ ├── fsl_sim.h │ │ ├── fsl_smc.c │ │ ├── fsl_smc.h │ │ ├── fsl_tpm.c │ │ ├── fsl_tpm.h │ │ ├── fsl_tsi_v4.c │ │ ├── fsl_tsi_v4.h │ │ ├── fsl_uart.c │ │ ├── fsl_uart.h │ │ ├── fsl_uart_edma.c │ │ ├── fsl_uart_edma.h │ │ ├── fsl_vref.c │ │ ├── fsl_vref.h │ │ ├── fsl_wdog.c │ │ └── fsl_wdog.h │ │ ├── fsl_device_registers.h │ │ ├── gcc │ │ └── startup_MK66F18.S │ │ ├── system_MK66F18.c │ │ ├── system_MK66F18.h │ │ └── utilities │ │ ├── fsl_debug_console.c │ │ ├── fsl_debug_console.h │ │ ├── fsl_notifier.c │ │ ├── fsl_notifier.h │ │ └── fsl_sbrk.c │ ├── kds │ ├── .cproject │ ├── .gitignore │ ├── .project │ ├── .settings │ │ ├── com.processorexpert.core.ide.newprojectwizard.prefs │ │ └── language.settings.xml │ └── settings │ │ ├── FIR_FFT_Benchmarking debug jlink.launch │ │ ├── FIR_FFT_Benchmarking debug pne.launch │ │ ├── FIR_FFT_Benchmarking release jlink.launch │ │ ├── FIR_FFT_Benchmarking release pne.launch │ │ └── MK66FN2M0xxx18_flash.ld │ ├── main.c │ ├── pin_mux.c │ └── pin_mux.h └── Utilities └── arm_timing.h /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #ignore the analysis directory for now 2 | Analysis/* 3 | 4 | # jEdit and Matlab temporary files 5 | *.*~ 6 | *.asv 7 | 8 | #kinetis temperorary files 9 | *.o 10 | *.d 11 | 12 | # Windows image file caches 13 | Thumbs.db 14 | ehthumbs.db 15 | 16 | # Folder config file 17 | Desktop.ini 18 | 19 | # Recycle Bin used on file shares 20 | $RECYCLE.BIN/ 21 | 22 | # Windows Installer files 23 | *.cab 24 | *.msi 25 | *.msm 26 | *.msp 27 | 28 | # Windows shortcuts 29 | *.lnk 30 | 31 | # ========================= 32 | # Operating System Files 33 | # ========================= 34 | 35 | # OSX 36 | # ========================= 37 | 38 | .DS_Store 39 | .AppleDouble 40 | .LSOverride 41 | 42 | # Thumbnails 43 | ._* 44 | 45 | # Files that might appear on external disk 46 | .Spotlight-V100 47 | .Trashes 48 | 49 | # Directories potentially created on remote AFP share 50 | .AppleDB 51 | .AppleDesktop 52 | Network Trash Folder 53 | Temporary Items 54 | .apdisk 55 | -------------------------------------------------------------------------------- /Arduino/Audio Processing Benchmarking/2017-07-09 FFT Speed Results.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Arduino/Audio Processing Benchmarking/2017-07-09 FFT Speed Results.xlsx -------------------------------------------------------------------------------- /Arduino/Audio Processing Benchmarking/2017-10-19 FFT Speed Results.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Arduino/Audio Processing Benchmarking/2017-10-19 FFT Speed Results.xlsx -------------------------------------------------------------------------------- /Arduino/Audio Processing Benchmarking/ARM_FFT_Valid_N/ARM_FFT_Valid_N.ino: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include 4 | 5 | #define ARM_MATH_CM4 6 | #include "arm_math.h" 7 | 8 | void setup() { 9 | // put your setup code here, to run once: 10 | Serial.begin(115200); 11 | delay(1000); 12 | 13 | } 14 | 15 | void tryInitFFT(const int N) { 16 | uint8_t ifftFlag = 0; // 0 is FFT, 1 is IFFT 17 | uint8_t doBitReverse = 1; 18 | int status; 19 | 20 | //Serial.print("tryInitFFT: N_FFT = "); Serial.print(N); 21 | 22 | arm_cfft_radix4_instance_f32 foo1; 23 | status = arm_cfft_radix4_init_f32(&foo1, N,ifftFlag, doBitReverse); 24 | Serial.print(N);Serial.print(": arm_cfft_radix4_init_f32, FFT allocation : "); Serial.print(status); Serial.print(", where success is "); Serial.println(ARM_MATH_SUCCESS); 25 | 26 | arm_cfft_radix2_instance_f32 foo2; 27 | status = arm_cfft_radix2_init_f32(&foo2, N,ifftFlag, doBitReverse); 28 | Serial.print(N);Serial.print(": arm_cfft_radix2_init_f32, FFT allocation : "); Serial.print(status); Serial.print(", where success is "); Serial.println(ARM_MATH_SUCCESS); 29 | 30 | arm_cfft_radix4_instance_f32 foo3; 31 | arm_rfft_instance_f32 foo4; 32 | status = arm_rfft_init_f32(&foo4, &foo3, N, ifftFlag, doBitReverse); 33 | Serial.print(N);Serial.print(": arm_rfft_init_f32, FFT allocation : "); Serial.print(status); Serial.print(", where success is "); Serial.println(ARM_MATH_SUCCESS); 34 | } 35 | 36 | int count=0; 37 | void loop() { 38 | // put your main code here, to run repeatedly: 39 | 40 | if (count++ < 1) { 41 | const int N_N = 8; 42 | int32_t all_N[] = {16, 32, 64, 128, 256, 512, 1024, 2048}; 43 | for (int i=0; i < N_N; i++) { 44 | tryInitFFT(all_N[i]); 45 | } 46 | delay(2000); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /Arduino/Audio Processing Benchmarking/FFT Speed Results.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Arduino/Audio Processing Benchmarking/FFT Speed Results.xlsx -------------------------------------------------------------------------------- /Arduino/Audio Processing Benchmarking/FIR Speed Results.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Arduino/Audio Processing Benchmarking/FIR Speed Results.xlsx -------------------------------------------------------------------------------- /Arduino/Audio Processing Benchmarking/FIR_FFT_Benchmarking/FIR_FFT_Benchmarking.ino: -------------------------------------------------------------------------------- 1 | /* 2 | This runs FIR and FFT computation routines. My purpose is to see how fast different 3 | platforms are when doing this kind of math. 4 | 5 | Created: OpenAudio (Chip Audette) 6 | : August 2016 7 | 8 | */ 9 | 10 | // Choose the operation that you want to do 11 | #define DO_NAIVE_FIR 0 12 | #define DO_ARM_FIR 1 13 | #define DO_KISS_FFT 2 14 | #define DO_ARM_FFT 3 15 | #define OPERATION_TO_DO DO_ARM_FFT //change this to select which function to run 16 | 17 | 18 | //In this header file is the definition for things like DataType (int16, int32, float) and MAX_N 19 | #include "FFT_FIR_Const.h" 20 | 21 | #if OPERATION_TO_DO == DO_NAIVE_FIR 22 | #include "do_naive_fir.h" 23 | char *alg_name = "NAIVE FIR"; 24 | #define N_TRIALS 500 // how many times to repeat the operation 25 | #endif 26 | 27 | #if OPERATION_TO_DO == DO_ARM_FIR 28 | #include "do_arm_fir.h" 29 | char *alg_name = "ARM FIR"; 30 | #define N_TRIALS 500 // how many times to repeat the operation 31 | #endif 32 | 33 | #if (OPERATION_TO_DO == DO_KISS_FFT) 34 | #include "do_kiss_fft.h" 35 | char *alg_name = "KISS FFT"; 36 | #define N_TRIALS 5 // how many times to repeat the operation 37 | #endif 38 | 39 | #if (OPERATION_TO_DO == DO_ARM_FFT) 40 | #include "do_arm_fft.h" 41 | char *alg_name = "ARM FFT"; 42 | #define N_TRIALS 50 // how many times to repeat the operation 43 | #endif 44 | 45 | // parameters for stepping through different FFT lengths 46 | #if (MAX_N <= 128) 47 | #define LEN_ALL_N 4 48 | int ALL_N[LEN_ALL_N] = {MAX_N, MAX_N/2, MAX_N/4, MAX_N/8}; 49 | #else 50 | #define LEN_ALL_N 8 51 | int ALL_N[LEN_ALL_N] = {MAX_N, MAX_N/2, MAX_N/4, MAX_N/8, MAX_N/16, MAX_N/32, MAX_N/64, MAX_N/128}; 52 | #endif 53 | 54 | #ifdef IS_ARDUINO_UNO 55 | int freeRam(void) { 56 | extern int __heap_start, *__brkval; 57 | int v; 58 | return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); 59 | } 60 | #else 61 | int freeRam(void) { return -1; } 62 | #endif 63 | 64 | void setup() { 65 | Serial.begin(115200); 66 | delay(1000); 67 | 68 | Serial.println(F("FIR/FFT Benchmarking..."));delay(500); 69 | //PRINTF(" : System Clock = %i Hz\r\n",CLOCK_GetFreq(kCLOCK_CoreSysClk)); 70 | //PRINTF(" : LPTMR Source Clock = %i Hz\r\n", LPTMR_CLOCK_HZ); 71 | //PRINTF(" : micros per tick = %4.1f\r\n", millis_per_tic*1000); 72 | } 73 | 74 | int I_loop=0; 75 | int N; 76 | uint32_t dt_micros; 77 | void loop() { 78 | 79 | if (I_loop < 3) { 80 | I_loop++; 81 | 82 | //step trough each N 83 | int FLOPS_per_trial[LEN_ALL_N]; 84 | for (int I_N = 0; I_N < LEN_ALL_N; I_N++) { 85 | N = ALL_N[I_N]; 86 | if (N >= 4) { 87 | 88 | //do the processing 89 | #if (OPERATION_TO_DO == DO_NAIVE_FIR) 90 | dt_micros = naive_fir_func(N,N_TRIALS); //applies FIR to one input sample. Does it N_TRIALS times. 91 | FLOPS_per_trial[I_N] = 2*N; //multiply plus add 92 | #elif (OPERATION_TO_DO == DO_ARM_FIR) 93 | dt_micros = arm_fir_func(N,N_TRIALS); //corrected dt_micros to be like applying FIR to one input sample. 94 | FLOPS_per_trial[I_N] = 2*N; 95 | #elif (OPERATION_TO_DO == DO_KISS_FFT) 96 | dt_micros = kiss_fft_func(N,N_TRIALS); 97 | FLOPS_per_trial[I_N]=-1; 98 | #elif (OPERATION_TO_DO == DO_ARM_FFT) 99 | dt_micros = arm_fft_func(N,N_TRIALS); 100 | FLOPS_per_trial[I_N]=-1; 101 | #endif 102 | 103 | //report the timing 104 | //PRINTF("%s: N = %i\tin %6.1f usec per operation\r\n",alg_name,N,((float)dt_micros)/((float)N_TRIALS)); 105 | Serial.print(alg_name); Serial.print(F(": N = ")); Serial.print(N); Serial.print(F(" in ")); 106 | if (dt_micros < 1) { 107 | Serial.print(F(" *** NOT ENOUGH TEMP MEMORY *** ")); 108 | } else { 109 | Serial.print(((float)dt_micros)/((float)N_TRIALS)); 110 | Serial.print(F(" usec per operation")); 111 | if (FLOPS_per_trial[I_N] > 0) { 112 | Serial.print(F(", MFLOPS = ")); 113 | Serial.print(((float)FLOPS_per_trial[I_N])*((float)N_TRIALS) / ((float)dt_micros)); 114 | } 115 | } 116 | #ifdef IS_ARDUINO_UNO 117 | Serial.print(F(", Free RAM = ")); Serial.print(freeRam()); 118 | #endif 119 | Serial.println(); 120 | } 121 | } 122 | } 123 | } 124 | 125 | 126 | -------------------------------------------------------------------------------- /Arduino/Audio Processing Benchmarking/FIR_FFT_Benchmarking/do_arm_fft.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _DO_ARM_FFT 3 | #define _DO_ARM_FFT 4 | 5 | #define ARM_MATH_CM4 6 | #include "arm_math.h" 7 | //include "arm_const_structs.h" //from CMSIS example. Is it needed? 8 | #include "fft_fir_const.h" 9 | 10 | //// parameters for stepping through different FFT lengths 11 | //#define MAX_N_FFT 2048 12 | //#define N_ALL_FFT 7 13 | //int ALL_N_FFT[N_ALL_FFT] = {MAX_N_FFT/64, MAX_N_FFT/32, MAX_N_FFT/16, MAX_N_FFT/8, MAX_N_FFT/4, MAX_N_FFT/2, MAX_N_FFT}; 14 | //#define N_FFT_LOOP 1000 15 | 16 | //parameters for CMSIS FFT functions 17 | uint8_t ifftFlag = 0; 18 | uint8_t doBitReverse = 1; 19 | 20 | // ///// Choose what type of FFT to do...integer/float, radix2 or radix4 21 | 22 | #define DO_RADIX2 //comment this out to do RADIX4. RADIX4 is usually faster 23 | //#define DO_RFFT //enable this to do RFFT instead of CFFT. 24 | 25 | #if (DATA_TYPE == USE_INT16) 26 | 27 | #ifdef DO_RADIX2 28 | q15_t buffer_complex[MAX_N*2]; 29 | arm_cfft_radix2_instance_q15 fft_inst; 30 | #define ARM_FFT_INIT_FUNC arm_cfft_radix2_init_q15 31 | #define ARM_FFT_FUNC arm_cfft_radix2_q15 32 | #else 33 | q15_t buffer_complex[MAX_N*2]; 34 | arm_cfft_radix4_instance_q15 fft_inst; 35 | #define ARM_FFT_INIT_FUNC arm_cfft_radix4_init_q15 36 | #define ARM_FFT_FUNC arm_cfft_radix4_q15 37 | #endif 38 | 39 | #elif (DATA_TYPE == USE_INT32) 40 | 41 | #ifdef DO_RADIX2 42 | q31_t buffer_complex[MAX_N*2]; 43 | arm_cfft_radix2_instance_q31 fft_inst; 44 | #define ARM_FFT_INIT_FUNC arm_cfft_radix2_init_q31 45 | #define ARM_FFT_FUNC arm_cfft_radix2_q31 46 | #else 47 | q31_t buffer_complex[MAX_N*2]; 48 | arm_cfft_radix4_instance_q31 fft_inst; 49 | #define ARM_FFT_INIT_FUNC arm_cfft_radix4_init_q31 50 | #define ARM_FFT_FUNC arm_cfft_radix4_q31 51 | #endif 52 | 53 | #elif (DATA_TYPE == USE_FLOAT) 54 | 55 | #ifdef DO_RFFT 56 | //http://www.keil.com/pack/doc/CMSIS/DSP/html/group__RealFFT.html 57 | float32_t buffer_input[3*MAX_N]; 58 | float32_t buffer_output[3*MAX_N]; 59 | arm_cfft_radix4_instance_f32 cfft_rad4_inst; 60 | arm_rfft_instance_f32 fft_inst; 61 | #define ARM_FFT_INIT_FUNC arm_rfft_init_f32 62 | #define ARM_FFT_FUNC arm_rfft_f32 63 | #else 64 | #ifdef DO_RADIX2 65 | float32_t buffer_complex[MAX_N*2]; 66 | arm_cfft_radix2_instance_f32 fft_inst; 67 | #define ARM_FFT_INIT_FUNC arm_cfft_radix2_init_f32 68 | #define ARM_FFT_FUNC arm_cfft_radix2_f32 69 | #else 70 | float32_t buffer_complex[MAX_N*2]; 71 | arm_cfft_radix4_instance_f32 fft_inst; 72 | #define ARM_FFT_INIT_FUNC arm_cfft_radix4_init_f32 73 | #define ARM_FFT_FUNC arm_cfft_radix4_f32 74 | #endif 75 | #endif 76 | 77 | #endif 78 | 79 | uint32_t start_micros = 0; 80 | uint32_t arm_fft_func(const int N_FFT, const int N_LOOP) { 81 | if (N_FFT > MAX_N) return 0; // don't ask for N that is too big 82 | if (N_FFT < 32) return 0; //dont' ask for N that is too small 83 | 84 | //initialize the FFT function 85 | #ifdef DO_RFFT 86 | ARM_FFT_INIT_FUNC(&fft_inst, &cfft_rad4_inst, N_FFT, ifftFlag, doBitReverse); 87 | #else 88 | ARM_FFT_INIT_FUNC(&fft_inst, N_FFT, ifftFlag, doBitReverse); 89 | #endif 90 | 91 | //PRINTF("STARTING N_FFT_LOOP = %i\r\n", N_FFT_LOOP); 92 | start_micros = micros(); 93 | for (int count=0; count < N_LOOP; count++) { 94 | 95 | #ifdef DO_RFFT 96 | // prepare the data...real only 97 | for (int j=0; j < N_FFT; j++) buffer_input[j] = j % 8; // 8 sample ramp 98 | 99 | /* Process the data through the RFFT module */ 100 | ARM_FFT_FUNC(&fft_inst, buffer_input, buffer_output); 101 | #else 102 | // prepare the data 103 | for (int j=0; j < 2*N_FFT; j += 2) { 104 | //first sample is real 105 | buffer_complex[j] = j % 8; // 8 sample ramp 106 | 107 | //second sample is imaginary 108 | buffer_complex[j+1] = 0; // always use a real signal 109 | } 110 | /* Process the data through the CFFT/CIFFT module */ 111 | ARM_FFT_FUNC(&fft_inst, buffer_complex); 112 | #endif 113 | } 114 | 115 | // return the time it took to do this run 116 | return micros() - start_micros; 117 | } 118 | 119 | 120 | #endif 121 | -------------------------------------------------------------------------------- /Arduino/Audio Processing Benchmarking/FIR_FFT_Benchmarking/do_arm_fir.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _DO_ARM_FIR 3 | #define _DO_ARM_FIR 4 | 5 | #define ARM_MATH_CM4 6 | #include "arm_math.h" 7 | //include "arm_const_structs.h" //from CMSIS example. Is it needed? 8 | #include "fft_fir_const.h" 9 | 10 | 11 | 12 | // ///// Choose what type of FIR to do...integer/float 13 | 14 | //#define DO_RADIX2 //comment this out to do RADIX4. RADIX4 is usually faster 15 | 16 | #if (DATA_TYPE == USE_INT16) 17 | #define FIR_DATA_TYPE q15_t 18 | arm_fir_instance_q15 FIR_inst; 19 | #define ARM_FIR_INIT_FUNC arm_fir_init_q15 20 | #define ARM_FIR_FUNC arm_fir_fast_q15 21 | 22 | #elif (DATA_TYPE == USE_INT32) 23 | 24 | #define FIR_DATA_TYPE q31_t 25 | arm_fir_instance_q31 FIR_inst; 26 | #define ARM_FIR_INIT_FUNC arm_fir_init_q31 27 | #define ARM_FIR_FUNC arm_fir_q31 28 | 29 | #elif (DATA_TYPE == USE_FLOAT) 30 | #define FIR_DATA_TYPE float32_t 31 | arm_fir_instance_f32 FIR_inst; 32 | #define ARM_FIR_INIT_FUNC arm_fir_init_f32 33 | #define ARM_FIR_FUNC arm_fir_f32 34 | 35 | #endif 36 | 37 | FIR_DATA_TYPE input[MAX_N]; 38 | FIR_DATA_TYPE output[MAX_N]; 39 | FIR_DATA_TYPE firCoeff[MAX_N]; 40 | FIR_DATA_TYPE firState[MAX_N + MAX_N - 1]; 41 | 42 | uint32_t start_micros = 0; 43 | uint32_t arm_fir_func(const int N_FIR, const int N_LOOP) { 44 | if (N_FIR > MAX_N) return 0; // don't ask for N that is too big 45 | 46 | //initialize the FFT function 47 | //arm_fir_init_f32(&S, NUM_TAPS, (float32_t *)&firCoeffs32[0], &firStateF32[0], blockSize); 48 | ARM_FIR_INIT_FUNC(&FIR_inst, N_FIR, (FIR_DATA_TYPE *)&firCoeff[0], (FIR_DATA_TYPE *)&firState[0],(uint32_t)N_FIR); 49 | 50 | //prepare input 51 | for (int i=0; i MAX_N) return 0; // don't ask for N that is too big 30 | 31 | //Configure the memory (and FFT twiddle factors) for this trial 32 | //my_fft_cfg = kiss_fft_alloc(N_FFT,is_ifft,NULL, NULL); 33 | my_fft_cfg = kiss_fft_alloc(N_FFT,is_ifft,fft_twiddle,&len_mem); 34 | if ((len_mem == 0) || (len_mem == NULL) || (my_fft_cfg == NULL)) return 0; //this means it couldn't configure the memroy 35 | 36 | //PRINTF("STARTING N_FFT_LOOP = %i\r\n", N_FFT_LOOP); 37 | start_micros = micros(); 38 | for (int count=0; count < N_LOOP; count++) { 39 | 40 | //prepare the fake input data 41 | for (int i = 0; i < N_FFT; i++) { 42 | //in_buffer[i].r = (kiss_fft_scalar)(i % 8); //real 43 | in_buffer[i].r = (kiss_fft_scalar)(i); //real 44 | in_buffer[i].i = (kiss_fft_scalar)0; //imaginary 45 | } 46 | 47 | //do fft 48 | kiss_fft(my_fft_cfg,in_buffer,out_buffer); 49 | } 50 | 51 | // return the time it took to do this run 52 | return micros() - start_micros; 53 | }; 54 | 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /Arduino/Audio Processing Benchmarking/FIR_FFT_Benchmarking/do_naive_fir.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _DO_NAIVE_FIR 3 | #define _DO_NAIVE_FIR 4 | 5 | #include "fft_fir_const.h" 6 | 7 | 8 | filt_t out_val; //must be outside the function to prevent optimizer from removing the meat of the function 9 | filt_t b[MAX_N],z[MAX_N]; 10 | uint32_t naive_fir_func(const int N_FIR, const int N_LOOP) { 11 | uint32_t start_micros = 0; 12 | uint32_t dt_micros=0; 13 | filt_t input_val; 14 | 15 | // define filter size 16 | int z_ind = -1; 17 | int foo_z_ind = 0; 18 | 19 | //initialize filter coefficients 20 | for (int i = 0; i < N_FIR; i++) { 21 | //define the filter coefficients 22 | b[i] = 23.1+(float)i; 23 | 24 | //initialize filter states to zero 25 | z[i] = 0.0+(float)i; 26 | } 27 | 28 | //start doing the trials 29 | start_micros = micros(); 30 | filt_t accum=0; 31 | for (int count = 0; count < N_LOOP; count++) { //run multiple times? or not. 32 | z_ind=0; 33 | 34 | //pretend a new value came in 35 | //input_val = 1194.23; //some unusual value 36 | input_val = (filt_t)1194.23+(filt_t)count; //adding the (float)count slows things down quite a bit! 37 | 38 | //put new value into state vector 39 | z_ind++; if (z_ind == N_FIR) z_ind = 0; // increment and wrap (if necessary) 40 | z[z_ind] = input_val; // put new value into z 41 | 42 | //apply filter 43 | out_val = 0.0; //initialize the output value 44 | foo_z_ind = z_ind; //not needed for modulo 45 | for (int i=0; i //does some of the datatypes for Maple 20 | #else 21 | #include //for micros() and whatnot for arduino. Don't do this for Maples 22 | #endif 23 | #else 24 | #include "board.h" //for Kinetis IDE 25 | #endif 26 | 27 | // Define the maximum size of the FFT/FIR that you want to do 28 | #ifdef IS_ARDUINO_UNO //Arduino Uno has very little memory 29 | #if (DATA_TYPE == USE_INT16) 30 | #if (OPERATION_TO_DO == DO_NAIVE_FIR) 31 | #define MAX_N 256 32 | #else 33 | #define MAX_N 64 34 | #endif 35 | #else 36 | #if (OPERATION_TO_DO == DO_NAIVE_FIR) 37 | #define MAX_N 128 38 | #else 39 | #define MAX_N 32 //Arduino Uno has very little memory 40 | #endif 41 | #endif 42 | #else 43 | #ifdef IS_MAPLE 44 | #if (OPERATION_TO_DO == DO_NAIVE_FIR) 45 | #define MAX_N 1024 46 | #else 47 | #define MAX_N 256 //limit for KissFFT 48 | #endif 49 | #else 50 | //Arduino M0, Due (?), Teensy 51 | #if OPERATION_TO_DO == DO_ARM_FIR 52 | #define MAX_N 256 53 | #else 54 | #define MAX_N 512 //All other platforms have more memory so you can do more 55 | #endif 56 | #endif 57 | #endif 58 | 59 | // ///////////// Below is code that responds to your choices above 60 | #ifdef IS_ARDUINO_UNO 61 | //define data types 62 | typedef int int16_t; 63 | typedef long int32_t; 64 | typedef unsigned long uint32_t; 65 | #endif 66 | 67 | #ifdef IS_MAPLE 68 | //define data types...http://docs.leaflabs.com/static.leaflabs.com/pub/leaflabs/maple-docs/0.0.11/lang/cpp/built-in-types.html 69 | typedef short int int16_t; 70 | //typedef int int32_t; 71 | //typedef int __int32_t; 72 | typedef __INT32_TYPE__ __int32_t; 73 | typedef __int32_t int32_t; 74 | typedef unsigned long uint32_t; 75 | typedef long long int64_t; 76 | #endif 77 | 78 | //for NAIVE_FIR 79 | #if (DATA_TYPE == USE_INT16) 80 | typedef int16_t filt_t; 81 | #elif (DATA_TYPE == USE_INT32) 82 | typedef int32_t filt_t; 83 | #elif (DATA_TYPE == USE_FLOAT) 84 | typedef float filt_t; 85 | #endif 86 | 87 | 88 | //for KISS_FFT 89 | #if (DATA_TYPE == USE_INT16) 90 | #define FIXED_POINT 16 91 | #elif (DATA_TYPE == USE_INT32) 92 | #define FIXED_POINT 32 93 | #endif 94 | 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /Arduino/Audio Processing Benchmarking/FIR_FFT_Benchmarking/kiss_fft.h: -------------------------------------------------------------------------------- 1 | #ifndef KISS_FFT_H 2 | #define KISS_FFT_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "fft_fir_const.h" 10 | 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /* 17 | ATTENTION! 18 | If you would like a : 19 | -- a utility that will handle the caching of fft objects 20 | -- real-only (no imaginary time component ) FFT 21 | -- a multi-dimensional FFT 22 | -- a command-line utility to perform ffts 23 | -- a command-line utility to perform fast-convolution filtering 24 | 25 | Then see kfc.h kiss_fftr.h kiss_fftnd.h fftutil.c kiss_fastfir.c 26 | in the tools/ directory. 27 | */ 28 | 29 | #ifdef USE_SIMD 30 | # include 31 | # define kiss_fft_scalar __m128 32 | #define KISS_FFT_MALLOC(nbytes) _mm_malloc(nbytes,16) 33 | #define KISS_FFT_FREE _mm_free 34 | #else 35 | #define KISS_FFT_MALLOC malloc 36 | #define KISS_FFT_FREE free 37 | #endif 38 | 39 | 40 | #ifdef FIXED_POINT 41 | //#include 42 | # if (FIXED_POINT == 32) 43 | # define kiss_fft_scalar int32_t 44 | # else 45 | # define kiss_fft_scalar int16_t 46 | # endif 47 | #else 48 | # ifndef kiss_fft_scalar 49 | /* default is float */ 50 | # define kiss_fft_scalar float 51 | # endif 52 | #endif 53 | 54 | typedef struct { 55 | kiss_fft_scalar r; 56 | kiss_fft_scalar i; 57 | }kiss_fft_cpx; 58 | 59 | typedef struct kiss_fft_state* kiss_fft_cfg; 60 | 61 | /* 62 | * kiss_fft_alloc 63 | * 64 | * Initialize a FFT (or IFFT) algorithm's cfg/state buffer. 65 | * 66 | * typical usage: kiss_fft_cfg mycfg=kiss_fft_alloc(1024,0,NULL,NULL); 67 | * 68 | * The return value from fft_alloc is a cfg buffer used internally 69 | * by the fft routine or NULL. 70 | * 71 | * If lenmem is NULL, then kiss_fft_alloc will allocate a cfg buffer using malloc. 72 | * The returned value should be free()d when done to avoid memory leaks. 73 | * 74 | * The state can be placed in a user supplied buffer 'mem': 75 | * If lenmem is not NULL and mem is not NULL and *lenmem is large enough, 76 | * then the function places the cfg in mem and the size used in *lenmem 77 | * and returns mem. 78 | * 79 | * If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough), 80 | * then the function returns NULL and places the minimum cfg 81 | * buffer size in *lenmem. 82 | * */ 83 | 84 | kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem); 85 | 86 | /* 87 | * kiss_fft(cfg,in_out_buf) 88 | * 89 | * Perform an FFT on a complex input buffer. 90 | * for a forward FFT, 91 | * fin should be f[0] , f[1] , ... ,f[nfft-1] 92 | * fout will be F[0] , F[1] , ... ,F[nfft-1] 93 | * Note that each element is complex and can be accessed like 94 | f[k].r and f[k].i 95 | * */ 96 | void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout); 97 | 98 | /* 99 | A more generic version of the above function. It reads its input from every Nth sample. 100 | * */ 101 | void kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int fin_stride); 102 | 103 | /* If kiss_fft_alloc allocated a buffer, it is one contiguous 104 | buffer and can be simply free()d when no longer needed*/ 105 | #define kiss_fft_free free 106 | 107 | /* 108 | Cleans up some memory that gets managed internally. Not necessary to call, but it might clean up 109 | your compiler output to call this before you exit. 110 | */ 111 | void kiss_fft_cleanup(void); 112 | 113 | 114 | /* 115 | * Returns the smallest integer k, such that k>=n and k has only "fast" factors (2,3,5) 116 | */ 117 | int kiss_fft_next_fast_size(int n); 118 | 119 | /* for real ffts, we need an even size */ 120 | #define kiss_fftr_next_fast_size_real(n) \ 121 | (kiss_fft_next_fast_size( ((n)+1)>>1)<<1) 122 | 123 | #ifdef __cplusplus 124 | } 125 | #endif 126 | 127 | #endif 128 | -------------------------------------------------------------------------------- /Arduino/Audio Processing Benchmarking/FLOPS_test/FLOPS_test.ino: -------------------------------------------------------------------------------- 1 | // https://forum.pjrc.com/threads/27959-FLOPS-not-scaling-to-F_CPU 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | //FASTRUN 8 | void float_MatMult(float* A, float* B, int m, int p, int n, float* C) { 9 | // A = input matrix (m x p) 10 | // B = input matrix (p x n) 11 | // m = number of rows in A 12 | // p = number of columns in A = number of rows in B 13 | // n = number of columns in B 14 | // C = output matrix = A*B (m x n) 15 | int i, j, k; 16 | for ( i = 0; i < m; i++ ) 17 | for ( j = 0; j < n; j++ ){ 18 | C[i*n+j] = 0; 19 | for( k = 0; k < p; k++ ) C[i*n+j] += A[i*p+k]*B[k*n+j]; 20 | } 21 | } 22 | 23 | #define N 128 24 | float32_t A[N][N]; 25 | float32_t B[N][N]; 26 | float32_t C[N][N]; 27 | 28 | 29 | void setup() { 30 | 31 | while (!Serial) ; 32 | 33 | // variables for timing 34 | int i=0; 35 | int dt; 36 | 37 | // variables for calculation 38 | 39 | 40 | memset(A,3.1415,sizeof(A)); 41 | memset(B,8.1415,sizeof(B)); 42 | memset(C,0.0,sizeof(C)); 43 | 44 | arm_matrix_instance_f32 A_inst, B_inst, C_inst; 45 | arm_mat_init_f32(&A_inst, N, N, (float32_t *)A); 46 | arm_mat_init_f32(&B_inst, N, N, (float32_t *)B); 47 | arm_mat_init_f32(&C_inst, N, N, (float32_t *)C); 48 | 49 | int tbegin = micros(); 50 | #if 1 51 | for (i=1;;i++) { 52 | // do calculation 53 | //float_MatMult((float*) A, (float*)B, N,N,N, (float*)C); 54 | arm_mat_mult_f32(&A_inst, &B_inst, &C_inst); 55 | // check if t_delay has passed 56 | dt = micros() - tbegin; 57 | if (dt > 1000000) break; 58 | } 59 | #else 60 | for (i=0; i < 200; i++) { 61 | float_MatMult((float*) A, (float*)B, N,N,N, (float*)C); 62 | } 63 | dt = micros() - tbegin; 64 | #endif 65 | 66 | Serial.printf("(%dx%d) matrices: ", N, N); 67 | Serial.printf("%d matrices in %d usec: ", i, dt); 68 | Serial.printf("%d matrices/second\n", (int)((float)i*1000000/dt)); 69 | Serial.printf("Float (%d bytes) ", sizeof(float)); 70 | //float total = N*N*N*i*1e6 / (float)dt; 71 | float total_MFLOPS = N*N*N*i / (float)dt; 72 | Serial.printf(" MFLOPS:\t(%f)\n", total_MFLOPS); 73 | 74 | ///////// Vector multiply 75 | tbegin = micros(); 76 | for (i=1;;i++) { 77 | // do calculation 78 | //float_MatMult((float*) A, (float*)B, N,N,N, (float*)C); 79 | arm_mult_f32((float32_t *)A, (float32_t *)B, (float32_t *)C, N*N); 80 | // check if t_delay has passed 81 | dt = micros() - tbegin; 82 | if (dt > 1000000) break; 83 | } 84 | 85 | Serial.printf("(%dx) Vector Multiply: ",N*N); 86 | Serial.printf("%d vectors in %d usec: ", i, dt); 87 | Serial.printf("%d vectors/second\n", (int)((float)i*1000000/dt)); 88 | Serial.printf("Float (%d bytes) ", sizeof(float)); 89 | //float total = N*i*1e6 / (float)dt; 90 | total_MFLOPS = N*N*i / (float)dt; 91 | Serial.printf(" MFLOPS:\t(%f)\n", total_MFLOPS); 92 | 93 | 94 | ///////// FIR 95 | arm_fir_instance_f32 FIR_inst; 96 | #define N_FIR (4*N) 97 | #define N_BUFF (16*N_FIR) 98 | arm_fir_init_f32(&FIR_inst, N_FIR, (float32_t *)B[0], (float32_t *)B[N_BUFF/N_FIR],N_BUFF); 99 | tbegin = micros(); 100 | for (i=1;;i++) { 101 | // do calculation 102 | //float_MatMult((float*) A, (float*)B, N,N,N, (float*)C); 103 | arm_fir_f32(&FIR_inst,(float32_t *)A, (float32_t *)C,N_BUFF); 104 | // check if t_delay has passed 105 | dt = micros() - tbegin; 106 | if (dt > 1000000) break; 107 | } 108 | 109 | 110 | Serial.printf("(%dx) FIR on %d buffer: ",N_FIR,N_BUFF); 111 | Serial.printf("%d buffers in %d usec: ", i, dt); 112 | Serial.printf("%d Buffers/second\n", (int)((float)i*1000000/dt)); 113 | Serial.printf("Float (%d bytes) ", sizeof(float)); 114 | //float total = N*i*1e6 / (float)dt; 115 | total_MFLOPS = N_FIR*N_BUFF*i / (float)dt; 116 | Serial.printf(" MFLOPS:\t(%f)\n", total_MFLOPS); 117 | 118 | } 119 | 120 | void loop() { 121 | } 122 | -------------------------------------------------------------------------------- /Arduino/Audio Processing Benchmarking/Notes - Arduino Maple.txt: -------------------------------------------------------------------------------- 1 | 2 | 2016-09-04 3 | 4 | Following install instructions from here: https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki/Installation 5 | 6 | Following these instructions, I installed Arduino IDE 1.6.9, which required uninstalling my previous installation (1.6.5). I fear that this destroyed my Teensy installation, but I'll deal with that later. 7 | 8 | Then I downloaded the Arduino_STM32 and put it into my new Arduino Hardware folder. I ran the BAT file, as instructed in the installation page. 9 | 10 | I don't see any option for Maple under the tools->boards menu. Error message to IDE console says "Could not find boards.txt in C:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F4. is it pre-1.5?". 11 | 12 | Note that I already had the M0 drivers installed, so I should be good there. 13 | 14 | Unzip again. Remove master from name (keep underscore). Copy to Arduino/hardware again. Start Arduino IDE again. Now the Maple appears! 15 | 16 | Trying to compile and update blink program. It took a while to compile (10-20sec?), but it works! 17 | 18 | Now trying to compile my FIR_FFT Benchmarking code 19 | in NAIVe_FIR mode. it doesn't like including arduino.h or board.h. Also, needed to add a block of code to define my data types (int32_t and whatnot). That took a lot of shenanigans. For my int32 type, I needed to add this into fft_fir.const.h 20 | 21 | #include 22 | typedef __INT32_TYPE__ __int32_t; 23 | typedef __int32_t int32_t; 24 | 25 | -------------------------------------------------------------------------------- /Arduino/Audio Processing Benchmarking/Old/FFT_Benchmarking_ARM/FFT_Benchmarking_ARM.ino: -------------------------------------------------------------------------------- 1 | 2 | //CMSIS DSP Software library for ARM (basis of Teensy 3.1 arm_math library 3 | http://www.keil.com/pack/doc/CMSIS/DSP/html/modules.html 4 | #include "arm_math.h" 5 | 6 | /* ------------------------------------------------------------------ 7 | * Global variables for FFT Bin Example 8 | * ------------------------------------------------------------------- */ 9 | #define MAX_N_FFT 4096 10 | #define N_ALL_N_FFT 8 11 | int all_N_FFT[N_ALL_N_FFT] = {32, 64, 128, 256, 512, 1024, 2048, 4096}; 12 | //#define N_ALL_N_FFT 3 13 | //int all_N_FFT[N_ALL_N_FFT] = {64, 256, 1024}; 14 | int N_FFT; 15 | //q15_t buffer_real[MAX_N_FFT*2]; 16 | q15_t buffer_complex[MAX_N_FFT*2]; 17 | //q31_t buffer_real[MAX_N_FFT*2]; 18 | //q31_t buffer_complex[MAX_N_FFT*2]; 19 | //float32_t buffer_real[MAX_N_FFT*2]; 20 | //float32_t buffer_complex[MAX_N_FFT*2]; 21 | uint8_t ifftFlag = 0; 22 | uint8_t doBitReverse = 1; 23 | arm_cfft_radix2_instance_q15 cfft_inst; 24 | //arm_cfft_radix2_instance_q31 cfft_inst; 25 | //arm_cfft_radix4_instance_q15 cfft_inst; 26 | //arm_rfft_instance_q15 rfft_inst; 27 | //arm_cfft_radix2_instance_f32 cfft_inst; 28 | //arm_cfft_radix4_instance_f32 cfft_inst; 29 | //arm_rfft_instance_f32 rfft_inst; 30 | 31 | 32 | void setup() { 33 | Serial.begin(115200); 34 | delay(2000); 35 | Serial.println("Starting FFT_Benchmarking_ARM..."); 36 | } 37 | 38 | 39 | #define N_TRIALS_PER_FFT 3 40 | #define N_LOOP 200 41 | int32_t accumulated_micros=0; 42 | int32_t start_micros = 0; 43 | 44 | void loop() { 45 | for (int I_FFT_size_ind = 0; I_FFT_size_ind < N_ALL_N_FFT; I_FFT_size_ind++) { 46 | N_FFT = all_N_FFT[I_FFT_size_ind]; 47 | 48 | //initialize the FFT function 49 | arm_cfft_radix2_init_q15(&cfft_inst, N_FFT, ifftFlag, doBitReverse); 50 | //arm_cfft_radix2_init_q31(&cfft_inst, N_FFT, ifftFlag, doBitReverse); 51 | //arm_cfft_radix4_init_q15(&cfft_inst, N_FFT, ifftFlag, doBitReverse); 52 | //arm_cfft_radix4_init_q31(&cfft_inst, N_FFT, ifftFlag, doBitReverse); 53 | //arm_cfft_radix4_init_q15(&cfft_inst, N_FFT, ifftFlag, doBitReverse); 54 | //arm_rfft_init_q15(&rfft_inst, &cfft_inst, N_FFT, ifftFlag, doBitReverse); 55 | //arm_cfft_radix4_init_q31(&cfft_inst, N_FFT, ifftFlag, doBitReverse); 56 | //arm_rfft_init_q31(&rfft_inst, &cfft_inst, N_FFT, ifftFlag, doBitReverse); 57 | //arm_cfft_radix2_init_f32(&cfft_inst, N_FFT, ifftFlag, doBitReverse); 58 | //arm_cfft_radix4_init_f32(&cfft_inst, N_FFT, ifftFlag, doBitReverse); 59 | //arm_rfft_init_f32(&rfft_inst, &cfft_inst, N_FFT, ifftFlag, doBitReverse); 60 | 61 | //loop over number of trials per FFT 62 | for (int I_trial = 0; I_trial < N_TRIALS_PER_FFT; I_trial++) { 63 | 64 | //reset the timer 65 | accumulated_micros = 0; 66 | 67 | //loop over the desried number of FFTs 68 | for (int i=0; i < N_LOOP; i++) { 69 | 70 | // prepare the data 71 | //for (int j=0; j < N_FFT; j++) buffer_real[j]=j%8;// 8 sample ramp 72 | for (int j=0; j < 2*N_FFT; j += 2) { 73 | //first sample is real 74 | buffer_complex[j] = j % 8; // 8 sample ramp 75 | 76 | //second sample is imaginary 77 | buffer_complex[j+1] = 0; // always use a real signal 78 | } 79 | 80 | // start the clock 81 | start_micros = micros(); 82 | 83 | /* Process the data through the CFFT/CIFFT module */ 84 | // //arm_cfft_f32(&arm_cfft_sR_f32_len1024, testInput_f32_10khz, ifftFlag, doBitReverse); 85 | // //arm_cfft_radix2_q15(fft_instance,input_data) 86 | // //arm_cfft_q31(fft_instance,input_complex_Q31,ifftFlag,bitReverseFlag); 87 | // //if (window) apply_window_to_fft_buffer(buffer, window); 88 | // //arm_cfft_radix4_q15(&fft_inst, buffer_complex_Q15); 89 | arm_cfft_radix2_q15(&cfft_inst, buffer_complex); 90 | //arm_cfft_radix2_q31(&cfft_inst, buffer_complex); 91 | //arm_cfft_radix4_q15(&cfft_inst, buffer_complex); 92 | //arm_cfft_radix4_q31(&cfft_inst, buffer_complex); 93 | //arm_rfft_q15(&rfft_inst, buffer_real, buffer_complex); 94 | //arm_rfft_q31(&rfft_inst, buffer_real, buffer_complex); 95 | //arm_cfft_radix2_f32(&cfft_inst, buffer_complex); 96 | //arm_cfft_radix4_f32(&cfft_inst, buffer_complex); 97 | //arm_rfft_f32(&rfft_inst, buffer_real, buffer_complex); 98 | 99 | // add time for this run 100 | accumulated_micros += (micros() - start_micros); 101 | 102 | } 103 | 104 | Serial.print("N_FFT = "); 105 | Serial.print(N_FFT); 106 | Serial.print(", N_LOOP = "); 107 | Serial.print(N_LOOP); 108 | Serial.print(", Micros per FFT = "); 109 | Serial.print((float)accumulated_micros/((float)N_LOOP)); 110 | Serial.println(); 111 | } 112 | } 113 | } 114 | 115 | 116 | -------------------------------------------------------------------------------- /Arduino/Audio Processing Benchmarking/Old/FFT_Benchmarking_C_physionet/types.h: -------------------------------------------------------------------------------- 1 | 2 | typedef float full_res_t; 3 | -------------------------------------------------------------------------------- /Arduino/Audio Processing Benchmarking/Old/FFT_Benchmarking_IntFFT_AnyN/FFT_Benchmarking_IntFFT_AnyN.ino: -------------------------------------------------------------------------------- 1 | 2 | 3 | //include "arm_math.h" //to get int16_t and int32_t 4 | #include "mytypes.h" 5 | 6 | //Add streaming-like output http://playground.arduino.cc/Main/StreamingOutput 7 | template inline Print &operator <<(Print &obj, T arg) { 8 | obj.print(arg); 9 | return obj; 10 | } 11 | 12 | const int ledPin = 13; //Teensy 3.0+ is on pin 13 13 | 14 | #define MAX_NFFT 2048 15 | #define N_ALL_FFT 7 16 | int ALL_N_FFT[N_ALL_FFT] = {MAX_NFFT, 1024, 512, 256, 128, 64, 32}; 17 | //int ALL_LOG2_N_FFT[N_ALL_FFT] = {10}; 18 | int N_FFT = MAX_NFFT; 19 | //int LOG2_N_FFT = 10; 20 | int real[MAX_NFFT]; 21 | int imag[MAX_NFFT]; 22 | 23 | 24 | void setup() { 25 | //start the serial 26 | Serial.begin(115200); 27 | 28 | //delay to allow the serial to really get going 29 | delay(2000); 30 | 31 | //prepare for blinky light 32 | pinMode(ledPin, OUTPUT); 33 | digitalWrite(ledPin, HIGH); 34 | 35 | } 36 | 37 | #define N_LOOP 200 38 | int count = 0; 39 | long start_micros = 0; 40 | long accumulated_micros = 0; 41 | int led_status = LOW; 42 | int ret_val = 0; 43 | Int_FFT_cfg* fft_cfg = NULL; 44 | void loop() { 45 | 46 | for (int I_N_FFT = 0; I_N_FFT < N_ALL_FFT; I_N_FFT++) { 47 | N_FFT = ALL_N_FFT[I_N_FFT]; 48 | //LOG2_N_FFT = ALL_LOG2_N_FFT[I_N_FFT]; 49 | if (fft_cfg != NULL) delete fft_cfg; 50 | fft_cfg = new Int_FFT_cfg(N_FFT); 51 | 52 | //Serial << "Allocating memory for N = " << N_FFT << '\n'; 53 | int is_ifft = 0; 54 | 55 | accumulated_micros = 0; 56 | count = 0; 57 | 58 | //Serial << "Beginning N_LOOP = " << N_LOOP << '\n'; 59 | while (count < N_LOOP) { 60 | led_status = HIGH; 61 | digitalWrite(ledPin, led_status); 62 | count++; 63 | 64 | //prepare input data 65 | for (int i = 0; i < N_FFT; i++) { 66 | real[i] = (i % 8); //real 67 | //real[i] = 1000*cos(2*3.1415926535 * ((float)i/10.0));// real 68 | imag[i] = 0; //imaginary 69 | } 70 | 71 | //start timer 72 | start_micros = micros(); 73 | 74 | //do fft 75 | ret_val = fix_fft(fft_cfg,real,imag,is_ifft); 76 | //Serial << "ret_val = " << ret_val << '\n'; 77 | 78 | //finish timer 79 | accumulated_micros += (micros() - start_micros); 80 | //Serial << "FFT " << count << " complete.\n"; 81 | } 82 | 83 | if (accumulated_micros != 0) { 84 | //print the timing results 85 | Serial.print("N_FFT = "); 86 | Serial.print(N_FFT); 87 | Serial.print(", micros per FFT = "); 88 | Serial.println( ((float)accumulated_micros) / ((float)N_LOOP)); 89 | } 90 | 91 | } 92 | 93 | } 94 | 95 | -------------------------------------------------------------------------------- /Arduino/Audio Processing Benchmarking/Old/FFT_Benchmarking_IntFFT_AnyN/mytypes.h: -------------------------------------------------------------------------------- 1 | 2 | typedef int fixed; 3 | #include 4 | 5 | class Int_FFT_cfg { 6 | public: 7 | Int_FFT_cfg() {}; 8 | 9 | Int_FFT_cfg(int n) { 10 | N_FFT = n; 11 | 12 | //allocate memory for the table; 13 | Sinewave = new int[N_FFT]; 14 | 15 | //figure out the factor of two for this FFT 16 | LOG2_N_WAVE = 0; 17 | while (n > 0) { 18 | LOG2_N_WAVE++; 19 | n = n >> 1; //shift down (ie, divide by two) 20 | } 21 | 22 | //create sine lookup table 23 | createSineLookupTable(); 24 | } 25 | ~Int_FFT_cfg(void) { 26 | delete [] Sinewave; 27 | } 28 | 29 | int* Sinewave; 30 | int N_FFT=0; 31 | int LOG2_N_WAVE=0; 32 | 33 | private: 34 | 35 | void createSineLookupTable(void) { 36 | const float MAX_VAL = 32768.0; 37 | const float f_N_FFT = (float)N_FFT; 38 | for (int i=0; i inline Print &operator <<(Print &obj, T arg) { 8 | obj.print(arg); 9 | return obj; 10 | } 11 | 12 | const int ledPin = 13; //Teensy 3.0+ is on pin 13 13 | 14 | #define MAX_NFFT 1024 15 | #define N_ALL_FFT 1 16 | int ALL_N_FFT[N_ALL_FFT] = {MAX_NFFT}; 17 | int ALL_LOG2_N_FFT[N_ALL_FFT] = {10}; 18 | int N_FFT = MAX_NFFT; 19 | int LOG2_N_FFT = 10; 20 | int real[MAX_NFFT]; 21 | int imag[MAX_NFFT]; 22 | 23 | 24 | void setup() { 25 | //start the serial 26 | Serial.begin(115200); 27 | 28 | //delay to allow the serial to really get going 29 | delay(2000); 30 | 31 | //prepare for blinky light 32 | pinMode(ledPin, OUTPUT); 33 | digitalWrite(ledPin, HIGH); 34 | 35 | } 36 | 37 | #define N_LOOP 200 38 | int count = 0; 39 | long start_micros = 0; 40 | long accumulated_micros = 0; 41 | int led_status = LOW; 42 | int ret_val = 0; 43 | void loop() { 44 | 45 | for (int I_N_FFT = 0; I_N_FFT < N_ALL_FFT; I_N_FFT++) { 46 | N_FFT = ALL_N_FFT[I_N_FFT]; 47 | LOG2_N_FFT = ALL_LOG2_N_FFT[I_N_FFT]; 48 | 49 | //Serial << "Allocating memory for N = " << N_FFT << '\n'; 50 | int is_ifft = 0; 51 | 52 | accumulated_micros = 0; 53 | count = 0; 54 | 55 | //Serial << "Beginning N_LOOP = " << N_LOOP << '\n'; 56 | while (count < N_LOOP) { 57 | led_status = HIGH; 58 | digitalWrite(ledPin, led_status); 59 | count++; 60 | 61 | //prepare input data 62 | for (int i = 0; i < N_FFT; i++) { 63 | real[i] = (i % 8); //real 64 | //real[i] = 1000*cos(2*3.1415926535 * ((float)i/10.0));// real 65 | imag[i] = 0; //imaginary 66 | } 67 | 68 | //start timer 69 | start_micros = micros(); 70 | 71 | //do fft 72 | ret_val = fix_fft(real,imag,LOG2_N_FFT,is_ifft); 73 | //Serial << "ret_val = " << ret_val << '\n'; 74 | 75 | //finish timer 76 | accumulated_micros += (micros() - start_micros); 77 | //Serial << "FFT " << count << " complete.\n"; 78 | } 79 | 80 | if (accumulated_micros != 0) { 81 | //print the timing results 82 | Serial.print("N_FFT = "); 83 | Serial.print(N_FFT); 84 | Serial.print(", micros per FFT = "); 85 | Serial.println( ((float)accumulated_micros) / ((float)N_LOOP)); 86 | } 87 | 88 | } 89 | 90 | } 91 | 92 | -------------------------------------------------------------------------------- /Arduino/Audio Processing Benchmarking/Old/FFT_Benchmarking_IntFFT_N1024/integer_fft.Readme.txt: -------------------------------------------------------------------------------- 1 | Here it is... an integer FFT routine that's pretty fast. I've only tested 2 | it on a 68k powerbook, and it's much faster than either software floating 3 | point or the built in FPU. The orignal source was DOS only and came off 4 | the net. 5 | I simply removed the ugly DOS stuff and did some simple testing. I do not 6 | guarantee that it works... but try compiling with -DMAIN to test it yourself. 7 | 8 | Those of you with impoverished floating point hardware (notably, some new 9 | Powerbooks, and maybe even Intel machines) might find these routines 10 | useful. 11 | 12 | Input and output is an array of shorts. I haven't tested all the routines, 13 | but the FFT looks good enough to use. It keeps a table of trig functions, so 14 | it will only run up to 1024 points. 15 | 16 | -- Malcolm 17 | 18 | Written by: Tom Roberts 11/8/89 19 | Made portable: Malcolm Slaney 12/15/94 malcolm@interval.com 20 | -------------------------------------------------------------------------------- /Arduino/Audio Processing Benchmarking/Old/FFT_Benchmarking_IntFFT_N1024/mytypes.h: -------------------------------------------------------------------------------- 1 | 2 | typedef int fixed; 3 | 4 | -------------------------------------------------------------------------------- /Arduino/Audio Processing Benchmarking/Old/FFT_Benchmarking_KissFFT/FFT_Benchmarking_KissFFT.ino: -------------------------------------------------------------------------------- 1 | 2 | 3 | //add KISS_FFT library: http://sourceforge.net/projects/kissfft/?source=typ_redirect 4 | #include "arm_math.h" //to get int16_t and int32_t 5 | #include "mytypes.h" 6 | #include "kiss_fft.h" 7 | 8 | //Add streaming-like output http://playground.arduino.cc/Main/StreamingOutput 9 | template inline Print &operator <<(Print &obj, T arg) { 10 | obj.print(arg); 11 | return obj; 12 | } 13 | 14 | const int ledPin = 13; //Teensy 3.0+ is on pin 13 15 | 16 | #define MAX_NFFT 256 17 | #define N_ALL_FFT 4 18 | int ALL_N_FFT[N_ALL_FFT] = {256, 128, 64, 32}; 19 | int N_FFT; 20 | kiss_fft_cpx in_buffer[MAX_NFFT]; 21 | kiss_fft_cpx out_buffer[MAX_NFFT]; 22 | 23 | 24 | void setup() { 25 | //start the serial 26 | Serial.begin(115200); 27 | 28 | //delay to allow the serial to really get going 29 | delay(2000); 30 | 31 | //prepare for blinky light 32 | pinMode(ledPin, OUTPUT); 33 | digitalWrite(ledPin, HIGH); 34 | 35 | } 36 | 37 | #define N_LOOP 10 38 | int count = 0; 39 | long start_micros = 0; 40 | long accumulated_micros = 0; 41 | int led_status = LOW; 42 | kiss_fft_cfg my_fft_cfg; 43 | void loop() { 44 | 45 | for (int I_N_FFT = 0; I_N_FFT < N_ALL_FFT; I_N_FFT++) { 46 | N_FFT = ALL_N_FFT[I_N_FFT]; 47 | 48 | //Serial << "Allocating memory for N = " << N_FFT << '\n'; 49 | int is_ifft = 0; 50 | if (my_fft_cfg) KISS_FFT_FREE(my_fft_cfg); //de-allocate the memory prior to making new allocations 51 | my_fft_cfg = kiss_fft_alloc(N_FFT,is_ifft,NULL, NULL); 52 | //Serial << "my_fft_cfg = " << ((int)my_fft_cfg) << '\n'; 53 | 54 | accumulated_micros = 0; 55 | count = 0; 56 | 57 | //Serial << "Beginning N_LOOP = " << N_LOOP << '\n'; 58 | while (count < N_LOOP) { 59 | led_status = HIGH; 60 | digitalWrite(ledPin, led_status); 61 | count++; 62 | 63 | //prepare input data 64 | for (int i = 0; i < N_FFT; i++) { 65 | in_buffer[i].r = (kiss_fft_scalar)(i % 8); //real 66 | in_buffer[i].i = (kiss_fft_scalar)0; //imaginary 67 | } 68 | 69 | //start timer 70 | start_micros = micros(); 71 | 72 | //do fft 73 | kiss_fft(my_fft_cfg,in_buffer,out_buffer); 74 | 75 | //finish timer 76 | accumulated_micros += (micros() - start_micros); 77 | //Serial << "FFT " << count << " complete.\n"; 78 | } 79 | 80 | if (accumulated_micros != 0) { 81 | //print the timing results 82 | Serial.print("N_FFT = "); 83 | Serial.print(N_FFT); 84 | Serial.print(", micros per FFT = "); 85 | Serial.println( ((float)accumulated_micros) / ((float)N_LOOP)); 86 | } 87 | 88 | } 89 | 90 | } 91 | 92 | -------------------------------------------------------------------------------- /Arduino/Audio Processing Benchmarking/Old/FFT_Benchmarking_KissFFT/kiss_fft.h: -------------------------------------------------------------------------------- 1 | #ifndef KISS_FFT_H 2 | #define KISS_FFT_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /* 14 | ATTENTION! 15 | If you would like a : 16 | -- a utility that will handle the caching of fft objects 17 | -- real-only (no imaginary time component ) FFT 18 | -- a multi-dimensional FFT 19 | -- a command-line utility to perform ffts 20 | -- a command-line utility to perform fast-convolution filtering 21 | 22 | Then see kfc.h kiss_fftr.h kiss_fftnd.h fftutil.c kiss_fastfir.c 23 | in the tools/ directory. 24 | */ 25 | 26 | #ifdef USE_SIMD 27 | # include 28 | # define kiss_fft_scalar __m128 29 | #define KISS_FFT_MALLOC(nbytes) _mm_malloc(nbytes,16) 30 | #define KISS_FFT_FREE _mm_free 31 | #else 32 | #define KISS_FFT_MALLOC malloc 33 | #define KISS_FFT_FREE free 34 | #endif 35 | 36 | 37 | #ifdef FIXED_POINT 38 | #include 39 | # if (FIXED_POINT == 32) 40 | # define kiss_fft_scalar int32_t 41 | # else 42 | # define kiss_fft_scalar int16_t 43 | # endif 44 | #else 45 | # ifndef kiss_fft_scalar 46 | /* default is float */ 47 | # define kiss_fft_scalar float 48 | # endif 49 | #endif 50 | 51 | typedef struct { 52 | kiss_fft_scalar r; 53 | kiss_fft_scalar i; 54 | }kiss_fft_cpx; 55 | 56 | typedef struct kiss_fft_state* kiss_fft_cfg; 57 | 58 | /* 59 | * kiss_fft_alloc 60 | * 61 | * Initialize a FFT (or IFFT) algorithm's cfg/state buffer. 62 | * 63 | * typical usage: kiss_fft_cfg mycfg=kiss_fft_alloc(1024,0,NULL,NULL); 64 | * 65 | * The return value from fft_alloc is a cfg buffer used internally 66 | * by the fft routine or NULL. 67 | * 68 | * If lenmem is NULL, then kiss_fft_alloc will allocate a cfg buffer using malloc. 69 | * The returned value should be free()d when done to avoid memory leaks. 70 | * 71 | * The state can be placed in a user supplied buffer 'mem': 72 | * If lenmem is not NULL and mem is not NULL and *lenmem is large enough, 73 | * then the function places the cfg in mem and the size used in *lenmem 74 | * and returns mem. 75 | * 76 | * If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough), 77 | * then the function returns NULL and places the minimum cfg 78 | * buffer size in *lenmem. 79 | * */ 80 | 81 | kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem); 82 | 83 | /* 84 | * kiss_fft(cfg,in_out_buf) 85 | * 86 | * Perform an FFT on a complex input buffer. 87 | * for a forward FFT, 88 | * fin should be f[0] , f[1] , ... ,f[nfft-1] 89 | * fout will be F[0] , F[1] , ... ,F[nfft-1] 90 | * Note that each element is complex and can be accessed like 91 | f[k].r and f[k].i 92 | * */ 93 | void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout); 94 | 95 | /* 96 | A more generic version of the above function. It reads its input from every Nth sample. 97 | * */ 98 | void kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int fin_stride); 99 | 100 | /* If kiss_fft_alloc allocated a buffer, it is one contiguous 101 | buffer and can be simply free()d when no longer needed*/ 102 | #define kiss_fft_free free 103 | 104 | /* 105 | Cleans up some memory that gets managed internally. Not necessary to call, but it might clean up 106 | your compiler output to call this before you exit. 107 | */ 108 | void kiss_fft_cleanup(void); 109 | 110 | 111 | /* 112 | * Returns the smallest integer k, such that k>=n and k has only "fast" factors (2,3,5) 113 | */ 114 | int kiss_fft_next_fast_size(int n); 115 | 116 | /* for real ffts, we need an even size */ 117 | #define kiss_fftr_next_fast_size_real(n) \ 118 | (kiss_fft_next_fast_size( ((n)+1)>>1)<<1) 119 | 120 | #ifdef __cplusplus 121 | } 122 | #endif 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /Arduino/Audio Processing Benchmarking/Old/FFT_Benchmarking_KissFFT/kiss_fft.h~: -------------------------------------------------------------------------------- 1 | #ifndef KISS_FFT_H 2 | #define KISS_FFT_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /* 14 | ATTENTION! 15 | If you would like a : 16 | -- a utility that will handle the caching of fft objects 17 | -- real-only (no imaginary time component ) FFT 18 | -- a multi-dimensional FFT 19 | -- a command-line utility to perform ffts 20 | -- a command-line utility to perform fast-convolution filtering 21 | 22 | Then see kfc.h kiss_fftr.h kiss_fftnd.h fftutil.c kiss_fastfir.c 23 | in the tools/ directory. 24 | */ 25 | 26 | #ifdef USE_SIMD 27 | # include 28 | # define kiss_fft_scalar __m128 29 | #define KISS_FFT_MALLOC(nbytes) _mm_malloc(nbytes,16) 30 | #define KISS_FFT_FREE _mm_free 31 | #else 32 | #define KISS_FFT_MALLOC malloc 33 | #define KISS_FFT_FREE free 34 | #endif 35 | 36 | 37 | #ifdef FIXED_POINT 38 | #include 39 | # if (FIXED_POINT == 32) 40 | # define kiss_fft_scalar int32_t 41 | # else 42 | # define kiss_fft_scalar int16_t 43 | # endif 44 | #else 45 | # ifndef kiss_fft_scalar 46 | /* default is float */ 47 | # define kiss_fft_scalar float 48 | # endif 49 | #endif 50 | 51 | typedef struct { 52 | kiss_fft_scalar r; 53 | kiss_fft_scalar i; 54 | }kiss_fft_cpx; 55 | 56 | typedef struct kiss_fft_state* kiss_fft_cfg; 57 | 58 | /* 59 | * kiss_fft_alloc 60 | * 61 | * Initialize a FFT (or IFFT) algorithm's cfg/state buffer. 62 | * 63 | * typical usage: kiss_fft_cfg mycfg=kiss_fft_alloc(1024,0,NULL,NULL); 64 | * 65 | * The return value from fft_alloc is a cfg buffer used internally 66 | * by the fft routine or NULL. 67 | * 68 | * If lenmem is NULL, then kiss_fft_alloc will allocate a cfg buffer using malloc. 69 | * The returned value should be free()d when done to avoid memory leaks. 70 | * 71 | * The state can be placed in a user supplied buffer 'mem': 72 | * If lenmem is not NULL and mem is not NULL and *lenmem is large enough, 73 | * then the function places the cfg in mem and the size used in *lenmem 74 | * and returns mem. 75 | * 76 | * If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough), 77 | * then the function returns NULL and places the minimum cfg 78 | * buffer size in *lenmem. 79 | * */ 80 | 81 | kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem); 82 | 83 | /* 84 | * kiss_fft(cfg,in_out_buf) 85 | * 86 | * Perform an FFT on a complex input buffer. 87 | * for a forward FFT, 88 | * fin should be f[0] , f[1] , ... ,f[nfft-1] 89 | * fout will be F[0] , F[1] , ... ,F[nfft-1] 90 | * Note that each element is complex and can be accessed like 91 | f[k].r and f[k].i 92 | * */ 93 | void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout); 94 | 95 | /* 96 | A more generic version of the above function. It reads its input from every Nth sample. 97 | * */ 98 | void kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int fin_stride); 99 | 100 | /* If kiss_fft_alloc allocated a buffer, it is one contiguous 101 | buffer and can be simply free()d when no longer needed*/ 102 | #define kiss_fft_free free 103 | 104 | /* 105 | Cleans up some memory that gets managed internally. Not necessary to call, but it might clean up 106 | your compiler output to call this before you exit. 107 | */ 108 | void kiss_fft_cleanup(void); 109 | 110 | 111 | /* 112 | * Returns the smallest integer k, such that k>=n and k has only "fast" factors (2,3,5) 113 | */ 114 | int kiss_fft_next_fast_size(int n); 115 | 116 | /* for real ffts, we need an even size */ 117 | #define kiss_fftr_next_fast_size_real(n) \ 118 | (kiss_fft_next_fast_size( ((n)+1)>>1)<<1) 119 | 120 | #ifdef __cplusplus 121 | } 122 | #endif 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /Arduino/Audio Processing Benchmarking/Old/FFT_Benchmarking_KissFFT/mytypes.h: -------------------------------------------------------------------------------- 1 | 2 | //define FIXED_POINT 32 //comment this out to make it use floats 3 | //define KISS_FFT_USE_ALLOCA 4 | -------------------------------------------------------------------------------- /Arduino/Audio Processing Benchmarking/Old/FIR_Benchmarking/FIR_Benchmarking.ino: -------------------------------------------------------------------------------- 1 | 2 | #include "types.h" 3 | 4 | //Define test parameters 5 | #define N_TRIALS 1000 6 | 7 | 8 | //Define FIR Filter 9 | #define N_FIR 64 10 | filt_t b[N_FIR]; 11 | //filt_t a[1] = {0.0}; 12 | int z_ind = -1; 13 | int foo_z_ind = 0; 14 | filt_t z[N_FIR]; 15 | //int z[N_FIR]; 16 | 17 | //define other parameters 18 | long start_micros=0; 19 | long end_micros=0; 20 | int count; 21 | filt_t input_val; 22 | //int input_val; 23 | filt_t out_val; 24 | 25 | 26 | filt_t filter(filt_t b[], filt_t &input_val, filt_t z[], int &z_ind) { 27 | //put new value into state vector 28 | z_ind++; if (z_ind == N_FIR) z_ind = 0; // increment and wrap (if necessary) 29 | z[z_ind] = input_val; // put new value into z 30 | 31 | //apply filter 32 | out_val = 0.0; 33 | foo_z_ind = z_ind; 34 | for (int i=0; i 4 | //include 5 | //include 6 | 7 | // signed16 * signed 16 >> 16 8 | #define MultiS16X16toH16(intRes, intIn1, intIn2) \ 9 | asm volatile ( \ 10 | "clr r26 \n\t" \ 11 | "mul %A1, %A2 \n\t" \ 12 | "mov r27, r1 \n\t" \ 13 | "muls %B1, %B2 \n\t" \ 14 | "movw %A0, r0 \n\t" \ 15 | "mulsu %B2, %A1 \n\t" \ 16 | "sbc %B0, r26 \n\t" \ 17 | "add r27, r0 \n\t" \ 18 | "adc %A0, r1 \n\t" \ 19 | "adc %B0, r26 \n\t" \ 20 | "mulsu %B1, %A2 \n\t" \ 21 | "sbc %B0, r26 \n\t" \ 22 | "add r27, r0 \n\t" \ 23 | "adc %A0, r1 \n\t" \ 24 | "adc %B0, r26 \n\t" \ 25 | "clr r1 \n\t" \ 26 | : \ 27 | "=&r" (intRes) \ 28 | : \ 29 | "a" (intIn1), \ 30 | "a" (intIn2) \ 31 | : \ 32 | "r26", "r27" \ 33 | ) 34 | 35 | int int_val = 0; 36 | int out_val; 37 | long long_val = 0; 38 | 39 | void setup() { 40 | Serial.begin(115200); 41 | 42 | // put your setup code here, to run once: 43 | int_val = -32000; 44 | Serial.print("Int = "); 45 | Serial.println(int_val); 46 | Serial.print("Int+Int = "); 47 | Serial.println(int_val+int_val); 48 | Serial.print("long(Int)+long(Int) = "); 49 | Serial.println(long(int_val)+long(int_val)); 50 | Serial.print("int(long(Int)+long(Int)) = "); 51 | Serial.println(int(long(int_val)+long(int_val))); 52 | Serial.print("int( (long(Int)+long(Int)) >> 16 ) = "); 53 | Serial.println(int( (long(int_val)+long(int_val)) >> 16 )); 54 | 55 | Serial.println("*********************"); 56 | Serial.print("int_val = "); 57 | Serial.println(int_val); 58 | Serial.print("int_val * -int_val = "); 59 | Serial.println(int_val * -int_val); 60 | Serial.print("long(int_val) * long(-int_val) = "); 61 | Serial.println(long(int_val) * long(-int_val)); 62 | Serial.print("int( long(int_val) * long(-int_val) >> 16) = "); 63 | Serial.println(int( long(int_val) * long(-int_val) >> 16)); 64 | Serial.print("int( MultiS16X16toH16(int_val, intVal) = "); 65 | MultiS16X16toH16(out_val,int_val,-int_val); 66 | Serial.println(out_val); 67 | 68 | 69 | } 70 | 71 | long start_micros, end_micros; 72 | #define N_LOOP 320000L 73 | void loop() { 74 | // put your main code here, to run repeatedly: 75 | 76 | start_micros = micros(); 77 | 78 | for (long i=0; i> 16; 80 | } 81 | 82 | end_micros = micros(); 83 | Serial.print("Long,Long,Shift = "); 84 | Serial.print(float(end_micros-start_micros)/float(N_LOOP)); 85 | Serial.println(" micros"); 86 | 87 | //////////////////////////// 88 | 89 | start_micros = micros(); 90 | 91 | for (long i=0; i //ARM DSP extensions. https://www.keil.com/pack/doc/CMSIS/DSP/html/index.html 4 | #include 5 | 6 | 7 | class AudioEffectTestCycles : public AudioStream 8 | { 9 | public: 10 | //constructor 11 | AudioEffectTestCycles(void) : AudioStream(1, inputQueueArray) { 12 | //do any setup activities here 13 | }; 14 | 15 | 16 | 17 | //here's the method that is called automatically by the Teensy Audio Library every data block 18 | void update(void) { 19 | audio_block_t *audio_block; 20 | audio_block = receiveWritable(); 21 | if (!audio_block) return; 22 | 23 | //do work here 24 | for (int i=0; idata[i]; 26 | val /= 32768.0f; 27 | for (int j=0; j < (int)(user_parameter); j++) { 28 | val = expf(val); 29 | } 30 | audio_block->data[i] = (int16_t)(val*32768.0f); 31 | } 32 | 33 | ///transmit the block and release memory 34 | transmit(audio_block); 35 | release(audio_block); 36 | } 37 | 38 | 39 | // Call this method in your main program if you want to set the value of your user parameter. 40 | // The user parameter can be used in your algorithm above. The user_parameter variable was 41 | // created in the "private:" section of this class, which appears a little later in this file. 42 | // Feel free to create more user parameters (and to use better names for your variables) 43 | // for use in this class. 44 | float32_t setUserParameter(float val) { 45 | return user_parameter = 100.0*val; 46 | } 47 | 48 | private: 49 | //state-related variables 50 | audio_block_t *inputQueueArray[1]; //memory pointer for the input to this module 51 | 52 | 53 | //this value can be set from the outside (such as from the potentiometer) to control 54 | //a parameter within your algorithm 55 | float32_t user_parameter = 0.0; 56 | 57 | }; //end class definition 58 | 59 | -------------------------------------------------------------------------------- /Arduino/Teensy Frequency Domain/FrequencyDomainDemo1/MyFFT_F32.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef _MyFFT_h 4 | #define _MyFFT_h 5 | 6 | //include 7 | #include 8 | 9 | class MyFFT_F32 10 | { 11 | public: 12 | MyFFT_F32(void) {}; 13 | MyFFT_F32(const int _N_FFT) { 14 | setup(_N_FFT); 15 | } 16 | MyFFT_F32(const int _N_FFT, const int _is_IFFT) { 17 | setup(_N_FFT, _is_IFFT); 18 | } 19 | ~MyFFT_F32(void) { delete window; }; //destructor 20 | 21 | void setup(const int _N_FFT) { 22 | int _is_IFFT = 0; 23 | setup(_N_FFT,_is_IFFT); 24 | } 25 | void setup(const int _N_FFT, const int _is_IFFT) { 26 | if (!is_valid_N_FFT(_N_FFT)) { 27 | Serial.println(F("MyFFT_F32: *** ERROR ***")); 28 | Serial.print(F(" : Cannot use N_FFT = ")); Serial.println(N_FFT); 29 | Serial.print(F(" : Must be power of 2 between 16 and 2048")); 30 | return; 31 | } 32 | N_FFT = _N_FFT; 33 | is_IFFT = _is_IFFT; 34 | 35 | if ((N_FFT == 16) || (N_FFT == 64) || (N_FFT == 256) || (N_FFT == 1024)) { 36 | arm_cfft_radix4_init_f32(&fft_inst_r4, N_FFT, is_IFFT, 1); //FFT 37 | is_rad4 = 1; 38 | } else { 39 | arm_cfft_radix2_init_f32(&fft_inst_r2, N_FFT, is_IFFT, 1); //FFT 40 | } 41 | 42 | //allocate window 43 | window = new float[N_FFT]; 44 | if (is_IFFT) { 45 | useRectangularWindow(); //default to no windowing for IFFT 46 | } else { 47 | useHanningWindow(); //default to windowing for FFT 48 | } 49 | } 50 | virtual int is_valid_N_FFT(const int N) { 51 | if ((N == 16) || (N == 32) || (N == 64) || (N == 128) || 52 | (N == 256) || (N == 512) || (N==1024) || (N==2048)) { 53 | return 1; 54 | } else { 55 | return 0; 56 | } 57 | } 58 | 59 | void useRectangularWindow(void) { 60 | flag__useWindow = 0; 61 | for (int i=0; i < N_FFT; i++) window[i] = 1.0; //cast it to the right type 62 | } 63 | void useHanningWindow(void) { 64 | flag__useWindow = 1; 65 | if (window != NULL) { 66 | for (int i=0; i < N_FFT; i++) window[i] = (-0.5f*cosf(2.0f*M_PI*(float)i/(float)N_FFT) + 0.5f); //cast it to the right type 67 | } 68 | } 69 | 70 | void applyWindowToRealPartOfComplexVector(float32_t *complex_2N_buffer) { 71 | for (int i=0; i < N_FFT; i++) { 72 | complex_2N_buffer[2*i] = complex_2N_buffer[2*i]*window[i]; 73 | } 74 | } 75 | void applyWindowToRealVector(float32_t *real_N_buffer) { 76 | for (int i=0; i < N_FFT; i++) { 77 | real_N_buffer[i] = real_N_buffer[2*i]*window[i]; 78 | } 79 | } 80 | 81 | virtual void execute(float32_t *complex_2N_buffer) { //interleaved [real,imaginary], total length is 2*N_FFT 82 | if (N_FFT == 0) return; 83 | 84 | //apply window before FFT (if it is an FFT and not IFFT) 85 | if ((~is_IFFT) && (flag__useWindow)) applyWindowToRealPartOfComplexVector(complex_2N_buffer); 86 | 87 | //do the FFT 88 | if (is_rad4) { 89 | arm_cfft_radix4_f32(&fft_inst_r4, complex_2N_buffer); 90 | } else { 91 | arm_cfft_radix2_f32(&fft_inst_r2, complex_2N_buffer); 92 | } 93 | 94 | //apply window after FFT (if it is an IFFT and not FFT) 95 | if ((is_IFFT) && (flag__useWindow)) applyWindowToRealPartOfComplexVector(complex_2N_buffer); 96 | } 97 | 98 | private: 99 | int N_FFT=0; 100 | int is_IFFT=0; 101 | int is_rad4=0; 102 | float *window; 103 | int flag__useWindow; 104 | arm_cfft_radix4_instance_f32 fft_inst_r4; 105 | arm_cfft_radix2_instance_f32 fft_inst_r2; 106 | 107 | }; 108 | 109 | class MyIFFT_F32 : public MyFFT_F32 // is basically the same as myFFT, so let's inherent myFFT 110 | { 111 | public: 112 | MyIFFT_F32(void) : MyFFT_F32() {}; 113 | MyIFFT_F32(const int _N_FFT): MyFFT_F32() { 114 | //constructor 115 | MyIFFT_F32::setup(_N_FFT); //call myFFT's setup routine 116 | } 117 | void setup(const int _N_FFT) { 118 | const int _is_IFFT = 1; 119 | MyFFT_F32::setup(_N_FFT, _is_IFFT); //call myFFT's setup routine 120 | } 121 | //all other functions are in myFFT 122 | }; 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /Arduino/Teensy Frequency Domain/MoreOverlapDemo_FD/FreqDomainProcessing - CPU.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Arduino/Teensy Frequency Domain/MoreOverlapDemo_FD/FreqDomainProcessing - CPU.png -------------------------------------------------------------------------------- /Arduino/Teensy Frequency Domain/MoreOverlapDemo_FD/Tympan Frequency Domain CPU.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Arduino/Teensy Frequency Domain/MoreOverlapDemo_FD/Tympan Frequency Domain CPU.xlsx -------------------------------------------------------------------------------- /Arduino/Teensy Frequency Domain/TestFFT/TestFFT.ino: -------------------------------------------------------------------------------- 1 | /* 2 | TestFFT 3 | 4 | Created: Chip Audette Jan 2017 5 | 6 | Purpose: Generate Output of FFT Routines to confirm that I'm using them 7 | Correctly 8 | 9 | License: MIT License 10 | 11 | */ 12 | 13 | #include 14 | #include "rfft.c" 15 | 16 | #define N_FFT (256) 17 | 18 | arm_cfft_radix4_instance_f32 cfft_inst1, cifft_inst1; //for FFT calls later...radix 4 won't do N=128 19 | //arm_cfft_radix2_instance_f32 cfft_inst1, cifft_inst1; //for FFT calls later...radix 4 won't do N=128 20 | //arm_cfft_radix4_instance_f32 cfft_inst2, cifft_inst2; //for FFT calls later...radix 4 won't do N=128 21 | arm_cfft_radix2_instance_f32 cfft_inst2, cifft_inst2; //for FFT calls later...radix2 will do N=128 22 | arm_rfft_instance_f32 rfft_inst1, rifft_inst1; 23 | //arm_rfft_instance_q31 rfft_inst1; 24 | //arm_cfft_radix4_instance_q31 cfft_inst_q31; 25 | void initFFTroutines(void) { 26 | int status; 27 | int N_FFT1 = N_FFT; 28 | uint8_t ifftFlag = 0; // 0 is FFT, 1 is IFFT 29 | uint8_t doBitReverse = 1; 30 | //arm_cfft_radix4_init_f32(&cfft_inst1, N_FFT1, ifftFlag, doBitReverse); //init FFT 31 | arm_cfft_radix2_init_f32(&cfft_inst2, N_FFT1, ifftFlag, doBitReverse); //init FFT 32 | //status = arm_rfft_init_q31(&rfft_inst1, &cfft_inst_q31, 128, ifftFlag, doBitReverse); //init FFT 33 | status = arm_rfft_init_f32(&rfft_inst1, &cfft_inst1, 256, ifftFlag, doBitReverse); //init FFT 34 | 35 | 36 | //erial.print("%RFFT Init Status: "); Serial.print(status); Serial.print(", where sucess would be "); Serial.println(ARM_MATH_SUCCESS); 37 | //delay(1000); 38 | 39 | //ifftFlag = 1; 40 | //arm_cfft_radix4_init_f32(&cifft_inst1, N_FFT1, ifftFlag, doBitReverse); //init FFT 41 | //arm_cfft_radix2_init_f32(&cifft_inst2, N_FFT1, ifftFlag, doBitReverse); //init FFT 42 | //arm_rfft_init_f32(&rifft_inst1, &cifft_inst1, N_FFT1, ifftFlag, doBitReverse); //init FFT 43 | } 44 | 45 | void setup() { 46 | delay(500); 47 | Serial.begin(115200); 48 | Serial.println("%TestFFT: starting..."); 49 | delay(1000); 50 | 51 | initFFTroutines(); 52 | } 53 | 54 | void makeSignal(float32_t real_sig[], int Nfft, const float32_t freq_fac, const float32_t DC_offset) { 55 | for (int i=0; i<2*Nfft;i++) real_sig[i]=0.0f; 56 | for (int i=0; i //Teensy Audio Library 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | // Create audio objects 13 | AudioControlSGTL5000 sgtl5000_1; //controller for the Teensy Audio Board 14 | //AudioInputI2S i2s_in; //Digital audio *from* the Teensy Audio Board ADC. Sends Int16. Stereo. 15 | AudioOutputI2S i2s_out; //Digital audio *to* the Teensy Audio Board DAC. Expects Int16. Stereo 16 | AudioSynthWaveformSine testSignal; //xy=107,185 17 | 18 | const int n_freqs = 3; 19 | int freq_ind = 0; 20 | float freqs_Hz[n_freqs] = {600.0, 700.0, 800.0}; 21 | 22 | // Make all of the audio connections 23 | AudioConnection patchCord1(testSignal, 0, i2s_out, 0); 24 | AudioConnection patchCord2(testSignal, 0, i2s_out, 1); 25 | //AudioConnection patchCord1(i2s_in, 0, i2s_out, 0); 26 | //AudioConnection patchCord2(i2s_in, 1, i2s_out, 1); 27 | 28 | 29 | // define the setup() function, the function that is called once when the device is booting 30 | void setup() { 31 | Serial.begin(115200); //open the USB serial link to enable debugging messages 32 | delay(1000); //give the computer's USB serial system a moment to catch up. 33 | Serial.print("ChangeBlockLength: AUDIO_BLOCK_SAMPLES: ");Serial.println(AUDIO_BLOCK_SAMPLES); 34 | 35 | // Audio connections require memory 36 | AudioMemory(10); //allocate Int16 audio data blocks 37 | 38 | // Enable the audio shield, select input, and enable output 39 | sgtl5000_1.enable(); //start the audio board 40 | sgtl5000_1.inputSelect(AUDIO_INPUT_LINEIN); //choose line-in or mic-in 41 | sgtl5000_1.volume(0.8); 42 | sgtl5000_1.lineInLevel(10, 10); //level can be 0 to 15. 5 is the Teensy Audio Library's default 43 | sgtl5000_1.adcHighPassFilterDisable(); //reduces noise. https://forum.pjrc.com/threads/27215-24-bit-audio-boards?p=78831&viewfull=1#post78831 44 | 45 | 46 | //setup sine wave as test signal 47 | testSignal.amplitude(0.01); 48 | testSignal.frequency(freqs_Hz[(freq_ind++) % n_freqs]); 49 | 50 | } //end setup() 51 | 52 | // define the loop() function, the function that is repeated over and over for the life of the device 53 | unsigned long lastUpdate_millis = 0; 54 | void loop() { 55 | if ((millis() - lastUpdate_millis) > 2000) { 56 | Serial.println("Changing Frequency..."); 57 | testSignal.frequency(freqs_Hz[(freq_ind++) % n_freqs]); 58 | lastUpdate_millis = millis(); 59 | } 60 | } //end loop() 61 | 62 | -------------------------------------------------------------------------------- /Arduino/Teensy Time Domain Audio/GainOnly/AudioControlSGTL5000_Extended.h: -------------------------------------------------------------------------------- 1 | 2 | /* AudioContolSGTL5000_Extended.h 3 | * 4 | * Purpose: Extends the functionality of the AudioControlSGTL5000 from the Teensy Audio Library 5 | * 6 | * Created: Chip Audette, Nov 2016 7 | * 8 | * License: MIT License. Use at your own risk 9 | */ 10 | 11 | #ifndef _AudioControlSGTL5000_Extended 12 | #define _AudioControlSGTL5000_Extended 13 | 14 | class AudioControlSGTL5000_Extended : public AudioControlSGTL5000 15 | { 16 | public: 17 | AudioControlSGTL5000_Extended(void) {}; 18 | bool micBiasEnable(void) { 19 | return micBiasEnable(3.0); 20 | } 21 | bool micBiasEnable(float volt) { 22 | //in the SGTL5000 datasheet see Table 29. CHIP_MIC_CTRL Register 0x002A 23 | 24 | ///bias resistor is set via bits 9-8 (out of 15-0) 25 | uint16_t bias_resistor_setting = 1 << 8; //set the bit for the registor to enable 2kOhm 26 | 27 | //bias voltage is set via bits 6-4 (out of 15-0) 28 | uint16_t bias_voltage_setting = ((uint16_t)((volt - 1.25) / 0.250 + 0.5)) << 4; 29 | 30 | //combine the two settings and issue the command 31 | return write(0x002A, bias_voltage_setting | bias_resistor_setting); 32 | } 33 | bool micBiasDisable(void) { 34 | //in the SGTL5000 datasheet see Table 29. CHIP_MIC_CTRL Register 0x002A 35 | return write(0x002A, 0x00); 36 | } 37 | }; 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /Arduino/Teensy Time Domain Audio/MultiBandCompressor_Float/effect_WDRcompressor_f32.h: -------------------------------------------------------------------------------- 1 | /* 2 | * effect_WDR_compressor: Wide Dynamic Rnage Compressor 3 | * 4 | * Created: Chip Audette (OpenAudio) Feb 2017 5 | * Derived From: WDRC_circuit from CHAPRO from BTNRC: https://github.com/BTNRH/chapro 6 | * As of Feb 2017, CHAPRO license is listed as "Creative Commons?" 7 | * 8 | * MIT License. Use at your own risk. 9 | * 10 | */ 11 | 12 | #ifndef _filter_fir_f32 13 | #define _filter_fir_f32 14 | 15 | #include "Arduino.h" 16 | #include "AudioStream_F32.h" 17 | #include "arm_math.h" 18 | 19 | /* from CHAPRO cha_ff.h 20 | #define DSL_MXCH 32 // maximum number of channels 21 | 22 | typedef struct { 23 | double attack; // attack time (ms) 24 | double release; // release time (ms) 25 | double maxdB; // maximum signal (dB SPL) 26 | int ear; // 0=left, 1=right 27 | int nchannel; // number of channels 28 | double cross_freq[DSL_MXCH]; // cross frequencies (Hz) 29 | double tkgain[DSL_MXCH]; // compression-start gain 30 | double cr[DSL_MXCH]; // compression ratio 31 | double tk[DSL_MXCH]; // compression-start kneepoint 32 | double bolt[DSL_MXCH]; // broadband output limiting threshold 33 | } CHA_DSL; 34 | 35 | typedef struct { 36 | double attack; // attack time (ms) 37 | double release; // release time (ms) 38 | double fs; // sampling rate (Hz) 39 | double maxdB; // maximum signal (dB SPL) 40 | double tkgain; // compression-start gain 41 | double tk; // compression-start kneepoint 42 | double cr; // compression ratio 43 | double bolt; // broadband output limiting threshold 44 | } CHA_WDRC; 45 | */ 46 | 47 | class AudioEffectCompressorWDR_F32 : public AudioStream_F32 48 | { 49 | public: 50 | AudioEffectCompressorWDR_F32(void): AudioStream_F32(1,inputQueueArray) { 51 | } 52 | 53 | //from 54 | void cha_agc_channel(CHA_PTR cp, float *x, float *y, int cs) { 55 | float alfa, beta, *tkgn, *tk, *cr, *bolt, *ppk; 56 | float *xk, *yk, *pk; 57 | int k, nc; 58 | 59 | // initialize WDRC variables 60 | alfa = (float) CHA_DVAR[_gcalfa]; 61 | beta = (float) CHA_DVAR[_gcbeta]; 62 | tkgn = (float *) cp[_gctkgn]; 63 | tk = (float *) cp[_gctk]; 64 | cr = (float *) cp[_gccr]; 65 | bolt = (float *) cp[_gcbolt]; 66 | ppk = (float *) cp[_gcppk]; 67 | // loop over channels 68 | nc = CHA_IVAR[_nc]; 69 | for (k = 0; k < nc; k++) { 70 | xk = x + k * cs; 71 | yk = y + k * cs; 72 | pk = ppk + k; 73 | compress(cp, xk, yk, cs, pk, alfa, beta, tkgn[k], tk[k], cr[k], bolt[k]); 74 | } 75 | } 76 | 77 | 78 | void setAttackRelease_sec(float atk_sec, float rel_sec, float fs_Hz) { 79 | time_const(atk_sec, rel_sec, fs_Hz, &alfa, &beta); 80 | } 81 | 82 | 83 | private: 84 | float alfa, beta; 85 | 86 | //from CHAPRO, agc_prepare.c 87 | static void time_const(double atk_mec, double rel_mec, double fs, float *alfa, float *beta) { 88 | double ansi_atk, ansi_rel; 89 | 90 | // convert ANSI attack & release times to filter time constants 91 | ansi_atk = atk * fs / 2.425f; 92 | ansi_rel = rel * fs / 1.782f; 93 | *alfa = (float) (ansi_atk / (1.0f + ansi_atk)); 94 | *beta = (float) (ansi_rel / (10.f + ansi_rel)); 95 | } 96 | }; 97 | 98 | -------------------------------------------------------------------------------- /Arduino/Teensy Time Domain Audio/MultiBandCompressor_Float/filter_fir_f32.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AudioFilterFIR_F32 3 | * 4 | * Created: Chip Audette (OpenAudio) Feb 2017 5 | * - Building from AudioFilterFIR from Teensy Audio Library (AudioFilterFIR credited to Pete (El Supremo)) 6 | * 7 | */ 8 | 9 | #ifndef _filter_fir_f32 10 | #define _filter_fir_f32 11 | 12 | #include "Arduino.h" 13 | #include "AudioStream_F32.h" 14 | #include "arm_math.h" 15 | 16 | // Indicates that the code should just pass through the audio 17 | // without any filtering (as opposed to doing nothing at all) 18 | #define FIR_F32_PASSTHRU ((const float32_t *) 1) 19 | 20 | #define FIR_MAX_COEFFS 200 21 | 22 | class AudioFilterFIR_F32 : public AudioStream_F32 23 | { 24 | public: 25 | AudioFilterFIR_F32(void): AudioStream_F32(1,inputQueueArray), coeff_p(NULL) { 26 | } 27 | void begin(const float32_t *cp, int n_coeffs) { 28 | coeff_p = cp; 29 | // Initialize FIR instance (ARM DSP Math Library) 30 | if (coeff_p && (coeff_p != FIR_F32_PASSTHRU) && n_coeffs <= FIR_MAX_COEFFS) { 31 | arm_fir_init_f32(&fir_inst, n_coeffs, (float32_t *)coeff_p, &StateF32[0], AUDIO_BLOCK_SAMPLES); 32 | //if (arm_fir_init_f32(&fir_inst, n_coeffs, (float32_t *)coeff_p, &StateF32[0], AUDIO_BLOCK_SAMPLES) != ARM_MATH_SUCCESS) { 33 | // n_coeffs must be an even number, 4 or larger 34 | //coeff_p = NULL; 35 | //} 36 | } 37 | } 38 | void end(void) { 39 | coeff_p = NULL; 40 | } 41 | virtual void update(void); 42 | private: 43 | audio_block_f32_t *inputQueueArray[1]; 44 | 45 | // pointer to current coefficients or NULL or FIR_PASSTHRU 46 | const float32_t *coeff_p; 47 | 48 | // ARM DSP Math library filter instance 49 | arm_fir_instance_f32 fir_inst; 50 | float32_t StateF32[AUDIO_BLOCK_SAMPLES + FIR_MAX_COEFFS]; 51 | }; 52 | 53 | 54 | void AudioFilterFIR_F32::update(void) 55 | { 56 | audio_block_f32_t *block, *b_new; 57 | 58 | block = AudioStream_F32::receiveReadOnly_f32(); 59 | if (!block) return; 60 | 61 | // If there's no coefficient table, give up. 62 | if (coeff_p == NULL) { 63 | AudioStream_F32::release(block); 64 | return; 65 | } 66 | 67 | // do passthru 68 | if (coeff_p == FIR_F32_PASSTHRU) { 69 | // Just passthrough 70 | AudioStream_F32::transmit(block); 71 | AudioStream_F32::release(block); 72 | return; 73 | } 74 | 75 | // get a block for the FIR output 76 | b_new = AudioStream_F32::allocate_f32(); 77 | if (b_new) { 78 | arm_fir_f32(&fir_inst, (float32_t *)block->data, (float32_t *)b_new->data, AUDIO_BLOCK_SAMPLES); 79 | AudioStream_F32::transmit(b_new); // send the FIR output 80 | AudioStream_F32::release(b_new); 81 | } 82 | AudioStream_F32::release(block); 83 | } 84 | 85 | #endif 86 | 87 | 88 | -------------------------------------------------------------------------------- /Arduino/Teensy Time Domain Audio/PassThrough_LineIn/PassThrough_LineIn.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * PassThrough_LineIn 3 | * Test the ability to pass audio through the device from the LineIn input. 4 | * 5 | * Created: Chip Audette, Oct 2016 6 | * 7 | * Uses Teensy Audio Board. 8 | */ 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | AudioControlSGTL5000 sgtl5000_1; 16 | AudioInputI2S i2s1; 17 | AudioOutputI2S i2s2; 18 | 19 | //simplest pass-through (On Teensy 3.6: works at 96 MHz and 120MHz. Not at 144/180/192/216/240MHz. 20 | AudioConnection patchCord1(i2s1, 0, i2s2, 0); 21 | AudioConnection patchCord2(i2s1, 1, i2s2, 1); 22 | 23 | void setup() { 24 | Serial.begin(115200); 25 | delay(500); 26 | Serial.println("Pass-Through Line-In to Headphone..."); 27 | 28 | AudioMemory(20); 29 | delay(250); 30 | 31 | // Enable the audio shield and set the output volume. 32 | sgtl5000_1.enable(); 33 | sgtl5000_1.inputSelect(AUDIO_INPUT_LINEIN); 34 | sgtl5000_1.volume(0.45); //headphone volume 35 | //sgtl5000_1.lineInLevel(11, 11); //max is 15, default is 5 36 | } 37 | 38 | void loop() { 39 | delay(20); 40 | } 41 | 42 | -------------------------------------------------------------------------------- /Arduino/Teensy Time Domain Audio/TestHeadphone_ToneAndSweep/TestHeadphone_ToneAndSweep.ino: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | // GUItool: begin automatically generated code 9 | AudioSynthToneSweep tonesweep1; //xy=86,141 10 | AudioSynthWaveformSine sine1; //xy=93,84 11 | AudioMixer4 mixer1; //xy=274,85 12 | AudioOutputI2S i2s1; //xy=458,92 13 | AudioConnection patchCord1(tonesweep1, 0, mixer1, 1); 14 | AudioConnection patchCord2(sine1, 0, mixer1, 0); 15 | AudioConnection patchCord3(mixer1, 0, i2s1, 0); 16 | AudioConnection patchCord4(mixer1, 0, i2s1, 1); 17 | 18 | //AudioOutputUSB usb1; //xy=464,156 19 | //AudioConnection patchCord5(mixer1, 0, usb1, 0); 20 | //AudioConnection patchCord6(mixer1, 0, usb1, 1); 21 | 22 | AudioControlSGTL5000 sgtl5000_1; //xy=288,187 23 | // GUItool: end automatically generated code 24 | 25 | 26 | void setup() { 27 | // put your setup code here, to run once: 28 | 29 | delay(200); 30 | Serial.begin(115200); 31 | delay(200); 32 | 33 | AudioMemory(10); //give Audio Library some memory 34 | 35 | //configure the Teensy Audio Board 36 | sgtl5000_1.enable(); 37 | //sgtl5000_1.inputSelect(myInput); 38 | sgtl5000_1.volume(0.8); //headphone volume 39 | sgtl5000_1.adcHighPassFilterDisable(); //reduce noise? https://forum.pjrc.com/threads/27215-24-bit-audio-boards?p=78831&viewfull=1#post78831 40 | 41 | 42 | //configure the sine wave 43 | sine1.amplitude(0.0); 44 | 45 | 46 | } 47 | 48 | 49 | float level = 0.05; 50 | float lowFreq = 20.; 51 | float highFreq = 20000.; 52 | float dur_sec = 5.0; 53 | void loop() { 54 | 55 | //do tone at 1 kHz 56 | sine1.frequency(1000.0); 57 | sine1.amplitude(level); 58 | delay(dur_sec*1000); 59 | 60 | //do frequency sweep 61 | sine1.amplitude(0.0); //turn off sine 62 | tonesweep1.play(level, lowFreq, highFreq, dur_sec); 63 | while (tonesweep1.isPlaying()) { 64 | delay(10); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Arduino/Teensy Time Domain Audio/Tympan_BasicTest/Tympan_BasicTest.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Tympan_BasicTest.ino 3 | * 4 | * Created: BPF and WEA, Creare LLC, Jan/Feb 2017 5 | * Purpose: Demonstrate basic audio pass-thru using the Tympan Audio Board, 6 | * which is based on the TI TLV320AIC3206 7 | * 8 | * License: MIT License, Use At Your Own Risk 9 | * 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include //AudioControlTLV320AIC3206 lives here 18 | 19 | // define audio classes and connections 20 | AudioControlTLV320AIC3206 tlv320aic3206_1; 21 | AudioOutputI2S audioOutput; 22 | AudioSynthWaveformSine sine; 23 | #if 1 24 | //use sine wave to test just the output portion 25 | AudioConnection patchCord1(sine, 0, audioOutput, 0); 26 | AudioConnection patchCord2(sine, 0, audioOutput, 1); 27 | #else 28 | //use audio from microphones (or line in) and pipe to the audio output 29 | AudioConnection patchCord1(audioInput, 0, audioOutput, 0); 30 | AudioConnection patchCord2(audioInput, 1, audioOutput, 1); 31 | #endif 32 | 33 | // define the setup 34 | void setup(void) 35 | { 36 | //allocate the audio memory first 37 | AudioMemory(10); //big number to accomodate the delay effect 38 | 39 | //begin the serial comms 40 | Serial.begin(115200); delay(500); 41 | Serial.println("Tympan_TLV320AIC3206: starting..."); 42 | 43 | // Setup the TLV320 44 | tlv320aic3206_1.enable(); // activate AIC 45 | 46 | // Choose the desired input 47 | tlv320aic3206_1.inputSelect(TYMPAN_INPUT_ON_BOARD_MIC); // use the on board microphones // default 48 | // tlv320aic3206_1.inputSelect(TYMPAN_INPUT_JACK_AS_MIC); // use the microphone jack - defaults to mic bias 2.5V 49 | // tlv320aic3206_1.inputSelect(TYMPAN_INPUT_JACK_AS_LINEIN); // use the microphone jack - defaults to mic bias OFF 50 | // tlv320aic3206_1.inputSelect(TYMPAN_INPUT_LINE_IN); // use the line in pads on the TYMPAN board - defaults to mic bias OFF 51 | 52 | //Adjust the MIC bias, if using TYMPAN_INPUT_JACK_AS_MIC 53 | // tlv320aic3206_1.setMicBias(TYMPAN_MIC_BIAS_OFF); // Turn mic bias off 54 | // tlv320aic3206_1.setMicBias(TYMPAN_MIC_BIAS_2_5); // set mic bias to 2.5 // default 55 | // tlv320aic3206_1.setMicBias(TYMPAN_MIC_BIAS_1_7); // set mic bias to 1.7 56 | // tlv320aic3206_1.setMicBias(TYMPAN_MIC_BIAS_1_25); // set mic bias to 1.25 57 | // tlv320aic3206_1.setMicBias(TYMPAN_MIC_BIAS_VSUPPLY); // set mic bias to supply voltage 58 | 59 | // VOLUMES 60 | tlv320aic3206_1.volume_dB(10); // -63.6 to +24 dB in 0.5dB steps. uses float 61 | tlv320aic3206_1.setInputGain_dB(10); // set MICPGA volume, 0-47.5dB in 0.5dB setps 62 | 63 | //Sine wave 64 | sine.amplitude(0.05); 65 | sine.frequency(500.0); 66 | 67 | Serial.println("Done"); 68 | } 69 | 70 | void loop(void) 71 | { 72 | // Nothing to do - just looping input to output 73 | delay(2000); 74 | Serial.println("Running..."); 75 | } 76 | -------------------------------------------------------------------------------- /Arduino/Teensy Time Domain Audio/Tympan_Expander_MultiBand/SerialManager.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _SerialManager_h 3 | #define _SerialManager_h 4 | 5 | //add in the algorithm whose gains we wish to set via this SerialManager 6 | #include "AudioEffectExpander.h" 7 | typedef AudioEffectExpander_F32 GainAlgorithm_t; 8 | 9 | //now, define the Serial Manager class 10 | class SerialManager { 11 | public: 12 | SerialManager(int n, GainAlgorithm_t *gain_algs) { 13 | N_CHAN = n; 14 | gain_algorithms = gain_algs; 15 | }; 16 | void respondToByte(char c); 17 | 18 | void printHelp(void); 19 | void incrementChannelGain(int chan, float change_dB); 20 | void decreaseChannelGain(int chan); 21 | 22 | float channelGainIncrement_dB = 2.5f; 23 | int N_CHAN; 24 | private: 25 | GainAlgorithm_t *gain_algorithms; //point to first element in array of expanders 26 | 27 | }; 28 | 29 | void SerialManager::printHelp(void) { 30 | Serial.println(); 31 | Serial.println("SerialManager Help: Available Commands:"); 32 | Serial.println(" h: Print this help"); 33 | Serial.println(" g: Print the gain settings of the device."); 34 | Serial.println(" C: Toggle printing of CPU and Memory usage"); 35 | Serial.println(" L: Toggle printing of pre-gain per-channel signal levels"); 36 | Serial.print(" k: Increase the gain of all channels (ie, knob gain) by "); Serial.print(channelGainIncrement_dB); Serial.println(" dB"); 37 | Serial.print(" K: Decrease the gain of all channels (ie, knob gain) by "); Serial.print(channelGainIncrement_dB); Serial.println(" dB"); 38 | Serial.print(" 1,2.3.4: Increase linear gain of given channel (1-4) by "); Serial.print(channelGainIncrement_dB); Serial.println(" dB"); 39 | Serial.print(" !,@,#,$: Decrease linear gain of given channel (1-4) by "); Serial.print(channelGainIncrement_dB); Serial.println(" dB"); 40 | Serial.println(); 41 | } 42 | 43 | //functions in the main sketch that I want to call from here 44 | extern void incrementKnobGain(float); 45 | extern void printGainSettings(void); 46 | extern void togglePrintMemroyAndCPU(void); 47 | extern void togglePrintAveSignalLevels(void); 48 | 49 | //switch yard to determine the desired action 50 | void SerialManager::respondToByte(char c) { 51 | switch (c) { 52 | case 'h': case '?': 53 | printHelp(); break; 54 | case 'g': case 'G': 55 | printGainSettings(); break; 56 | case 'k': 57 | incrementKnobGain(channelGainIncrement_dB); break; 58 | case 'K': //which is "shift k" 59 | incrementKnobGain(-channelGainIncrement_dB); break; 60 | case '1': 61 | incrementChannelGain(1-1, channelGainIncrement_dB); break; 62 | case '2': 63 | incrementChannelGain(2-1, channelGainIncrement_dB); break; 64 | case '3': 65 | incrementChannelGain(3-1, channelGainIncrement_dB); break; 66 | case '4': 67 | incrementChannelGain(4-1, channelGainIncrement_dB); break; 68 | case '!': //which is "shift 1" 69 | incrementChannelGain(1-1, -channelGainIncrement_dB); break; 70 | case '@': //which is "shift 2" 71 | incrementChannelGain(2-1, -channelGainIncrement_dB); break; 72 | case '#': //which is "shift 3" 73 | incrementChannelGain(3-1, -channelGainIncrement_dB); break; 74 | case '$': //which is "shift 4" 75 | incrementChannelGain(4-1, -channelGainIncrement_dB); break; 76 | case 'C': case 'c': 77 | Serial.println("Command Received: toggle printing of memory and CPU usage."); 78 | togglePrintMemroyAndCPU(); break; 79 | case 'L': case 'l': 80 | Serial.println("Command Received: toggle printing of per-band ave signal levels."); 81 | togglePrintAveSignalLevels(); break; 82 | } 83 | } 84 | 85 | void SerialManager::incrementChannelGain(int chan, float change_dB) { 86 | if (chan < N_CHAN) { 87 | gain_algorithms[chan].incrementGain_dB(change_dB); 88 | Serial.print("Incrementing gain on channel ");Serial.print(chan); 89 | Serial.print(" by "); Serial.print(change_dB); Serial.println(" dB"); 90 | printGainSettings(); //in main sketch file 91 | } 92 | } 93 | 94 | #endif 95 | 96 | -------------------------------------------------------------------------------- /Arduino/Teensy Tympan/Estimating CPU Time (WDRC).xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Arduino/Teensy Tympan/Estimating CPU Time (WDRC).xlsx -------------------------------------------------------------------------------- /Arduino/Teensy Tympan/StereoAudioToSD/plotSDTiming.m: -------------------------------------------------------------------------------- 1 | 2 | pname = ''; 3 | fname = 'example_serial_log.txt'; %filename 4 | sname = 'SD Card'; %name to use in the plots 5 | 6 | block_size_samp = 128; %audio block size of Tympan 7 | fs_Hz = 44177; %sample rate of Tympan 8 | 9 | %read the file 10 | disp(['Reading ' pname fname]); 11 | fid=fopen([pname fname],'r'); 12 | all_txt = textscan(fid,'%s','delimiter',{',' ' ' ':' '='}); 13 | all_txt = all_txt{1}; 14 | fclose(fid); 15 | 16 | %find SD timing entries 17 | I=find(strcmpi(all_txt(1:end-2),'SD') & strcmpi(all_txt(3:end),'us')); 18 | usec = str2num(strvcat(all_txt(I+3))); 19 | 20 | %find overrun flags 21 | I=find(strcmpi({all_txt{1:end-1}},'Overrun')); 22 | overrun1 = str2num(strvcat(all_txt(I+2))); 23 | overrun2 = str2num(strvcat(all_txt(I+4))); 24 | memory_usage = str2num(strvcat(all_txt(I+6))); 25 | memory_limit = str2num(strvcat(all_txt(I+8))); 26 | is2_no_memory = str2num(strvcat(all_txt(I+10))); 27 | is_overrun = overrun1 | overrun2 | is2_no_memory | (memory_usage >= memory_limit); 28 | 29 | %calculate timing parameters 30 | block_time_sec = block_size_samp/fs_Hz; 31 | block_rate_Hz = 1/block_time_sec; 32 | 33 | 34 | %% plots 35 | figure; 36 | try;setFigureTallWide;catch;end 37 | ax=[]; 38 | c=lines; 39 | all_stats=[];all_stats_usec=[];all_worst_usec=[]; 40 | Idata=1; 41 | 42 | n = length(usec); 43 | block_ID = [1:n]; 44 | t_sec = block_ID/block_rate_Hz; 45 | subplot(2,4,2:3); %top center 46 | semilogy(t_sec,usec/1000,'o-','linewidth',1,'markersize',3); 47 | lt={};lt{end+1}=sname; 48 | xlabel('Time (sec)'); 49 | ylabel({'Block Write Time';'(millisec)'}); 50 | title('Writing Audio to SD Card from Teensy 3.6'); 51 | ylim([1 200]);set(gca,'YTick',[1 10 100],'YTickLabels',{'1' '10' '100'}); 52 | 53 | if (1) 54 | %get 1 sec moving average 55 | lp_sec = 1.0; 56 | N=round(lp_sec*block_rate_Hz); 57 | b = 1/N*ones(N,1);a = 1; 58 | %[b,a]=butter(2,lp_Hz/(block_rate_Hz/2)); 59 | f_usec = filter(b,a,usec-usec(1))+usec(1); 60 | hold on; 61 | plot(t_sec,f_usec/1000,'-','linewidth',3); 62 | lt{end+1}=[num2str(lp_sec) ' sec Ave']; 63 | xlim([0 t_sec(end)]); 64 | hold off; 65 | ylim([0.5 200]); 66 | end 67 | if (1) 68 | I=find(is_overrun); 69 | foo_t_sec = t_sec(I);yl=ylim; 70 | hold on; 71 | plot(ones(2,1)*(foo_t_sec(:)'),yl(:)*ones(1,length(foo_t_sec)),'r:','linewidth',2); 72 | lt{end+1}='Overrun'; 73 | end 74 | 75 | legend(lt); 76 | hold on;plot(xlim,block_time_sec*1000*[1 1],'k--','linewidth',2); 77 | all_stats_usec(Idata,:) = [median(usec) mean(usec) xpercentile(usec,0.99) xpercentile(usec,0.999) max(usec)]; 78 | xl = xlim; x = xl(2)+0.05*diff(xl); 79 | yl = ylim; y = yl(2); 80 | text(x,y,{['Median = ' num2str(all_stats_usec(Idata,1)/1000,3) ' ms']; 81 | ['Mean = ' num2str(all_stats_usec(Idata,2)/1000,3) ' ms']; 82 | ['99th = ' num2str(all_stats_usec(Idata,3)/1000,3) ' ms']; 83 | ['99.9th = ' num2str(all_stats_usec(Idata,4)/1000,3) ' ms']; 84 | ['Max = ' num2str(all_stats_usec(Idata,5)/1000,3) ' ms']}, ... 85 | 'horizontalalignment','left','verticalalignment','top'); 86 | all_worst_usec(Idata) = max(usec); 87 | ax(end+1)=gca; 88 | 89 | % plot memory usage 90 | subplot(2,2,3); 91 | plot(t_sec,memory_usage,'o-','linewidth',1,'color',c(Idata,:),'markersize',3); 92 | xlabel('Time (sec)');ylabel('F32 Memory Usage'); 93 | xlim([0 t_sec(end)]); 94 | hold on; 95 | plot(t_sec,memory_limit,'k--','linewidth',2); 96 | hold off; 97 | yl=ylim; if (yl(2)==max(memory_limit));ylim([yl(1) 1.2*max(memory_limit)]); end; 98 | legend({'Used','Limit'}); 99 | title('Reported Use of Audio Memory'); 100 | ax(end+1)=gca; 101 | 102 | %plot other overrun flags 103 | subplot(2,2,4); 104 | plot(t_sec,[is2_no_memory(:) overrun1(:) overrun2(:) ],'o-','linewidth',1,'markersize',3); 105 | xlabel('Time (sec)');ylabel('Overrun Flag'); 106 | ylim([-0.25 2.25]); 107 | xlim([0 t_sec(end)]); 108 | legend({'I2S Input', 'Left Queue','Right Queue'}); 109 | hold on;plot(xlim,0.5*[1 1],'k--','linewidth',2);hold off 110 | title('Reported Overrun Flags'); 111 | ax(end+1)=gca; 112 | 113 | linkaxes(ax,'x'); 114 | 115 | 116 | -------------------------------------------------------------------------------- /Arduino/Teensy Tympan/StereoAudioToSD_SdFatLibrary/SDAudioWriter_SdFat.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | Chip Audette, OpenAudio, Mar 2018 4 | 5 | MIT License. Use at your own risk. 6 | */ 7 | 8 | #ifndef _SDAudioWriter_SdFAT 9 | #define _SDAudioWriter_SdFAT 10 | 11 | #include //originally from https://github.com/greiman/SdFat but class names have been modified to prevent collisions with Teensy Audio/SD libraries 12 | #include //for data types float32_t and int16_t and whatnot 13 | #include //for AUDIO_BLOCK_SAMPLES 14 | 15 | 16 | // Preallocate 40MB file. 17 | const uint64_t PRE_ALLOCATE_SIZE = 40ULL << 20; 18 | 19 | #define MAXFILE 100 20 | 21 | //char *header = 0; 22 | #define MAX_AUDIO_BUFF_LEN (2*AUDIO_BLOCK_SAMPLES) //Assume stereo (for the 2x). AUDIO_BLOCK_SAMPLES is from Audio_Stream.h, which should be max of Audio_Stream_F32 as well. 23 | 24 | class SDAudioWriter_SdFat 25 | { 26 | public: 27 | SDAudioWriter_SdFat() {}; 28 | ~SDAudioWriter_SdFat() { 29 | if (isFileOpen()) { 30 | close(); 31 | } 32 | } 33 | void setup(void) { 34 | init(); 35 | }; 36 | void init() { 37 | if (!sd.begin()) sd.errorHalt("sd.begin failed"); 38 | } 39 | //write two F32 channels as int16 40 | int writeF32AsInt16(float32_t *chan1, float32_t *chan2, int nsamps) { 41 | const int buffer_len = 2 * nsamps; //it'll be stereo, so 2*nsamps 42 | int count = 0; 43 | if (file.isOpen()) { 44 | for (int Isamp = 0; Isamp < nsamps; Isamp++) { 45 | //convert the F32 to Int16 and interleave 46 | write_buffer[count++] = (int16_t)(chan1[Isamp] * 32767.0); 47 | write_buffer[count++] = (int16_t)(chan2[Isamp] * 32767.0); 48 | } 49 | 50 | // write all audio bytes (512 bytes is most efficient) 51 | if (flagPrintElapsedWriteTime) usec = 0; 52 | file.write((byte *)write_buffer, buffer_len * sizeof(write_buffer[0])); 53 | if (flagPrintElapsedWriteTime) { 54 | Serial.print("SD, us="); Serial.println(usec); 55 | } 56 | } 57 | return 0; 58 | } 59 | 60 | bool open(char *fname) { 61 | if (sd.exists(fname)) { //maybe this isn't necessary when using the O_TRUNC flag below 62 | // The SD library writes new data to the end of the 63 | // file, so to start a new recording, the old file 64 | // must be deleted before new data is written. 65 | sd.remove(fname); 66 | } 67 | file.createContiguous(fname,PRE_ALLOCATE_SIZE); 68 | return isFileOpen(); 69 | } 70 | 71 | int close(void) { 72 | //file.truncate(); 73 | file.close(); 74 | return 0; 75 | } 76 | bool isFileOpen(void) { 77 | if (file.isOpen()) { 78 | return true; 79 | } else { 80 | return false; 81 | } 82 | } 83 | // char* makeFilename(char * filename) 84 | // { static int ifl = 0; 85 | // ifl++; 86 | // if (ifl > MAXFILE) return 0; 87 | // sprintf(filename, "File%04d.raw", ifl); 88 | // //Serial.println(filename); 89 | // return filename; 90 | // } 91 | 92 | void enablePrintElapsedWriteTime(void) { 93 | flagPrintElapsedWriteTime = true; 94 | } 95 | void disablePrintElapseWriteTime(void) { 96 | flagPrintElapsedWriteTime = false; 97 | } 98 | 99 | private: 100 | //SdFatSdio sd; //slower 101 | SdFatSdioEX sd; //faster 102 | SdFile_Gre file; 103 | int16_t write_buffer[MAX_AUDIO_BUFF_LEN]; 104 | boolean flagPrintElapsedWriteTime = false; 105 | elapsedMicros usec; 106 | 107 | }; 108 | 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /Arduino/Teensy Tympan/ToneGeneration_Serial_BT/SerialManager.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * SerialManager 4 | * 5 | * Created: Chip Audette, OpenAudio, April 2017 6 | * 7 | * Purpose: This class receives commands coming in over the serial link. 8 | * It allows the user to control the Tympan via text commands, such 9 | * as changing the volume or changing the filter cutoff. 10 | * 11 | */ 12 | 13 | 14 | #ifndef _SerialManager_h 15 | #define _SerialManager_h 16 | 17 | //now, define the Serial Manager class 18 | class SerialManager { 19 | public: 20 | SerialManager(Stream *_s) { s = _s; }; 21 | 22 | void respondToByte(char c); 23 | void printHelp(void); 24 | float gainIncrement_dB = 2.5f; 25 | float freqIncrementFactor = sqrt(2.0); //move half an octave with each step 26 | private: 27 | Stream *s = NULL; 28 | 29 | }; 30 | 31 | void SerialManager::printHelp(void) { 32 | s->println(); 33 | s->println("SerialManager Help: Available Commands:"); 34 | s->println(" h: Print this help"); 35 | // s->println(" g: Print the gain settings of the device."); 36 | s->println(" C: Toggle printing of CPU and Memory usage"); 37 | s->println(" s: Print the sinewave settings."); 38 | s->print(" k: Increase the volume by "); s->print(gainIncrement_dB); s->println(" dB"); 39 | s->print(" K: Decrease the volume by "); s->print(gainIncrement_dB); s->println(" dB"); 40 | s->println(" 1/!: Increment/Decrement frequency by 1000 Hz"); 41 | s->println(" 2/@: Increment/Decrement frequency by 100 Hz"); 42 | s->println(" 3/#: Increment/Decrement frequency by 10 Hz"); 43 | s->println(" 4/$: Increment/Decrement frequency by 1 Hz"); 44 | s->println(" 5/$: Increment/Decrement frequency by 0.1 Hz"); 45 | s->println(); 46 | } 47 | 48 | //functions in the main sketch that I want to call from here 49 | extern void incrementKnobGain(float); 50 | extern void incrementToneFrequency(float); 51 | extern void printGainSettings(void); 52 | extern void printSineSettings(void); 53 | extern void togglePrintMemoryAndCPU(void); 54 | 55 | //switch yard to determine the desired action 56 | void SerialManager::respondToByte(char c) { 57 | switch (c) { 58 | case 'h': case '?': 59 | printHelp(); break; 60 | case 's': case 'S': 61 | printSineSettings(); break; 62 | case 'C': case 'c': 63 | s->println("Command Received: toggle printing of memory and CPU usage."); 64 | togglePrintMemoryAndCPU(); break; 65 | case 'k': 66 | incrementKnobGain(gainIncrement_dB); break; 67 | case 'K': //which is "shift k" 68 | incrementKnobGain(-gainIncrement_dB); break; 69 | case '1': 70 | incrementToneFrequency(1000.f); break; 71 | case '!': 72 | incrementToneFrequency(-1000.f); break; 73 | case '2': 74 | incrementToneFrequency(100.f); break; 75 | case '@': 76 | incrementToneFrequency(-100.f); break; 77 | case '3': 78 | incrementToneFrequency(10.f); break; 79 | case '#': 80 | incrementToneFrequency(-10.f); break; 81 | case '4': 82 | incrementToneFrequency(1.f); break; 83 | case '$': 84 | incrementToneFrequency(-1.f); break; 85 | case '5': 86 | incrementToneFrequency(0.1f); break; 87 | case '%': 88 | incrementToneFrequency(-0.1f); break; 89 | } 90 | } 91 | 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /Arduino/Teensy Tympan/TrebleBoost_toSD_test/MyWriteAudioToSD.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _MyWriteAudioToSD_h 3 | #define _MyWriteAudioToSD_h 4 | 5 | #include 6 | //include 7 | //include 8 | #include 9 | //include 10 | #include 11 | 12 | class MyWriteAudioToSD { 13 | public: 14 | MyWriteAudioToSD() {}; 15 | ~MyWriteAudioToSD() { 16 | if (isFileOpen()) { close(); } 17 | } 18 | 19 | int setup(void) { 20 | if (!(SD.begin(chipSelect))) { 21 | // stop here if no SD card, but print a message 22 | while (1) { 23 | Serial.println("MyWriteAudioToSD: setup: Unable to access the SD card..."); 24 | delay(500); 25 | } 26 | } 27 | return 0; 28 | } 29 | 30 | bool open(char *fname) { 31 | if (SD.exists(fname)) { 32 | // The SD library writes new data to the end of the 33 | // file, so to start a new recording, the old file 34 | // must be deleted before new data is written. 35 | SD.remove(fname); 36 | } 37 | frec = SD.open(fname, FILE_WRITE); 38 | return isFileOpen(); 39 | } 40 | 41 | bool isFileOpen(void) { 42 | if (frec) { 43 | return true; 44 | } else { 45 | return false; 46 | } 47 | } 48 | 49 | //write two channels as int16 50 | int writeF32AsInt16(float32_t *chan1, float32_t *chan2, int nsamps) { 51 | const int buffer_len = 2*nsamps; //it'll be stereo, so 2*nsamps 52 | int16_t buffer[buffer_len]; 53 | int count=0; 54 | if (frec) { 55 | for (int Isamp=0; Isamp < nsamps; Isamp++) { 56 | //convert the F32 to Int16 and interleave 57 | buffer[count++] = (int16_t)(chan1[Isamp]*32767.0); 58 | buffer[count++] = (int16_t)(chan2[Isamp]*32767.0); 59 | } 60 | 61 | // write all audio bytes (512 bytes is most efficient) 62 | frec.write((byte *)buffer, buffer_len*sizeof(buffer[0])); 63 | } 64 | return 0; 65 | } 66 | 67 | //write two channels as int16 68 | int writeF32AsF32(float32_t *chan1, float32_t *chan2, int nsamps) { 69 | float32_t buffer[nsamps*2]; 70 | int count=0; 71 | if (frec) { 72 | for (int Isamp=0; Isamp < nsamps; Isamp++) { 73 | //interleave 74 | buffer[count++] = chan1[Isamp]; 75 | buffer[count++] = chan2[Isamp]; 76 | } 77 | 78 | // write all audio bytes (512 bytes is most efficient) 79 | frec.write((byte *)buffer, nsamps*sizeof(buffer[0])); 80 | } 81 | return 0; 82 | } 83 | 84 | int close(void) { 85 | frec.close(); 86 | return 0; 87 | } 88 | 89 | private: 90 | const int chipSelect = BUILTIN_SDCARD; //for Teensy 3.6 91 | File frec; //Create the file object for the SD card 92 | //int SD_mode = 0; // 0 is not recording, 1 is recording 93 | 94 | }; 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /Arduino/Teensy Tympan/TympanI2SMics/AudioEffectGain.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AudioEffectGain 3 | * 4 | * Created: Chip Audette, November 2016 5 | * Purpose; Apply digital gain to the audio data. 6 | * 7 | * This processes a single stream fo audio data (ie, it is mono) 8 | * 9 | * MIT License. use at your own risk. 10 | */ 11 | 12 | #ifndef _AudioEffectGain_h 13 | #define _AudioEffectGain_h 14 | 15 | #include //ARM DSP extensions. for speed! 16 | #include 17 | 18 | class AudioEffectGain : public AudioStream 19 | { 20 | //GUI: inputs:1, outputs:1 //this line used for automatic generation of GUI node 21 | public: 22 | //constructor 23 | AudioEffectGain(void) : AudioStream(1, inputQueueArray) {}; 24 | //AudioEffectGain(const AudioSettings_F32 &settings) : AudioStream_F32(1, inputQueueArray_f32) {}; 25 | 26 | //here's the method that does all the work 27 | void update(void) { 28 | //Serial.println("AudioEffectGain_F32: updating."); //for debugging. 29 | audio_block_t *block; 30 | block = AudioStream::receiveWritable(); 31 | if (!block) return; 32 | 33 | //apply the gain 34 | //for (int i = 0; i < AUDIO_BLOCK_SAMPLES; i++) block->data[i] = gain * (block->data[i]); //non DSP way to do it 35 | //arm_scale_f32(block->data, gain, block->data, block->length); //use ARM DSP for speed! 36 | float32_t val=0.0; 37 | const float32_t MAX_INT = (32678.0-1.0); 38 | for (int i=0; idata[i])/MAX_INT; 40 | val *= gain; 41 | block->data[i] = (int16_t)(max(min( (val * MAX_INT), MAX_INT), -MAX_INT)); 42 | } 43 | 44 | //transmit the block and be done 45 | AudioStream::transmit(block); 46 | AudioStream::release(block); 47 | } 48 | 49 | //methods to set parameters of this module 50 | float setGain(float g) { return gain = g;} 51 | float setGain_dB(float gain_dB) { 52 | float gain = pow(10.0, gain_dB / 20.0); 53 | setGain(gain); 54 | return getGain_dB(); 55 | } 56 | 57 | //increment the linear gain 58 | float incrementGain_dB(float increment_dB) { 59 | return setGain_dB(getGain_dB() + increment_dB); 60 | } 61 | 62 | //void setSampleRate_Hz(const float _fs_Hz) {}; //unused. included for interface compatability with fancier gain algorithms 63 | float getCurrentLevel_dB(void) { return 0.0; }; //meaningless. included for interface compatibility with fancier gain algorithms 64 | 65 | //methods to return information about this module 66 | float getGain(void) { return gain; } 67 | float getGain_dB(void) { return 20.0*log10(gain); } 68 | 69 | private: 70 | audio_block_t *inputQueueArray[1]; //memory pointer for the input to this module 71 | float gain = 1.0; //default value 72 | }; 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /Arduino/Teensy Tympan/TympanI2SMics/Tympan RevD3 w I2S Mics.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Arduino/Teensy Tympan/TympanI2SMics/Tympan RevD3 w I2S Mics.pptx -------------------------------------------------------------------------------- /Arduino/Teensy Tympan/TympanI2SMics/TympanI2SMics.ino/AudioEffectGain.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AudioEffectGain 3 | * 4 | * Created: Chip Audette, November 2016 5 | * Purpose; Apply digital gain to the audio data. 6 | * 7 | * This processes a single stream fo audio data (ie, it is mono) 8 | * 9 | * MIT License. use at your own risk. 10 | */ 11 | 12 | #ifndef _AudioEffectGain_h 13 | #define _AudioEffectGain_h 14 | 15 | #include //ARM DSP extensions. for speed! 16 | #include 17 | 18 | class AudioEffectGain : public AudioStream 19 | { 20 | //GUI: inputs:1, outputs:1 //this line used for automatic generation of GUI node 21 | public: 22 | //constructor 23 | AudioEffectGain(void) : AudioStream(1, inputQueueArray) {}; 24 | //AudioEffectGain(const AudioSettings_F32 &settings) : AudioStream_F32(1, inputQueueArray_f32) {}; 25 | 26 | //here's the method that does all the work 27 | void update(void) { 28 | //Serial.println("AudioEffectGain_F32: updating."); //for debugging. 29 | audio_block_t *block; 30 | block = AudioStream::receiveWritable(); 31 | if (!block) return; 32 | 33 | //apply the gain 34 | //for (int i = 0; i < AUDIO_BLOCK_SAMPLES; i++) block->data[i] = gain * (block->data[i]); //non DSP way to do it 35 | //arm_scale_f32(block->data, gain, block->data, block->length); //use ARM DSP for speed! 36 | float32_t val=0.0; 37 | const float32_t MAX_INT = (32678.0-1.0); 38 | for (int i=0; idata[i])/MAX_INT; 40 | val *= gain; 41 | block->data[i] = (int16_t)(max(min( (val * MAX_INT), MAX_INT), -MAX_INT)); 42 | } 43 | 44 | //transmit the block and be done 45 | AudioStream::transmit(block); 46 | AudioStream::release(block); 47 | } 48 | 49 | //methods to set parameters of this module 50 | float setGain(float g) { return gain = g;} 51 | float setGain_dB(float gain_dB) { 52 | float gain = pow(10.0, gain_dB / 20.0); 53 | setGain(gain); 54 | return getGain_dB(); 55 | } 56 | 57 | //increment the linear gain 58 | float incrementGain_dB(float increment_dB) { 59 | return setGain_dB(getGain_dB() + increment_dB); 60 | } 61 | 62 | //void setSampleRate_Hz(const float _fs_Hz) {}; //unused. included for interface compatability with fancier gain algorithms 63 | float getCurrentLevel_dB(void) { return 0.0; }; //meaningless. included for interface compatibility with fancier gain algorithms 64 | 65 | //methods to return information about this module 66 | float getGain(void) { return gain; } 67 | float getGain_dB(void) { return 20.0*log10(gain); } 68 | 69 | private: 70 | audio_block_t *inputQueueArray[1]; //memory pointer for the input to this module 71 | float gain = 1.0; //default value 72 | }; 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /Arduino/Teensy Tympan/TympanI2SMics/Typman RevC with 2nd AIC.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Arduino/Teensy Tympan/TympanI2SMics/Typman RevC with 2nd AIC.png -------------------------------------------------------------------------------- /Arduino/Teensy Tympan/TympanI2SMics/Typman RevC with 2nd AIC.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Arduino/Teensy Tympan/TympanI2SMics/Typman RevC with 2nd AIC.pptx -------------------------------------------------------------------------------- /Arduino/Teensy Tympan/TympanI2SMics/~$Tympan RevD3 w I2S Mics.pptx: -------------------------------------------------------------------------------- 1 | Chip Audette Chip Audette -------------------------------------------------------------------------------- /Arduino/Teensy Tympan/TympanI2SMicsQuad/AudioEffectGain.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AudioEffectGain 3 | * 4 | * Created: Chip Audette, November 2016 5 | * Purpose; Apply digital gain to the audio data. 6 | * 7 | * This processes a single stream fo audio data (ie, it is mono) 8 | * 9 | * MIT License. use at your own risk. 10 | */ 11 | 12 | #ifndef _AudioEffectGain_h 13 | #define _AudioEffectGain_h 14 | 15 | #include //ARM DSP extensions. for speed! 16 | #include 17 | 18 | class AudioEffectGain : public AudioStream 19 | { 20 | //GUI: inputs:1, outputs:1 //this line used for automatic generation of GUI node 21 | public: 22 | //constructor 23 | AudioEffectGain(void) : AudioStream(1, inputQueueArray) {}; 24 | //AudioEffectGain(const AudioSettings_F32 &settings) : AudioStream_F32(1, inputQueueArray_f32) {}; 25 | 26 | //here's the method that does all the work 27 | void update(void) { 28 | //Serial.println("AudioEffectGain_F32: updating."); //for debugging. 29 | audio_block_t *block; 30 | block = AudioStream::receiveWritable(); 31 | if (!block) return; 32 | 33 | //apply the gain 34 | //for (int i = 0; i < AUDIO_BLOCK_SAMPLES; i++) block->data[i] = gain * (block->data[i]); //non DSP way to do it 35 | //arm_scale_f32(block->data, gain, block->data, block->length); //use ARM DSP for speed! 36 | float32_t val=0.0; 37 | const float32_t MAX_INT = (32678.0-1.0); 38 | for (int i=0; idata[i])/MAX_INT; 40 | val *= gain; 41 | block->data[i] = (int16_t)(max(min( (val * MAX_INT), MAX_INT), -MAX_INT)); 42 | } 43 | 44 | //transmit the block and be done 45 | AudioStream::transmit(block); 46 | AudioStream::release(block); 47 | } 48 | 49 | //methods to set parameters of this module 50 | float setGain(float g) { return gain = g;} 51 | float setGain_dB(float gain_dB) { 52 | float gain = pow(10.0, gain_dB / 20.0); 53 | setGain(gain); 54 | return getGain_dB(); 55 | } 56 | 57 | //increment the linear gain 58 | float incrementGain_dB(float increment_dB) { 59 | return setGain_dB(getGain_dB() + increment_dB); 60 | } 61 | 62 | //void setSampleRate_Hz(const float _fs_Hz) {}; //unused. included for interface compatability with fancier gain algorithms 63 | float getCurrentLevel_dB(void) { return 0.0; }; //meaningless. included for interface compatibility with fancier gain algorithms 64 | 65 | //methods to return information about this module 66 | float getGain(void) { return gain; } 67 | float getGain_dB(void) { return 20.0*log10(gain); } 68 | 69 | private: 70 | audio_block_t *inputQueueArray[1]; //memory pointer for the input to this module 71 | float gain = 1.0; //default value 72 | }; 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /Arduino/Teensy Tympan/TympanPDMMics/AudioEffectGain.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AudioEffectGain 3 | * 4 | * Created: Chip Audette, November 2016 5 | * Purpose; Apply digital gain to the audio data. 6 | * 7 | * This processes a single stream fo audio data (ie, it is mono) 8 | * 9 | * MIT License. use at your own risk. 10 | */ 11 | 12 | #ifndef _AudioEffectGain_h 13 | #define _AudioEffectGain_h 14 | 15 | #include //ARM DSP extensions. for speed! 16 | #include 17 | 18 | class AudioEffectGain : public AudioStream 19 | { 20 | //GUI: inputs:1, outputs:1 //this line used for automatic generation of GUI node 21 | public: 22 | //constructor 23 | AudioEffectGain(void) : AudioStream(1, inputQueueArray) {}; 24 | //AudioEffectGain(const AudioSettings_F32 &settings) : AudioStream_F32(1, inputQueueArray_f32) {}; 25 | 26 | //here's the method that does all the work 27 | void update(void) { 28 | //Serial.println("AudioEffectGain_F32: updating."); //for debugging. 29 | audio_block_t *block; 30 | block = AudioStream::receiveWritable(); 31 | if (!block) return; 32 | 33 | //apply the gain 34 | //for (int i = 0; i < AUDIO_BLOCK_SAMPLES; i++) block->data[i] = gain * (block->data[i]); //non DSP way to do it 35 | //arm_scale_f32(block->data, gain, block->data, block->length); //use ARM DSP for speed! 36 | float32_t val=0.0; 37 | const float32_t MAX_INT = (32678.0-1.0); 38 | for (int i=0; idata[i])/MAX_INT; 40 | val *= gain; 41 | block->data[i] = (int16_t)(max(min( (val * MAX_INT), MAX_INT), -MAX_INT)); 42 | } 43 | 44 | //transmit the block and be done 45 | AudioStream::transmit(block); 46 | AudioStream::release(block); 47 | } 48 | 49 | //methods to set parameters of this module 50 | float setGain(float g) { return gain = g;} 51 | float setGain_dB(float gain_dB) { 52 | float gain = pow(10.0, gain_dB / 20.0); 53 | setGain(gain); 54 | return getGain_dB(); 55 | } 56 | 57 | //increment the linear gain 58 | float incrementGain_dB(float increment_dB) { 59 | return setGain_dB(getGain_dB() + increment_dB); 60 | } 61 | 62 | //void setSampleRate_Hz(const float _fs_Hz) {}; //unused. included for interface compatability with fancier gain algorithms 63 | float getCurrentLevel_dB(void) { return 0.0; }; //meaningless. included for interface compatibility with fancier gain algorithms 64 | 65 | //methods to return information about this module 66 | float getGain(void) { return gain; } 67 | float getGain_dB(void) { return 20.0*log10(gain); } 68 | 69 | private: 70 | audio_block_t *inputQueueArray[1]; //memory pointer for the input to this module 71 | float gain = 1.0; //default value 72 | }; 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /Arduino/Teensy Tympan/TympanPDMMics/Tympan RevD3 w I2S and PDM Mics.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Arduino/Teensy Tympan/TympanPDMMics/Tympan RevD3 w I2S and PDM Mics.pptx -------------------------------------------------------------------------------- /Arduino/Teensy Tympan/TympanQuad/Tympan RevD3 w I2S Mics.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Arduino/Teensy Tympan/TympanQuad/Tympan RevD3 w I2S Mics.pptx -------------------------------------------------------------------------------- /Arduino/Teensy Tympan/TympanQuad/Typman RevC with 2nd AIC.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Arduino/Teensy Tympan/TympanQuad/Typman RevC with 2nd AIC.png -------------------------------------------------------------------------------- /Arduino/Teensy Tympan/TympanQuad/Typman RevC with 2nd AIC.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Arduino/Teensy Tympan/TympanQuad/Typman RevC with 2nd AIC.pptx -------------------------------------------------------------------------------- /Hardware/Breadboard #1/2016-10 Teensy Breadboard Wiring.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Hardware/Breadboard #1/2016-10 Teensy Breadboard Wiring.pptx -------------------------------------------------------------------------------- /Hardware/Breadboard #2/2016-12-02 BB#2 for BTNRH.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Hardware/Breadboard #2/2016-12-02 BB#2 for BTNRH.pptx -------------------------------------------------------------------------------- /Hardware/Design Files/Tympan_RevA/7146-0013_Assembly_Top_Rev-A.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Hardware/Design Files/Tympan_RevA/7146-0013_Assembly_Top_Rev-A.pdf -------------------------------------------------------------------------------- /Hardware/Design Files/Tympan_RevA/ERRORS.txt: -------------------------------------------------------------------------------- 1 | 2017-03-04 2 | Chip Audette 3 | 4 | The Tympan Rev A board was built using the schematic and BOM in this directory. In using the hardware, though, we have discovered errors. We have either rewired the hardware to overcome the error, or modified the software to accomodate the error. In a future revision of the board, these issues should be fixed: 5 | 6 | *** ISSUE (1) *** 7 | 8 | Swap DIN and DOUT. The I2S data transfer lines between the Teensy and the AIC3206 codec need to be swapped. The Rev A schematic does not work. The correct connections should be: 9 | 10 | Teensy 3.6 pin 22 should connect to AIC3206 Pin 8. 11 | Teensy 3.6 pin 14 should connect to AIC3206 Pin 9 12 | 13 | 14 | *** ISSUE (2) *** 15 | 16 | The potentiometer is wired backwards. The potentiometer on Tympan Rev A does function, but turning it "up" results in lower values being read by the Teensy. The hardware design should be revised to swap the high and low pins on the pot. In other words, looking at the Typan Rev A schematic, the "CCW" end should be connected to "GND" while the "CW" end should be connected to 3.3V. 17 | 18 | 19 | *** ISSUE (3) *** 20 | 21 | The microphone input jack (J5) was inteneded to enable either a microphone input (with Tympan supplying the desired mic bias) or a line-level input. Because of the way that we brought the single "MICBIAS" line to the two inputs on the J5 jack, this design does not work well as a line-in. The problem is that the left and right channels of the line in become mixed via the connection through R10 and R15. So, for mono operation, the jack is acceptable as a line-in connection, but not for stereo operation. This portion of the circuit needs to be redesigned. A new design has not yet been decided. 22 | 23 | 24 | *** ISSUE (4) *** 25 | 26 | The Teensy cannot be reprogrammed reliably unless there is a battery attached. I assume that this is an issue with the power supply. I would have assumed that the power supplied over USB would have been more than sufficient to program the Teensy, but apparently there is some sort of transient that the system cannot support without the battery attached. The specific design flaw has not yet been identified, so a specific fix has not yet been recommended. Options include adding more capacitance or taking steps to reduce power draw (such as cutting off the Bluetooth module until needed). 27 | -------------------------------------------------------------------------------- /Hardware/Design Files/Tympan_RevA/Tympan_BOM_Rev-A.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Hardware/Design Files/Tympan_RevA/Tympan_BOM_Rev-A.pdf -------------------------------------------------------------------------------- /Hardware/Design Files/Tympan_RevA/Tympan_Sch_Rev-A.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Hardware/Design Files/Tympan_RevA/Tympan_Sch_Rev-A.pdf -------------------------------------------------------------------------------- /Hardware/Phantom Power 48V/1.2A High Voltage Boost Converter in 2x2mm2 QFN Package (Rev. D).url: -------------------------------------------------------------------------------- 1 | [InternetShortcut] 2 | URL=http://www.ti.com/lit/ds/symlink/tps61170.pdf 3 | -------------------------------------------------------------------------------- /Hardware/Phantom Power 48V/2017-12-18 Voltage Doubling.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Hardware/Phantom Power 48V/2017-12-18 Voltage Doubling.pptx -------------------------------------------------------------------------------- /Hardware/Phantom Power 48V/48V StepUp PCB/LT8330 StepUp PCB.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Hardware/Phantom Power 48V/48V StepUp PCB/LT8330 StepUp PCB.fzz -------------------------------------------------------------------------------- /Hardware/Phantom Power 48V/Solutions - LT8330 3V to 6V Input, 48V Boost Converter.url: -------------------------------------------------------------------------------- 1 | [InternetShortcut] 2 | URL=http://www.linear.com/solutions/5810 3 | -------------------------------------------------------------------------------- /Hardware/Phantom Power 48V/Solutions - LTC3872 High Efficiency 5V Input, 48V Output Boost Converter.url: -------------------------------------------------------------------------------- 1 | [InternetShortcut] 2 | URL=http://www.linear.com/solutions/4796 3 | -------------------------------------------------------------------------------- /Hardware/Phantom Power 48V/Voltage Multiplier and Voltage Doubler Circuit.url: -------------------------------------------------------------------------------- 1 | [InternetShortcut] 2 | URL=http://www.electronics-tutorials.ws/blog/voltage-multiplier-circuit.html 3 | -------------------------------------------------------------------------------- /Hardware/Phantom Power 48V/phantsch.gif (1118×920).url: -------------------------------------------------------------------------------- 1 | [InternetShortcut] 2 | URL=http://www.paia.com/prodimages/phantsch.gif 3 | -------------------------------------------------------------------------------- /Hardware/Tympan A Board/2017-02-10 Tympan A.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Hardware/Tympan A Board/2017-02-10 Tympan A.pptx -------------------------------------------------------------------------------- /Hardware/Tympan A Board/Creare Audio Board - Ideas.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Hardware/Tympan A Board/Creare Audio Board - Ideas.pptx -------------------------------------------------------------------------------- /Hardware/Tympan A Board/Creare Mockup-small.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Hardware/Tympan A Board/Creare Mockup-small.JPG -------------------------------------------------------------------------------- /Hardware/Tympan A Board/Creare Notional Layout 2016-12-06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Hardware/Tympan A Board/Creare Notional Layout 2016-12-06.png -------------------------------------------------------------------------------- /Hardware/Tympan A Board/Notional Layout of Creare Audio Board.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Hardware/Tympan A Board/Notional Layout of Creare Audio Board.pptx -------------------------------------------------------------------------------- /Hardware/Tympan A Board/Old/Creare Notional Layout 2016-12-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Hardware/Tympan A Board/Old/Creare Notional Layout 2016-12-01.png -------------------------------------------------------------------------------- /Hardware/Tympan A Board/Old/Creare Notional Layout 2016-12-05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Hardware/Tympan A Board/Old/Creare Notional Layout 2016-12-05.png -------------------------------------------------------------------------------- /Hardware/Tympan A Board/Tympan Packaging.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Hardware/Tympan A Board/Tympan Packaging.pptx -------------------------------------------------------------------------------- /Hardware/Tympan A Board/Tympan Silk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Hardware/Tympan A Board/Tympan Silk.png -------------------------------------------------------------------------------- /Hardware/Tympan A Board/Typan Silk.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Hardware/Tympan A Board/Typan Silk.pdf -------------------------------------------------------------------------------- /Hardware/Tympan E (Notional)/2018-03-01 Tympan Mini.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Hardware/Tympan E (Notional)/2018-03-01 Tympan Mini.pptx -------------------------------------------------------------------------------- /Hardware/Tympan E (Notional)/Old/2017-12-13 Tympan Mini.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Hardware/Tympan E (Notional)/Old/2017-12-13 Tympan Mini.pptx -------------------------------------------------------------------------------- /Hardware/Tympan E (Notional)/Old/2018-01-17 Tympan Mini.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Hardware/Tympan E (Notional)/Old/2018-01-17 Tympan Mini.pptx -------------------------------------------------------------------------------- /Hardware/Tympan Mic Bias Config.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipaudette/OpenAudio/63208f4f3a93bc231dd2b07a251c456ca7d30678/Hardware/Tympan Mic Bias Config.pptx -------------------------------------------------------------------------------- /Kinetis Design Studio/Audio Processing Benchmarking/FIR_FFT_Benchmarking/CMSIS/Include/arm_const_structs.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 19. March 2015 5 | * $Revision: V.1.4.5 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_const_structs.h 9 | * 10 | * Description: This file has constant structs that are initialized for 11 | * user convenience. For example, some can be given as 12 | * arguments to the arm_cfft_f32() function. 13 | * 14 | * Target Processor: Cortex-M4/Cortex-M3 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions 18 | * are met: 19 | * - Redistributions of source code must retain the above copyright 20 | * notice, this list of conditions and the following disclaimer. 21 | * - Redistributions in binary form must reproduce the above copyright 22 | * notice, this list of conditions and the following disclaimer in 23 | * the documentation and/or other materials provided with the 24 | * distribution. 25 | * - Neither the name of ARM LIMITED nor the names of its contributors 26 | * may be used to endorse or promote products derived from this 27 | * software without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 30 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 31 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 32 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 33 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 34 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 35 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 37 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 38 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 39 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 40 | * POSSIBILITY OF SUCH DAMAGE. 41 | * -------------------------------------------------------------------- */ 42 | 43 | #ifndef _ARM_CONST_STRUCTS_H 44 | #define _ARM_CONST_STRUCTS_H 45 | 46 | #include "arm_math.h" 47 | #include "arm_common_tables.h" 48 | 49 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len16; 50 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len32; 51 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len64; 52 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len128; 53 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len256; 54 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len512; 55 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024; 56 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048; 57 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096; 58 | 59 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len16; 60 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len32; 61 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len64; 62 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len128; 63 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len256; 64 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len512; 65 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len1024; 66 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len2048; 67 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len4096; 68 | 69 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len16; 70 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len32; 71 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len64; 72 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len128; 73 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len256; 74 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len512; 75 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len1024; 76 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len2048; 77 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len4096; 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /Kinetis Design Studio/Audio Processing Benchmarking/FIR_FFT_Benchmarking/CMSIS/Include/core_cmFunc.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmFunc.h 3 | * @brief CMSIS Cortex-M Core Function Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMFUNC_H 42 | #define __CORE_CMFUNC_H 43 | 44 | 45 | /* ########################### Core Function Access ########################### */ 46 | /** \ingroup CMSIS_Core_FunctionInterface 47 | \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@} end of CMSIS_Core_RegAccFunctions */ 86 | 87 | #endif /* __CORE_CMFUNC_H */ 88 | -------------------------------------------------------------------------------- /Kinetis Design Studio/Audio Processing Benchmarking/FIR_FFT_Benchmarking/CMSIS/Include/core_cmInstr.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmInstr.h 3 | * @brief CMSIS Cortex-M Core Instruction Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMINSTR_H 42 | #define __CORE_CMINSTR_H 43 | 44 | 45 | /* ########################## Core Instruction Access ######################### */ 46 | /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface 47 | Access to dedicated instructions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@}*/ /* end of group CMSIS_Core_InstructionInterface */ 86 | 87 | #endif /* __CORE_CMINSTR_H */ 88 | -------------------------------------------------------------------------------- /Kinetis Design Studio/Audio Processing Benchmarking/FIR_FFT_Benchmarking/CMSIS/Include/core_cmSimd.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmSimd.h 3 | * @brief CMSIS Cortex-M SIMD Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMSIMD_H 42 | #define __CORE_CMSIMD_H 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | 49 | /* ################### Compiler specific Intrinsics ########################### */ 50 | /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics 51 | Access to dedicated SIMD instructions 52 | @{ 53 | */ 54 | 55 | /*------------------ RealView Compiler -----------------*/ 56 | #if defined ( __CC_ARM ) 57 | #include "cmsis_armcc.h" 58 | 59 | /*------------------ ARM Compiler V6 -------------------*/ 60 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 61 | #include "cmsis_armcc_V6.h" 62 | 63 | /*------------------ GNU Compiler ----------------------*/ 64 | #elif defined ( __GNUC__ ) 65 | #include "cmsis_gcc.h" 66 | 67 | /*------------------ ICC Compiler ----------------------*/ 68 | #elif defined ( __ICCARM__ ) 69 | #include 70 | 71 | /*------------------ TI CCS Compiler -------------------*/ 72 | #elif defined ( __TMS470__ ) 73 | #include 74 | 75 | /*------------------ TASKING Compiler ------------------*/ 76 | #elif defined ( __TASKING__ ) 77 | /* 78 | * The CMSIS functions have been implemented as intrinsics in the compiler. 79 | * Please use "carm -?i" to get an up to date list of all intrinsics, 80 | * Including the CMSIS ones. 81 | */ 82 | 83 | /*------------------ COSMIC Compiler -------------------*/ 84 | #elif defined ( __CSMC__ ) 85 | #include 86 | 87 | #endif 88 | 89 | /*@} end of group CMSIS_SIMD_intrinsics */ 90 | 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /* __CORE_CMSIMD_H */ 97 | -------------------------------------------------------------------------------- /Kinetis Design Studio/Audio Processing Benchmarking/FIR_FFT_Benchmarking/board.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Freescale Semiconductor, Inc. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * o Redistributions of source code must retain the above copyright notice, this list 9 | * of conditions and the following disclaimer. 10 | * 11 | * o Redistributions in binary form must reproduce the above copyright notice, this 12 | * list of conditions and the following disclaimer in the documentation and/or 13 | * other materials provided with the distribution. 14 | * 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from this 17 | * software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include 32 | #include "fsl_device_registers.h" 33 | #include "board.h" 34 | #include "fsl_debug_console.h" 35 | 36 | /******************************************************************************* 37 | * Variables 38 | ******************************************************************************/ 39 | 40 | /******************************************************************************* 41 | * Code 42 | ******************************************************************************/ 43 | 44 | /* Initialize debug console. */ 45 | void BOARD_InitDebugConsole(void) 46 | { 47 | uint32_t uartClkSrcFreq = BOARD_DEBUG_UART_CLK_FREQ; 48 | DbgConsole_Init(BOARD_DEBUG_UART_BASEADDR, BOARD_DEBUG_UART_BAUDRATE, BOARD_DEBUG_UART_TYPE, uartClkSrcFreq); 49 | } 50 | -------------------------------------------------------------------------------- /Kinetis Design Studio/Audio Processing Benchmarking/FIR_FFT_Benchmarking/clock_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Freescale Semiconductor, Inc. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * o Redistributions of source code must retain the above copyright notice, this list 9 | * of conditions and the following disclaimer. 10 | * 11 | * o Redistributions in binary form must reproduce the above copyright notice, this 12 | * list of conditions and the following disclaimer in the documentation and/or 13 | * other materials provided with the distribution. 14 | * 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from this 17 | * software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef _CLOCK_CONFIG_H_ 31 | #define _CLOCK_CONFIG_H_ 32 | 33 | /******************************************************************************* 34 | * DEFINITION 35 | ******************************************************************************/ 36 | #define BOARD_XTAL0_CLK_HZ 12000000U 37 | #define BOARD_XTAL32K_CLK_HZ 32768U 38 | 39 | /******************************************************************************* 40 | * API 41 | ******************************************************************************/ 42 | #if defined(__cplusplus) 43 | extern "C" { 44 | #endif /* __cplusplus*/ 45 | 46 | void BOARD_BootClockVLPR(void); 47 | void BOARD_BootClockRUN(void); 48 | void BOARD_BootClockHSRUN(void); 49 | 50 | #if defined(__cplusplus) 51 | } 52 | #endif /* __cplusplus*/ 53 | 54 | #endif /* _CLOCK_CONFIG_H_ */ 55 | -------------------------------------------------------------------------------- /Kinetis Design Studio/Audio Processing Benchmarking/FIR_FFT_Benchmarking/devices/MK66F18/drivers/fsl_common.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Freescale Semiconductor, Inc. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * o Redistributions of source code must retain the above copyright notice, this list 9 | * of conditions and the following disclaimer. 10 | * 11 | * o Redistributions in binary form must reproduce the above copyright notice, this 12 | * list of conditions and the following disclaimer in the documentation and/or 13 | * other materials provided with the distribution. 14 | * 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from this 17 | * software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include "fsl_common.h" 32 | #include "fsl_debug_console.h" 33 | 34 | #ifndef NDEBUG 35 | #if (defined(__CC_ARM)) || (defined(__ICCARM__)) 36 | void __aeabi_assert(const char *failedExpr, const char *file, int line) 37 | { 38 | PRINTF("ASSERT ERROR \" %s \": file \"%s\" Line \"%d\" \n", failedExpr, file, line); 39 | for (;;) 40 | { 41 | __asm("bkpt #0"); 42 | } 43 | } 44 | #elif(defined(__GNUC__)) 45 | void __assert_func(const char *file, int line, const char *func, const char *failedExpr) 46 | { 47 | PRINTF("ASSERT ERROR \" %s \": file \"%s\" Line \"%d\" function name \"%s\" \n", failedExpr, file, line, func); 48 | for (;;) 49 | { 50 | __asm("bkpt #0"); 51 | } 52 | } 53 | #endif /* (defined(__CC_ARM)) || (defined (__ICCARM__)) */ 54 | #endif /* NDEBUG */ 55 | 56 | void InstallIRQHandler(IRQn_Type irq, uint32_t irqHandler) 57 | { 58 | /* Addresses for VECTOR_TABLE and VECTOR_RAM come from the linker file */ 59 | #if defined(__CC_ARM) 60 | extern uint32_t Image$$VECTOR_ROM$$Base[]; 61 | extern uint32_t Image$$VECTOR_RAM$$Base[]; 62 | extern uint32_t Image$$RW_m_data$$Base[]; 63 | 64 | #define __VECTOR_TABLE Image$$VECTOR_ROM$$Base 65 | #define __VECTOR_RAM Image$$VECTOR_RAM$$Base 66 | #define __RAM_VECTOR_TABLE_SIZE (((uint32_t)Image$$RW_m_data$$Base - (uint32_t)Image$$VECTOR_RAM$$Base)) 67 | #elif defined(__ICCARM__) 68 | extern uint32_t __RAM_VECTOR_TABLE_SIZE[]; 69 | extern uint32_t __VECTOR_TABLE[]; 70 | extern uint32_t __VECTOR_RAM[]; 71 | #elif defined(__GNUC__) 72 | extern uint32_t __VECTOR_TABLE[]; 73 | extern uint32_t __VECTOR_RAM[]; 74 | extern uint32_t __RAM_VECTOR_TABLE_SIZE_BYTES[]; 75 | uint32_t __RAM_VECTOR_TABLE_SIZE = (uint32_t)(__RAM_VECTOR_TABLE_SIZE_BYTES); 76 | #endif /* defined(__CC_ARM) */ 77 | uint32_t n; 78 | 79 | __disable_irq(); 80 | if (SCB->VTOR != (uint32_t)__VECTOR_RAM) 81 | { 82 | /* Copy the vector table from ROM to RAM */ 83 | for (n = 0; n < ((uint32_t)__RAM_VECTOR_TABLE_SIZE) / sizeof(uint32_t); n++) 84 | { 85 | __VECTOR_RAM[n] = __VECTOR_TABLE[n]; 86 | } 87 | /* Point the VTOR to the position of vector table */ 88 | SCB->VTOR = (uint32_t)__VECTOR_RAM; 89 | } 90 | 91 | /* make sure the __VECTOR_RAM is noncachable */ 92 | __VECTOR_RAM[irq + 16] = irqHandler; 93 | 94 | __enable_irq(); 95 | } 96 | -------------------------------------------------------------------------------- /Kinetis Design Studio/Audio Processing Benchmarking/FIR_FFT_Benchmarking/devices/MK66F18/drivers/fsl_dmamux.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Freescale Semiconductor, Inc. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * o Redistributions of source code must retain the above copyright notice, this list 9 | * of conditions and the following disclaimer. 10 | * 11 | * o Redistributions in binary form must reproduce the above copyright notice, this 12 | * list of conditions and the following disclaimer in the documentation and/or 13 | * other materials provided with the distribution. 14 | * 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from this 17 | * software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include "fsl_dmamux.h" 32 | 33 | /******************************************************************************* 34 | * Definitions 35 | ******************************************************************************/ 36 | 37 | /******************************************************************************* 38 | * Prototypes 39 | ******************************************************************************/ 40 | 41 | /*! 42 | * @brief Get instance number for DMAMUX. 43 | * 44 | * @param base DMAMUX peripheral base address. 45 | */ 46 | static uint32_t DMAMUX_GetInstance(DMAMUX_Type *base); 47 | 48 | /******************************************************************************* 49 | * Variables 50 | ******************************************************************************/ 51 | 52 | /*! @brief Array to map DMAMUX instance number to base pointer. */ 53 | static DMAMUX_Type *const s_dmamuxBases[] = DMAMUX_BASE_PTRS; 54 | 55 | /*! @brief Array to map DMAMUX instance number to clock name. */ 56 | static const clock_ip_name_t s_dmamuxClockName[] = DMAMUX_CLOCKS; 57 | 58 | /******************************************************************************* 59 | * Code 60 | ******************************************************************************/ 61 | static uint32_t DMAMUX_GetInstance(DMAMUX_Type *base) 62 | { 63 | uint32_t instance; 64 | 65 | /* Find the instance index from base address mappings. */ 66 | for (instance = 0; instance < FSL_FEATURE_SOC_DMAMUX_COUNT; instance++) 67 | { 68 | if (s_dmamuxBases[instance] == base) 69 | { 70 | break; 71 | } 72 | } 73 | 74 | assert(instance < FSL_FEATURE_SOC_DMAMUX_COUNT); 75 | 76 | return instance; 77 | } 78 | 79 | void DMAMUX_Init(DMAMUX_Type *base) 80 | { 81 | CLOCK_EnableClock(s_dmamuxClockName[DMAMUX_GetInstance(base)]); 82 | } 83 | 84 | void DMAMUX_Deinit(DMAMUX_Type *base) 85 | { 86 | CLOCK_DisableClock(s_dmamuxClockName[DMAMUX_GetInstance(base)]); 87 | } 88 | -------------------------------------------------------------------------------- /Kinetis Design Studio/Audio Processing Benchmarking/FIR_FFT_Benchmarking/devices/MK66F18/drivers/fsl_ewm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Freescale Semiconductor, Inc. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * o Redistributions of source code must retain the above copyright notice, this list 9 | * of conditions and the following disclaimer. 10 | * 11 | * o Redistributions in binary form must reproduce the above copyright notice, this 12 | * list of conditions and the following disclaimer in the documentation and/or 13 | * other materials provided with the distribution. 14 | * 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from this 17 | * software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include "fsl_ewm.h" 32 | 33 | /******************************************************************************* 34 | * Code 35 | ******************************************************************************/ 36 | 37 | void EWM_Init(EWM_Type *base, const ewm_config_t *config) 38 | { 39 | assert(config); 40 | 41 | uint32_t value = 0U; 42 | 43 | CLOCK_EnableClock(kCLOCK_Ewm0); 44 | value = EWM_CTRL_EWMEN(config->enableEwm) | EWM_CTRL_ASSIN(config->setInputAssertLogic) | 45 | EWM_CTRL_INEN(config->enableEwmInput) | EWM_CTRL_INTEN(config->enableInterrupt); 46 | #if defined(FSL_FEATURE_EWM_HAS_PRESCALER) && FSL_FEATURE_EWM_HAS_PRESCALER 47 | base->CLKPRESCALER = config->prescaler; 48 | #endif /* FSL_FEATURE_EWM_HAS_PRESCALER */ 49 | 50 | #if defined(FSL_FEATURE_EWM_HAS_CLOCK_SELECT) && FSL_FEATURE_EWM_HAS_CLOCK_SELECT 51 | base->CLKCTRL = config->clockSource; 52 | #endif /* FSL_FEATURE_EWM_HAS_CLOCK_SELECT*/ 53 | 54 | base->CMPL = config->compareLowValue; 55 | base->CMPH = config->compareHighValue; 56 | base->CTRL = value; 57 | } 58 | 59 | void EWM_Deinit(EWM_Type *base) 60 | { 61 | EWM_DisableInterrupts(base, kEWM_InterruptEnable); 62 | CLOCK_DisableClock(kCLOCK_Ewm0); 63 | } 64 | 65 | void EWM_GetDefaultConfig(ewm_config_t *config) 66 | { 67 | assert(config); 68 | 69 | config->enableEwm = true; 70 | config->enableEwmInput = false; 71 | config->setInputAssertLogic = false; 72 | config->enableInterrupt = false; 73 | #if defined(FSL_FEATURE_EWM_HAS_CLOCK_SELECT) && FSL_FEATURE_EWM_HAS_CLOCK_SELECT 74 | config->clockSource = kEWM_LpoClockSource0; 75 | #endif /* FSL_FEATURE_EWM_HAS_CLOCK_SELECT*/ 76 | #if defined(FSL_FEATURE_EWM_HAS_PRESCALER) && FSL_FEATURE_EWM_HAS_PRESCALER 77 | config->prescaler = 0U; 78 | #endif /* FSL_FEATURE_EWM_HAS_PRESCALER */ 79 | config->compareLowValue = 0U; 80 | config->compareHighValue = 0xFEU; 81 | } 82 | 83 | void EWM_Refresh(EWM_Type *base) 84 | { 85 | uint32_t primaskValue = 0U; 86 | 87 | /* Disable the global interrupt to protect refresh sequence */ 88 | primaskValue = DisableGlobalIRQ(); 89 | base->SERV = (uint8_t)0xB4U; 90 | base->SERV = (uint8_t)0x2CU; 91 | EnableGlobalIRQ(primaskValue); 92 | } 93 | -------------------------------------------------------------------------------- /Kinetis Design Studio/Audio Processing Benchmarking/FIR_FFT_Benchmarking/devices/MK66F18/drivers/fsl_pit.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Freescale Semiconductor, Inc. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * o Redistributions of source code must retain the above copyright notice, this list 9 | * of conditions and the following disclaimer. 10 | * 11 | * o Redistributions in binary form must reproduce the above copyright notice, this 12 | * list of conditions and the following disclaimer in the documentation and/or 13 | * other materials provided with the distribution. 14 | * 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from this 17 | * software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include "fsl_pit.h" 32 | 33 | /******************************************************************************* 34 | * Prototypes 35 | ******************************************************************************/ 36 | /*! 37 | * @brief Gets the instance from the base address to be used to gate or ungate the module clock 38 | * 39 | * @param base PIT peripheral base address 40 | * 41 | * @return The PIT instance 42 | */ 43 | static uint32_t PIT_GetInstance(PIT_Type *base); 44 | 45 | /******************************************************************************* 46 | * Variables 47 | ******************************************************************************/ 48 | /*! @brief Pointers to PIT bases for each instance. */ 49 | static PIT_Type *const s_pitBases[] = PIT_BASE_PTRS; 50 | 51 | /*! @brief Pointers to PIT clocks for each instance. */ 52 | static const clock_ip_name_t s_pitClocks[] = PIT_CLOCKS; 53 | 54 | /******************************************************************************* 55 | * Code 56 | ******************************************************************************/ 57 | static uint32_t PIT_GetInstance(PIT_Type *base) 58 | { 59 | uint32_t instance; 60 | 61 | /* Find the instance index from base address mappings. */ 62 | for (instance = 0; instance < FSL_FEATURE_SOC_PIT_COUNT; instance++) 63 | { 64 | if (s_pitBases[instance] == base) 65 | { 66 | break; 67 | } 68 | } 69 | 70 | assert(instance < FSL_FEATURE_SOC_PIT_COUNT); 71 | 72 | return instance; 73 | } 74 | 75 | void PIT_Init(PIT_Type *base, const pit_config_t *config) 76 | { 77 | assert(config); 78 | 79 | /* Ungate the PIT clock*/ 80 | CLOCK_EnableClock(s_pitClocks[PIT_GetInstance(base)]); 81 | 82 | /* Enable PIT timers */ 83 | base->MCR &= ~PIT_MCR_MDIS_MASK; 84 | 85 | /* Config timer operation when in debug mode */ 86 | if (config->enableRunInDebug) 87 | { 88 | base->MCR &= ~PIT_MCR_FRZ_MASK; 89 | } 90 | else 91 | { 92 | base->MCR |= PIT_MCR_FRZ_MASK; 93 | } 94 | } 95 | 96 | void PIT_Deinit(PIT_Type *base) 97 | { 98 | /* Disable PIT timers */ 99 | base->MCR |= PIT_MCR_MDIS_MASK; 100 | 101 | /* Gate the PIT clock*/ 102 | CLOCK_DisableClock(s_pitClocks[PIT_GetInstance(base)]); 103 | } 104 | 105 | #if defined(FSL_FEATURE_PIT_HAS_LIFETIME_TIMER) && FSL_FEATURE_PIT_HAS_LIFETIME_TIMER 106 | 107 | uint64_t PIT_GetLifetimeTimerCount(PIT_Type *base) 108 | { 109 | uint32_t valueH = 0U; 110 | uint32_t valueL = 0U; 111 | 112 | /* LTMR64H should be read before LTMR64L */ 113 | valueH = base->LTMR64H; 114 | valueL = base->LTMR64L; 115 | 116 | return (((uint64_t)valueH << 32U) + (uint64_t)(valueL)); 117 | } 118 | 119 | #endif /* FSL_FEATURE_PIT_HAS_LIFETIME_TIMER */ 120 | -------------------------------------------------------------------------------- /Kinetis Design Studio/Audio Processing Benchmarking/FIR_FFT_Benchmarking/devices/MK66F18/drivers/fsl_pmc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Freescale Semiconductor, Inc. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * o Redistributions of source code must retain the above copyright notice, this list 9 | * of conditions and the following disclaimer. 10 | * 11 | * o Redistributions in binary form must reproduce the above copyright notice, this 12 | * list of conditions and the following disclaimer in the documentation and/or 13 | * other materials provided with the distribution. 14 | * 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from this 17 | * software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #include "fsl_pmc.h" 31 | 32 | #if (defined(FSL_FEATURE_PMC_HAS_PARAM) && FSL_FEATURE_PMC_HAS_PARAM) 33 | void PMC_GetParam(PMC_Type *base, pmc_param_t *param) 34 | { 35 | uint32_t reg = base->PARAM; 36 | ; 37 | param->vlpoEnable = (bool)(reg & PMC_PARAM_VLPOE_MASK); 38 | param->hvdEnable = (bool)(reg & PMC_PARAM_HVDE_MASK); 39 | } 40 | #endif /* FSL_FEATURE_PMC_HAS_PARAM */ 41 | 42 | void PMC_ConfigureLowVoltDetect(PMC_Type *base, const pmc_low_volt_detect_config_t *config) 43 | { 44 | base->LVDSC1 = (0U | 45 | #if (defined(FSL_FEATURE_PMC_HAS_LVDV) && FSL_FEATURE_PMC_HAS_LVDV) 46 | ((uint32_t)config->voltSelect << PMC_LVDSC1_LVDV_SHIFT) | 47 | #endif 48 | ((uint32_t)config->enableInt << PMC_LVDSC1_LVDIE_SHIFT) | 49 | ((uint32_t)config->enableReset << PMC_LVDSC1_LVDRE_SHIFT) 50 | /* Clear the Low Voltage Detect Flag with previouse power detect setting */ 51 | | PMC_LVDSC1_LVDACK_MASK); 52 | } 53 | 54 | void PMC_ConfigureLowVoltWarning(PMC_Type *base, const pmc_low_volt_warning_config_t *config) 55 | { 56 | base->LVDSC2 = (0U | 57 | #if (defined(FSL_FEATURE_PMC_HAS_LVWV) && FSL_FEATURE_PMC_HAS_LVWV) 58 | ((uint32_t)config->voltSelect << PMC_LVDSC2_LVWV_SHIFT) | 59 | #endif 60 | ((uint32_t)config->enableInt << PMC_LVDSC2_LVWIE_SHIFT) 61 | /* Clear the Low Voltage Warning Flag with previouse power detect setting */ 62 | | PMC_LVDSC2_LVWACK_MASK); 63 | } 64 | 65 | #if (defined(FSL_FEATURE_PMC_HAS_HVDSC1) && FSL_FEATURE_PMC_HAS_HVDSC1) 66 | void PMC_ConfigureHighVoltDetect(PMC_Type *base, const pmc_high_volt_detect_config_t *config) 67 | { 68 | base->HVDSC1 = (((uint32_t)config->voltSelect << PMC_HVDSC1_HVDV_SHIFT) | 69 | ((uint32_t)config->enableInt << PMC_HVDSC1_HVDIE_SHIFT) | 70 | ((uint32_t)config->enableReset << PMC_HVDSC1_HVDRE_SHIFT) 71 | /* Clear the High Voltage Detect Flag with previouse power detect setting */ 72 | | PMC_HVDSC1_HVDACK_MASK); 73 | } 74 | #endif /* FSL_FEATURE_PMC_HAS_HVDSC1 */ 75 | 76 | #if ((defined(FSL_FEATURE_PMC_HAS_BGBE) && FSL_FEATURE_PMC_HAS_BGBE) || \ 77 | (defined(FSL_FEATURE_PMC_HAS_BGEN) && FSL_FEATURE_PMC_HAS_BGEN) || \ 78 | (defined(FSL_FEATURE_PMC_HAS_BGBDS) && FSL_FEATURE_PMC_HAS_BGBDS)) 79 | void PMC_ConfigureBandgapBuffer(PMC_Type *base, const pmc_bandgap_buffer_config_t *config) 80 | { 81 | base->REGSC = (0U 82 | #if (defined(FSL_FEATURE_PMC_HAS_BGBE) && FSL_FEATURE_PMC_HAS_BGBE) 83 | | ((uint32_t)config->enable << PMC_REGSC_BGBE_SHIFT) 84 | #endif /* FSL_FEATURE_PMC_HAS_BGBE */ 85 | #if (defined(FSL_FEATURE_PMC_HAS_BGEN) && FSL_FEATURE_PMC_HAS_BGEN) 86 | | (((uint32_t)config->enableInLowPowerMode << PMC_REGSC_BGEN_SHIFT)) 87 | #endif /* FSL_FEATURE_PMC_HAS_BGEN */ 88 | #if (defined(FSL_FEATURE_PMC_HAS_BGBDS) && FSL_FEATURE_PMC_HAS_BGBDS) 89 | | ((uint32_t)config->drive << PMC_REGSC_BGBDS_SHIFT) 90 | #endif /* FSL_FEATURE_PMC_HAS_BGBDS */ 91 | ); 92 | } 93 | #endif 94 | -------------------------------------------------------------------------------- /Kinetis Design Studio/Audio Processing Benchmarking/FIR_FFT_Benchmarking/devices/MK66F18/drivers/fsl_rcm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Freescale Semiconductor, Inc. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * o Redistributions of source code must retain the above copyright notice, this list 9 | * of conditions and the following disclaimer. 10 | * 11 | * o Redistributions in binary form must reproduce the above copyright notice, this 12 | * list of conditions and the following disclaimer in the documentation and/or 13 | * other materials provided with the distribution. 14 | * 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from this 17 | * software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include "fsl_rcm.h" 32 | 33 | void RCM_ConfigureResetPinFilter(RCM_Type *base, const rcm_reset_pin_filter_config_t *config) 34 | { 35 | #if (defined(FSL_FEATURE_RCM_REG_WIDTH) && (FSL_FEATURE_RCM_REG_WIDTH == 32)) 36 | uint32_t reg; 37 | 38 | reg = (((uint32_t)config->enableFilterInStop << RCM_RPC_RSTFLTSS_SHIFT) | (uint32_t)config->filterInRunWait); 39 | if (config->filterInRunWait == kRCM_FilterBusClock) 40 | { 41 | reg |= ((uint32_t)config->busClockFilterCount << RCM_RPC_RSTFLTSEL_SHIFT); 42 | } 43 | base->RPC = reg; 44 | #else 45 | base->RPFC = ((uint8_t)(config->enableFilterInStop << RCM_RPFC_RSTFLTSS_SHIFT) | (uint8_t)config->filterInRunWait); 46 | if (config->filterInRunWait == kRCM_FilterBusClock) 47 | { 48 | base->RPFW = config->busClockFilterCount; 49 | } 50 | #endif /* FSL_FEATURE_RCM_REG_WIDTH */ 51 | } 52 | 53 | #if (defined(FSL_FEATURE_RCM_HAS_BOOTROM) && FSL_FEATURE_RCM_HAS_BOOTROM) 54 | void RCM_SetForceBootRomSource(RCM_Type *base, rcm_boot_rom_config_t config) 55 | { 56 | uint32_t reg; 57 | 58 | reg = base->FM; 59 | reg &= ~RCM_FM_FORCEROM_MASK; 60 | reg |= ((uint32_t)config << RCM_FM_FORCEROM_SHIFT); 61 | base->FM = reg; 62 | } 63 | #endif /* #if FSL_FEATURE_RCM_HAS_BOOTROM */ 64 | -------------------------------------------------------------------------------- /Kinetis Design Studio/Audio Processing Benchmarking/FIR_FFT_Benchmarking/devices/MK66F18/drivers/fsl_rnga.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Freescale Semiconductor, Inc. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * o Redistributions of source code must retain the above copyright notice, this list 9 | * of conditions and the following disclaimer. 10 | * 11 | * o Redistributions in binary form must reproduce the above copyright notice, this 12 | * list of conditions and the following disclaimer in the documentation and/or 13 | * other materials provided with the distribution. 14 | * 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from this 17 | * software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef _FSL_RNGA_DRIVER_H_ 31 | #define _FSL_RNGA_DRIVER_H_ 32 | 33 | #include "fsl_common.h" 34 | 35 | #if defined(FSL_FEATURE_SOC_RNG_COUNT) && FSL_FEATURE_SOC_RNG_COUNT 36 | /*! 37 | * @addtogroup rnga_driver 38 | * @{ 39 | */ 40 | 41 | /*! @file */ 42 | 43 | /******************************************************************************* 44 | * Definitions 45 | *******************************************************************************/ 46 | 47 | /*! @name Driver version */ 48 | /*@{*/ 49 | /*! @brief RNGA driver version 2.0.1. */ 50 | #define FSL_RNGA_DRIVER_VERSION (MAKE_VERSION(2, 0, 1)) 51 | /*@}*/ 52 | 53 | /*! @brief RNGA working mode */ 54 | typedef enum _rnga_mode 55 | { 56 | kRNGA_ModeNormal = 0U, /*!< Normal Mode. The ring-oscillator clocks are active; RNGA generates entropy 57 | (randomness) from the clocks and stores it in shift registers.*/ 58 | kRNGA_ModeSleep = 1U, /*!< Sleep Mode. The ring-oscillator clocks are inactive; RNGA does not generate entropy.*/ 59 | } rnga_mode_t; 60 | 61 | /******************************************************************************* 62 | * API 63 | *******************************************************************************/ 64 | 65 | #if defined(__cplusplus) 66 | extern "C" { 67 | #endif 68 | 69 | /*! 70 | * @brief Initializes the RNGA. 71 | * 72 | * This function initializes the RNGA. 73 | * When called, the RNGA entropy generation starts immediately. 74 | * 75 | * @param base RNGA base address 76 | */ 77 | void RNGA_Init(RNG_Type *base); 78 | 79 | /*! 80 | * @brief Shuts down the RNGA. 81 | * 82 | * This function shuts down the RNGA. 83 | * 84 | * @param base RNGA base address 85 | */ 86 | void RNGA_Deinit(RNG_Type *base); 87 | 88 | /*! 89 | * @brief Gets random data. 90 | * 91 | * This function gets random data from the RNGA. 92 | * 93 | * @param base RNGA base address 94 | * @param data pointer to user buffer to be filled by random data 95 | * @param data_size size of data in bytes 96 | * @return RNGA status 97 | */ 98 | status_t RNGA_GetRandomData(RNG_Type *base, void *data, size_t data_size); 99 | 100 | /*! 101 | * @brief Feeds the RNGA module. 102 | * 103 | * This function inputs an entropy value that the RNGA uses to seed its 104 | * pseudo-random algorithm. 105 | * 106 | * @param base RNGA base address 107 | * @param seed input seed value 108 | */ 109 | void RNGA_Seed(RNG_Type *base, uint32_t seed); 110 | 111 | /*! 112 | * @brief Sets the RNGA in normal mode or sleep mode. 113 | * 114 | * This function sets the RNGA in sleep mode or normal mode. 115 | * 116 | * @param base RNGA base address 117 | * @param mode normal mode or sleep mode 118 | */ 119 | void RNGA_SetMode(RNG_Type *base, rnga_mode_t mode); 120 | 121 | /*! 122 | * @brief Gets the RNGA working mode. 123 | * 124 | * This function gets the RNGA working mode. 125 | * 126 | * @param base RNGA base address 127 | * @return normal mode or sleep mode 128 | */ 129 | rnga_mode_t RNGA_GetMode(RNG_Type *base); 130 | 131 | #if defined(__cplusplus) 132 | } 133 | #endif 134 | 135 | /*! @}*/ 136 | 137 | #endif /* FSL_FEATURE_SOC_RNG_COUNT */ 138 | #endif /* _FSL_RNGA_H_*/ 139 | -------------------------------------------------------------------------------- /Kinetis Design Studio/Audio Processing Benchmarking/FIR_FFT_Benchmarking/devices/MK66F18/drivers/fsl_sim.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Freescale Semiconductor, Inc. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * o Redistributions of source code must retain the above copyright notice, this list 9 | * of conditions and the following disclaimer. 10 | * 11 | * o Redistributions in binary form must reproduce the above copyright notice, this 12 | * list of conditions and the following disclaimer in the documentation and/or 13 | * other materials provided with the distribution. 14 | * 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from this 17 | * software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include "fsl_sim.h" 32 | 33 | /******************************************************************************* 34 | * Codes 35 | ******************************************************************************/ 36 | #if (defined(FSL_FEATURE_SIM_OPT_HAS_USB_VOLTAGE_REGULATOR) && FSL_FEATURE_SIM_OPT_HAS_USB_VOLTAGE_REGULATOR) 37 | void SIM_SetUsbVoltRegulatorEnableMode(uint32_t mask) 38 | { 39 | SIM->SOPT1CFG |= (SIM_SOPT1CFG_URWE_MASK | SIM_SOPT1CFG_UVSWE_MASK | SIM_SOPT1CFG_USSWE_MASK); 40 | 41 | SIM->SOPT1 = (SIM->SOPT1 & ~kSIM_UsbVoltRegEnableInAllModes) | mask; 42 | } 43 | #endif /* FSL_FEATURE_SIM_OPT_HAS_USB_VOLTAGE_REGULATOR */ 44 | 45 | void SIM_GetUniqueId(sim_uid_t *uid) 46 | { 47 | #if defined(SIM_UIDH) 48 | uid->H = SIM->UIDH; 49 | #endif 50 | uid->MH = SIM->UIDMH; 51 | uid->ML = SIM->UIDML; 52 | uid->L = SIM->UIDL; 53 | } 54 | -------------------------------------------------------------------------------- /Kinetis Design Studio/Audio Processing Benchmarking/FIR_FFT_Benchmarking/devices/MK66F18/fsl_device_registers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 - 2015, Freescale Semiconductor, Inc. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * o Redistributions of source code must retain the above copyright notice, this list 9 | * of conditions and the following disclaimer. 10 | * 11 | * o Redistributions in binary form must reproduce the above copyright notice, this 12 | * list of conditions and the following disclaimer in the documentation and/or 13 | * other materials provided with the distribution. 14 | * 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from this 17 | * software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef __FSL_DEVICE_REGISTERS_H__ 32 | #define __FSL_DEVICE_REGISTERS_H__ 33 | 34 | /* 35 | * Include the cpu specific register header files. 36 | * 37 | * The CPU macro should be declared in the project or makefile. 38 | */ 39 | #if (defined(CPU_MK66FN2M0VLQ18) || defined(CPU_MK66FX1M0VLQ18) || defined(CPU_MK66FN2M0VMD18) || \ 40 | defined(CPU_MK66FX1M0VMD18)) 41 | 42 | #define K66F18_SERIES 43 | 44 | /* CMSIS-style register definitions */ 45 | #include "MK66F18.h" 46 | /* CPU specific feature definitions */ 47 | #include "MK66F18_features.h" 48 | 49 | #else 50 | #error "No valid CPU defined!" 51 | #endif 52 | 53 | #endif /* __FSL_DEVICE_REGISTERS_H__ */ 54 | 55 | /******************************************************************************* 56 | * EOF 57 | ******************************************************************************/ 58 | -------------------------------------------------------------------------------- /Kinetis Design Studio/Audio Processing Benchmarking/FIR_FFT_Benchmarking/devices/MK66F18/utilities/fsl_sbrk.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Freescale Semiconductor, Inc. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * o Redistributions of source code must retain the above copyright notice, this list 9 | * of conditions and the following disclaimer. 10 | * 11 | * o Redistributions in binary form must reproduce the above copyright notice, this 12 | * list of conditions and the following disclaimer in the documentation and/or 13 | * other materials provided with the distribution. 14 | * 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from this 17 | * software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #if defined(__GNUC__) 31 | #include 32 | #include 33 | #endif 34 | 35 | #if defined(__GNUC__) 36 | /*! 37 | * @brief Function to override ARMGCC default function _sbrk 38 | * 39 | * _sbrk is called by malloc. ARMGCC default _sbrk compares "SP" register and 40 | * heap end, if heap end is larger than "SP", then _sbrk returns error and 41 | * memory allocation failed. This function changes to compare __HeapLimit with 42 | * heap end. 43 | */ 44 | caddr_t _sbrk(int incr) 45 | { 46 | extern char end __asm("end"); 47 | extern char heap_limit __asm("__HeapLimit"); 48 | static char *heap_end; 49 | char *prev_heap_end; 50 | 51 | if (heap_end == NULL) 52 | heap_end = &end; 53 | 54 | prev_heap_end = heap_end; 55 | 56 | if (heap_end + incr > &heap_limit) 57 | { 58 | errno = ENOMEM; 59 | return (caddr_t)-1; 60 | } 61 | 62 | heap_end += incr; 63 | 64 | return (caddr_t)prev_heap_end; 65 | } 66 | #endif 67 | -------------------------------------------------------------------------------- /Kinetis Design Studio/Audio Processing Benchmarking/FIR_FFT_Benchmarking/kds/.gitignore: -------------------------------------------------------------------------------- 1 | /debug/ 2 | /release/ 3 | -------------------------------------------------------------------------------- /Kinetis Design Studio/Audio Processing Benchmarking/FIR_FFT_Benchmarking/kds/.settings/com.processorexpert.core.ide.newprojectwizard.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | versionGenerated/versionGenerated=1.8.4.RT7_b1550-0615 3 | -------------------------------------------------------------------------------- /Kinetis Design Studio/Audio Processing Benchmarking/FIR_FFT_Benchmarking/kds/.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Kinetis Design Studio/Audio Processing Benchmarking/FIR_FFT_Benchmarking/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 - 2015, Freescale Semiconductor, Inc. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * o Redistributions of source code must retain the above copyright notice, this list 9 | * of conditions and the following disclaimer. 10 | * 11 | * o Redistributions in binary form must reproduce the above copyright notice, this 12 | * list of conditions and the following disclaimer in the documentation and/or 13 | * other materials provided with the distribution. 14 | * 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from this 17 | * software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | 32 | #include "fsl_device_registers.h" 33 | #include "fsl_debug_console.h" 34 | #include "board.h" 35 | #include "pin_mux.h" 36 | #include "clock_config.h" 37 | 38 | #include "fsl_lptmr.h" 39 | #include "fsl_gpio.h" 40 | 41 | #include "..\..\Utilities\arm_timing.h" //my own functions for micros() on ARM 42 | 43 | //In this header file is the definition for things like DataType (int16, int32, float) and MAX_N 44 | #include "..\..\..\Arduino\Audio Processing Benchmarking\FIR_FFT_Benchmarking\fft_fir_const.h" 45 | //#include "fft_fir_const.h" 46 | 47 | // Choose the operation that you want to do 48 | #define DO_NAIVE_FIR 0 49 | #define DO_KISS_FFT 1 50 | #define DO_ARM_FFT 2 51 | #define OPERATION_TO_DO DO_ARM_FFT //change this to select which function to run 52 | 53 | 54 | #if OPERATION_TO_DO == DO_NAIVE_FIR 55 | #include "..\..\..\Arduino\Audio Processing Benchmarking\FIR_FFT_Benchmarking\do_naive_fir.h" 56 | char *alg_name = "NAIVE FIR"; 57 | #define N_TRIALS 10000 // how many times to repeat the operation 58 | #endif 59 | 60 | #if (OPERATION_TO_DO == DO_KISS_FFT) 61 | //in Kinetis Design Studio, be sure to increase the HEAP size! 62 | //Under settings/MK66FN2M0xxx18_flash.ld make this change: 63 | // HEAP_SIZE = DEFINED(__heap_size__) ? __heap_size__ : 0x4400; /* WEA 2016-08-20 */ 64 | #include "..\..\..\Arduino\Audio Processing Benchmarking\FIR_FFT_Benchmarking\do_kiss_fft.h" 65 | char *alg_name = "KISS FFT"; 66 | #define N_TRIALS 1000 // how many times to repeat the operation 67 | #endif 68 | 69 | #if (OPERATION_TO_DO == DO_ARM_FFT) 70 | #include "..\..\..\Arduino\Audio Processing Benchmarking\FIR_FFT_Benchmarking\do_arm_fft.h" 71 | char *alg_name = "ARM FFT"; 72 | #define N_TRIALS 1000 // how many times to repeat the operation 73 | #endif 74 | 75 | 76 | #ifdef IS_ARDUINO_UNO 77 | int freeRam(void) { 78 | extern int __heap_start, *__brkval; 79 | int v; 80 | return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); 81 | } 82 | #else 83 | int freeRam(void) { return -1; } 84 | #endif 85 | 86 | int main(void) { 87 | int N; 88 | int32_t dt_micros=0; 89 | 90 | BOARD_InitPins(); 91 | //BOARD_BootClockRUN(); //120 MHz 92 | BOARD_BootClockHSRUN(); //180MHz 93 | BOARD_InitDebugConsole(); 94 | 95 | initMicros(); 96 | 97 | PRINTF("FIR/FFT Benchmarking...\r\n"); 98 | PRINTF(" : System Clock = %i Hz\r\n",CLOCK_GetFreq(kCLOCK_CoreSysClk)); 99 | //PRINTF(" : LPTMR Source Clock = %i Hz\r\n", LPTMR_CLOCK_HZ); 100 | //PRINTF(" : micros per tick = %4.1f\r\n", millis_per_tic*1000); 101 | 102 | //loop forever 103 | N = MAX_N; 104 | int N_LOOP = 0; 105 | for (;;) { 106 | if (N_LOOP < 4) { 107 | 108 | //do the processing 109 | #if (OPERATION_TO_DO == DO_NAIVE_FIR) 110 | dt_micros = naive_fir_func(N,N_TRIALS); 111 | #elif (OPERATION_TO_DO == DO_KISS_FFT) 112 | dt_micros = kiss_fft_func(N,N_TRIALS); 113 | #elif (OPERATION_TO_DO == DO_ARM_FFT) 114 | dt_micros = arm_fft_func(N,N_TRIALS); 115 | #endif 116 | 117 | //report the timing 118 | PRINTF("%s: N = %i\tin %6.1f usec per operation\r\n",alg_name,N,((float)dt_micros)/((float)N_TRIALS)); 119 | 120 | //prepare for next step 121 | N = N/2; 122 | if (N < 8) { 123 | N = MAX_N; 124 | N_LOOP++; 125 | } 126 | 127 | } 128 | } 129 | return 0; 130 | } 131 | -------------------------------------------------------------------------------- /Kinetis Design Studio/Audio Processing Benchmarking/FIR_FFT_Benchmarking/pin_mux.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Freescale Semiconductor, Inc. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * o Redistributions of source code must retain the above copyright notice, this list 9 | * of conditions and the following disclaimer. 10 | * 11 | * o Redistributions in binary form must reproduce the above copyright notice, this 12 | * list of conditions and the following disclaimer in the documentation and/or 13 | * other materials provided with the distribution. 14 | * 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from this 17 | * software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include "fsl_device_registers.h" 32 | #include "fsl_port.h" 33 | #include "pin_mux.h" 34 | 35 | /******************************************************************************* 36 | * Code 37 | ******************************************************************************/ 38 | /*! 39 | * @brief Initialize all pins used in this example 40 | * 41 | * @param disablePortClockAfterInit disable port clock after pin 42 | * initialization or not. 43 | */ 44 | void BOARD_InitPins(void) 45 | { 46 | /* Initialize UART0 pins below */ 47 | /* Ungate the port clock */ 48 | CLOCK_EnableClock(kCLOCK_PortB); 49 | /* Affects PORTB_PCR16 register */ 50 | PORT_SetPinMux(PORTB, 16u, kPORT_MuxAlt3); 51 | /* Affects PORTB_PCR17 register */ 52 | PORT_SetPinMux(PORTB, 17u, kPORT_MuxAlt3); 53 | } 54 | -------------------------------------------------------------------------------- /Kinetis Design Studio/Audio Processing Benchmarking/FIR_FFT_Benchmarking/pin_mux.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Freescale Semiconductor, Inc. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * o Redistributions of source code must retain the above copyright notice, this list 9 | * of conditions and the following disclaimer. 10 | * 11 | * o Redistributions in binary form must reproduce the above copyright notice, this 12 | * list of conditions and the following disclaimer in the documentation and/or 13 | * other materials provided with the distribution. 14 | * 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from this 17 | * software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef _PIN_MUX_H_ 32 | #define _PIN_MUX_H_ 33 | 34 | #include 35 | #include "fsl_common.h" 36 | 37 | #if defined(__cplusplus) 38 | extern "C" { 39 | #endif /* __cplusplus*/ 40 | /*! 41 | * @brief configure all pins for this demo/example 42 | * 43 | */ 44 | void BOARD_InitPins(void); 45 | 46 | /*! 47 | * @brief configure pins for uart0 48 | * 49 | */ 50 | 51 | #if defined(__cplusplus) 52 | } 53 | #endif /* __cplusplus*/ 54 | 55 | #endif /* _PIN_MUX_H_ */ 56 | -------------------------------------------------------------------------------- /Kinetis Design Studio/Utilities/arm_timing.h: -------------------------------------------------------------------------------- 1 | #ifndef _ARM_TIMING 2 | #define _ARM_TIMING 3 | 4 | #define LPTMR_CLOCK_HZ CLOCK_GetFreq(kCLOCK_LpoClk) /* Get source clock for LPTMR driver */ 5 | volatile uint32_t lptmrCounter = 0U; 6 | void LPTMR0_IRQHandler(void) { 7 | LPTMR_ClearStatusFlags(LPTMR0, kLPTMR_TimerCompareFlag); 8 | lptmrCounter++; 9 | } 10 | float micros_per_tic; 11 | uint16_t tics_per_loop = 30000;//must be less than 32768 12 | void initMicros() { 13 | //configure the timer 14 | lptmr_config_t lptmrConfig; 15 | LPTMR_GetDefaultConfig(&lptmrConfig); 16 | LPTMR_Init(LPTMR0, &lptmrConfig); /* Initialize the LPTMR */ 17 | 18 | //now define how the timer relates to the real world 19 | micros_per_tic = 1000000.0/((float)LPTMR_CLOCK_HZ); //the 1000000 is because we're in microseconds 20 | LPTMR_SetTimerPeriod(LPTMR0, tics_per_loop); // Set timer period...this is when it'll wrap around to zero 21 | 22 | //finish configuring how the processor will work with the timer 23 | LPTMR_EnableInterrupts(LPTMR0, kLPTMR_TimerInterruptEnable); ///it'll call its interupt when it hits wraps around, per the setting above 24 | EnableIRQ(LPTMR0_IRQn); /* Enable at the NVIC */ 25 | LPTMR_StartTimer(LPTMR0); /* Start counting */ 26 | } 27 | uint32_t micros() { return (uint32_t)((uint32_t)LPTMR_GetCurrentTimerCount(LPTMR0) + (lptmrCounter*(uint32_t)tics_per_loop))*micros_per_tic; }; 28 | 29 | #endif 30 | --------------------------------------------------------------------------------