├── src ├── libopus │ ├── NEWS │ ├── ChangeLog │ ├── silk │ │ ├── fixed │ │ │ ├── k2a_FIX.o │ │ │ ├── schur_FIX.o │ │ │ ├── autocorr_FIX.o │ │ │ ├── find_LPC_FIX.o │ │ │ ├── find_LTP_FIX.o │ │ │ ├── k2a_Q16_FIX.o │ │ │ ├── schur64_FIX.o │ │ │ ├── corrMatrix_FIX.o │ │ │ ├── vector_ops_FIX.o │ │ │ ├── LTP_scale_ctrl_FIX.o │ │ │ ├── burg_modified_FIX.o │ │ │ ├── encode_frame_FIX.o │ │ │ ├── process_gains_FIX.o │ │ │ ├── find_pitch_lags_FIX.o │ │ │ ├── find_pred_coefs_FIX.o │ │ │ ├── residual_energy_FIX.o │ │ │ ├── LTP_analysis_filter_FIX.o │ │ │ ├── apply_sine_window_FIX.o │ │ │ ├── pitch_analysis_core_FIX.o │ │ │ ├── residual_energy16_FIX.o │ │ │ ├── noise_shape_analysis_FIX.o │ │ │ ├── regularize_correlations_FIX.o │ │ │ ├── warped_autocorrelation_FIX.o │ │ │ ├── k2a_FIX.lo │ │ │ ├── schur_FIX.lo │ │ │ ├── autocorr_FIX.lo │ │ │ ├── find_LPC_FIX.lo │ │ │ ├── find_LTP_FIX.lo │ │ │ ├── k2a_Q16_FIX.lo │ │ │ ├── schur64_FIX.lo │ │ │ ├── corrMatrix_FIX.lo │ │ │ ├── vector_ops_FIX.lo │ │ │ ├── burg_modified_FIX.lo │ │ │ ├── encode_frame_FIX.lo │ │ │ ├── process_gains_FIX.lo │ │ │ ├── LTP_scale_ctrl_FIX.lo │ │ │ ├── find_pitch_lags_FIX.lo │ │ │ ├── find_pred_coefs_FIX.lo │ │ │ ├── residual_energy_FIX.lo │ │ │ ├── apply_sine_window_FIX.lo │ │ │ ├── residual_energy16_FIX.lo │ │ │ ├── LTP_analysis_filter_FIX.lo │ │ │ ├── pitch_analysis_core_FIX.lo │ │ │ ├── noise_shape_analysis_FIX.lo │ │ │ ├── regularize_correlations_FIX.lo │ │ │ └── warped_autocorrelation_FIX.lo │ │ ├── lin2log.c │ │ ├── init_decoder.c │ │ ├── inner_prod_aligned.c │ │ └── bwexpander_32.c │ ├── AUTHORS │ ├── opus.pc │ ├── celt │ │ ├── cwrs.h │ │ ├── laplace.h │ │ ├── mfrngcod.h │ │ ├── celt_lpc.h │ │ ├── cpu_support.h │ │ └── modes.h │ ├── COPYING │ ├── mlp.h │ └── tansig_table.h ├── libhelix-mp3 │ ├── RCSL.txt │ ├── player.h │ └── LICENSE.txt ├── libhelix-aac │ └── readme.txt ├── AudioLogger.cpp ├── libmad │ ├── VERSION │ ├── COPYRIGHT │ ├── mad.h.sed │ ├── layer3.h │ ├── bit.h │ ├── version.h │ ├── global.h │ ├── README.ESP8266 │ ├── TODO │ ├── huffman.h │ ├── fixed.c │ ├── synth.h │ └── version.c ├── libogg │ ├── README.esp8266.md │ ├── AUTHORS │ ├── ogg.pc │ ├── ogg │ │ └── config_types.h │ └── COPYING ├── opusfile │ ├── README.esp8266.md │ ├── AUTHORS │ ├── opusfile.pc │ ├── README.md │ ├── COPYING │ └── internal.c ├── libflac │ ├── README.ESP8266 │ ├── share │ │ ├── utf8.h │ │ ├── macros.h │ │ └── private.h │ ├── COPYING.Xiph │ ├── private │ │ ├── md5.h │ │ ├── metadata.h │ │ └── format.h │ ├── protected │ │ └── all.h │ ├── FLAC │ │ └── assert.h │ ├── AUTHORS │ └── bitmath.c ├── AudioLogger.h ├── libtinysoundfont │ ├── LICENSE │ ├── README.md │ └── README.ESP8266 ├── AudioFileStream.cpp ├── AudioOutputSerialWAV.h ├── AudioFileSourceSPIFFS.h ├── AudioFileSourceLittleFS.h ├── AudioOutputSPIFFSWAV.h ├── AudioOutputSTDIO.h ├── AudioFileStream.h ├── AudioFileSourceICYStream.h ├── AudioOutputNull.h ├── AudioFileSourceID3.h ├── AudioFileSourceSD.h ├── AudioOutputBuffer.h ├── ESP8266Audio.h ├── AudioOutputI2SNoDAC.h ├── AudioFileSourceFS.h ├── AudioFileSourcePROGMEM.h ├── AudioFileSourceSTDIO.h ├── AudioOutputFilterDecimate.h ├── AudioFileSourceFS.cpp ├── AudioGenerator.h ├── AudioFileSource.h ├── AudioGeneratorMP3a.h ├── AudioFileSourceBuffer.h ├── AudioFileSourceSD.cpp ├── AudioFileSourceFATFS.h ├── AudioStatus.h ├── AudioGeneratorWAV.h ├── AudioGeneratorRTTTL.h ├── AudioFileSourceSPIRAMBuffer.h ├── AudioGeneratorAAC.h ├── AudioFileSourceHTTPStream.h ├── AudioGeneratorTalkie.h ├── AudioOutputI2S.h ├── AudioGeneratorOpus.h ├── AudioOutputFilterBiquad.h ├── AudioOutputBuffer.cpp ├── AudioOutputULP.h └── AudioFileSourceSTDIO.cpp ├── tests └── host │ ├── pgmspace.h │ ├── Serial.cpp │ ├── test_8u_16.wav │ ├── gs-16b-2c-44100hz.flac │ ├── wav.cpp │ ├── flac.cpp │ ├── opus.cpp │ ├── aac.cpp │ ├── midi.cpp │ └── mp3.cpp ├── examples ├── PlayAACFromPROGMEM │ ├── homer.aac │ └── PlayAACFromPROGMEM.ino ├── PlayMIDIFromLittleFS │ ├── data │ │ ├── 1mgm.sf2 │ │ └── furelise.mid │ └── PlayMIDIFromLittleFS.ino ├── PlayMIDIFromSPIFFS │ ├── data │ │ ├── 1mgm.sf2 │ │ └── furelise.mid │ └── PlayMIDIFromSPIFFS.ino ├── PlayMP3FromSPIFFS │ ├── data │ │ └── pno-cs.mp3 │ └── PlayMP3FromSPIFFS.ino ├── StreamMP3FromHTTP_SPIRAM │ └── Schema_Spiram.png ├── PlayOpusFromSPIFFS │ ├── data │ │ └── gs-16b-2c-44100hz.opus │ └── PlayOpusFromSPIFFS.ino ├── PlayFLACFromPROGMEMToDAC │ └── PlayFLACFromPROGMEMToDAC.ino ├── PlayWAVFromPROGMEM │ └── PlayWAVFromPROGMEM.ino ├── PlayMODFromPROGMEMToDAC │ └── PlayMODFromPROGMEMToDAC.ino ├── PlayRTTTLToI2SDAC │ └── PlayRTTTLToI2SDAC.ino ├── MixerSample │ └── MixerSample.ino ├── StreamOnHost │ ├── onHost │ └── AudioOutputNullSlow.h └── PlayFLAC-SD-SPDIF │ └── PlayFLAC-SD-SPDIF.ino ├── library.properties ├── library.json └── keywords.txt /src/libopus/NEWS: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/libopus/ChangeLog: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/host/pgmspace.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/host/Serial.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | SerialEmulator Serial; 4 | 5 | -------------------------------------------------------------------------------- /src/libhelix-mp3/RCSL.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/src/libhelix-mp3/RCSL.txt -------------------------------------------------------------------------------- /tests/host/test_8u_16.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/tests/host/test_8u_16.wav -------------------------------------------------------------------------------- /src/libhelix-aac/readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/src/libhelix-aac/readme.txt -------------------------------------------------------------------------------- /src/libopus/silk/fixed/k2a_FIX.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/src/libopus/silk/fixed/k2a_FIX.o -------------------------------------------------------------------------------- /tests/host/gs-16b-2c-44100hz.flac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/tests/host/gs-16b-2c-44100hz.flac -------------------------------------------------------------------------------- /src/libopus/silk/fixed/schur_FIX.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/src/libopus/silk/fixed/schur_FIX.o -------------------------------------------------------------------------------- /examples/PlayAACFromPROGMEM/homer.aac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/examples/PlayAACFromPROGMEM/homer.aac -------------------------------------------------------------------------------- /src/AudioLogger.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "AudioLogger.h" 3 | 4 | DevNullOut silencedLogger; 5 | Print* audioLogger = &silencedLogger; 6 | -------------------------------------------------------------------------------- /src/libopus/silk/fixed/autocorr_FIX.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/src/libopus/silk/fixed/autocorr_FIX.o -------------------------------------------------------------------------------- /src/libopus/silk/fixed/find_LPC_FIX.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/src/libopus/silk/fixed/find_LPC_FIX.o -------------------------------------------------------------------------------- /src/libopus/silk/fixed/find_LTP_FIX.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/src/libopus/silk/fixed/find_LTP_FIX.o -------------------------------------------------------------------------------- /src/libopus/silk/fixed/k2a_Q16_FIX.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/src/libopus/silk/fixed/k2a_Q16_FIX.o -------------------------------------------------------------------------------- /src/libopus/silk/fixed/schur64_FIX.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/src/libopus/silk/fixed/schur64_FIX.o -------------------------------------------------------------------------------- /src/libopus/silk/fixed/corrMatrix_FIX.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/src/libopus/silk/fixed/corrMatrix_FIX.o -------------------------------------------------------------------------------- /src/libopus/silk/fixed/vector_ops_FIX.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/src/libopus/silk/fixed/vector_ops_FIX.o -------------------------------------------------------------------------------- /examples/PlayMIDIFromLittleFS/data/1mgm.sf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/examples/PlayMIDIFromLittleFS/data/1mgm.sf2 -------------------------------------------------------------------------------- /examples/PlayMIDIFromSPIFFS/data/1mgm.sf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/examples/PlayMIDIFromSPIFFS/data/1mgm.sf2 -------------------------------------------------------------------------------- /examples/PlayMP3FromSPIFFS/data/pno-cs.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/examples/PlayMP3FromSPIFFS/data/pno-cs.mp3 -------------------------------------------------------------------------------- /src/libopus/silk/fixed/LTP_scale_ctrl_FIX.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/src/libopus/silk/fixed/LTP_scale_ctrl_FIX.o -------------------------------------------------------------------------------- /src/libopus/silk/fixed/burg_modified_FIX.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/src/libopus/silk/fixed/burg_modified_FIX.o -------------------------------------------------------------------------------- /src/libopus/silk/fixed/encode_frame_FIX.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/src/libopus/silk/fixed/encode_frame_FIX.o -------------------------------------------------------------------------------- /src/libopus/silk/fixed/process_gains_FIX.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/src/libopus/silk/fixed/process_gains_FIX.o -------------------------------------------------------------------------------- /examples/PlayMIDIFromSPIFFS/data/furelise.mid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/examples/PlayMIDIFromSPIFFS/data/furelise.mid -------------------------------------------------------------------------------- /src/libopus/silk/fixed/find_pitch_lags_FIX.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/src/libopus/silk/fixed/find_pitch_lags_FIX.o -------------------------------------------------------------------------------- /src/libopus/silk/fixed/find_pred_coefs_FIX.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/src/libopus/silk/fixed/find_pred_coefs_FIX.o -------------------------------------------------------------------------------- /src/libopus/silk/fixed/residual_energy_FIX.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/src/libopus/silk/fixed/residual_energy_FIX.o -------------------------------------------------------------------------------- /examples/PlayMIDIFromLittleFS/data/furelise.mid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/examples/PlayMIDIFromLittleFS/data/furelise.mid -------------------------------------------------------------------------------- /src/libmad/VERSION: -------------------------------------------------------------------------------- 1 | 0.15.1b 2 | configure.ac:24 3 | version.h:25-28 4 | msvc++/config.h:99,105,120 5 | msvc++/mad.h:41-44 6 | 7 | Makefile.am:98-100 8 | -------------------------------------------------------------------------------- /src/libopus/silk/fixed/LTP_analysis_filter_FIX.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/src/libopus/silk/fixed/LTP_analysis_filter_FIX.o -------------------------------------------------------------------------------- /src/libopus/silk/fixed/apply_sine_window_FIX.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/src/libopus/silk/fixed/apply_sine_window_FIX.o -------------------------------------------------------------------------------- /src/libopus/silk/fixed/pitch_analysis_core_FIX.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/src/libopus/silk/fixed/pitch_analysis_core_FIX.o -------------------------------------------------------------------------------- /src/libopus/silk/fixed/residual_energy16_FIX.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/src/libopus/silk/fixed/residual_energy16_FIX.o -------------------------------------------------------------------------------- /src/libogg/README.esp8266.md: -------------------------------------------------------------------------------- 1 | This is libogg from Xiph, modified to build under Arduino by . 2 | 3 | OGG license/etc. unchanged. 4 | -------------------------------------------------------------------------------- /src/libopus/silk/fixed/noise_shape_analysis_FIX.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/src/libopus/silk/fixed/noise_shape_analysis_FIX.o -------------------------------------------------------------------------------- /examples/StreamMP3FromHTTP_SPIRAM/Schema_Spiram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/examples/StreamMP3FromHTTP_SPIRAM/Schema_Spiram.png -------------------------------------------------------------------------------- /src/libopus/silk/fixed/regularize_correlations_FIX.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/src/libopus/silk/fixed/regularize_correlations_FIX.o -------------------------------------------------------------------------------- /src/libopus/silk/fixed/warped_autocorrelation_FIX.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/src/libopus/silk/fixed/warped_autocorrelation_FIX.o -------------------------------------------------------------------------------- /examples/PlayOpusFromSPIFFS/data/gs-16b-2c-44100hz.opus: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pixtxa/ESP8266Audio/master/examples/PlayOpusFromSPIFFS/data/gs-16b-2c-44100hz.opus -------------------------------------------------------------------------------- /src/opusfile/README.esp8266.md: -------------------------------------------------------------------------------- 1 | This is opusfile from Xiph, modified to build under Arduino by and adjusted to work with AudioFileSources, 2 | 3 | Original license/etc. unchanged. 4 | -------------------------------------------------------------------------------- /src/libogg/AUTHORS: -------------------------------------------------------------------------------- 1 | Monty 2 | Greg Maxwell 3 | Ralph Giles 4 | Cristian Adam 5 | Tim Terriberry 6 | 7 | and the rest of the Xiph.Org Foundation. 8 | -------------------------------------------------------------------------------- /src/libopus/AUTHORS: -------------------------------------------------------------------------------- 1 | Jean-Marc Valin (jmvalin@jmvalin.ca) 2 | Koen Vos (koenvos74@gmail.com) 3 | Timothy Terriberry (tterribe@xiph.org) 4 | Karsten Vandborg Sorensen (karsten.vandborg.sorensen@skype.net) 5 | Soren Skak Jensen (ssjensen@gn.com) 6 | Gregory Maxwell (greg@xiph.org) 7 | -------------------------------------------------------------------------------- /src/opusfile/AUTHORS: -------------------------------------------------------------------------------- 1 | Timothy B. Terriberry 2 | Ralph Giles 3 | Christopher "Monty" Montgomery (original libvorbisfile) 4 | Gregory Maxwell (noise shaping dithering) 5 | nu774 (original winsock support) 6 | -------------------------------------------------------------------------------- /src/libhelix-mp3/player.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | //SPI 5 | #define PIN_SPI_SCK 14 6 | #define PIN_SPI_MOSI 7 7 | #define PIN_SPI_SDCARD_CS 10 //SD-Card CS 8 | #define PIN_SPI_MEM_CS 6 //Flashmem CS 9 | 10 | //3V3 Voltage Regulator 11 | #define PIN_SHUTDOWNPWR3V3 5 12 | #define PWR3V3_ON HIGH 13 | #define PWR3V3_OFF LOW -------------------------------------------------------------------------------- /src/libflac/README.ESP8266: -------------------------------------------------------------------------------- 1 | This is LIBFLAC 1.3.2 ported to the ESP8266 by Earle F. Philhower, III 2 | . It's pretty much unchanged from base sourcew, 3 | with some CRC and string constants moved into PROGMEM. Headers have been 4 | purged of references to STDIO/FILE*. Files not needed for playback have 5 | been removed. 6 | -------------------------------------------------------------------------------- /src/libogg/ogg.pc: -------------------------------------------------------------------------------- 1 | # ogg pkg-config file 2 | 3 | prefix=/usr/local 4 | exec_prefix=${prefix} 5 | libdir=${exec_prefix}/lib 6 | includedir=${prefix}/include 7 | 8 | Name: ogg 9 | Description: ogg is a library for manipulating ogg bitstreams 10 | Version: 1.3.4 11 | Requires: 12 | Conflicts: 13 | Libs: -L${libdir} -logg 14 | Cflags: -I${includedir} 15 | -------------------------------------------------------------------------------- /src/libopus/silk/fixed/k2a_FIX.lo: -------------------------------------------------------------------------------- 1 | # silk/fixed/k2a_FIX.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/k2a_FIX.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object='k2a_FIX.o' 12 | 13 | -------------------------------------------------------------------------------- /src/libopus/silk/fixed/schur_FIX.lo: -------------------------------------------------------------------------------- 1 | # silk/fixed/schur_FIX.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/schur_FIX.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object='schur_FIX.o' 12 | 13 | -------------------------------------------------------------------------------- /src/libopus/silk/fixed/autocorr_FIX.lo: -------------------------------------------------------------------------------- 1 | # silk/fixed/autocorr_FIX.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/autocorr_FIX.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object='autocorr_FIX.o' 12 | 13 | -------------------------------------------------------------------------------- /src/libopus/silk/fixed/find_LPC_FIX.lo: -------------------------------------------------------------------------------- 1 | # silk/fixed/find_LPC_FIX.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/find_LPC_FIX.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object='find_LPC_FIX.o' 12 | 13 | -------------------------------------------------------------------------------- /src/libopus/silk/fixed/find_LTP_FIX.lo: -------------------------------------------------------------------------------- 1 | # silk/fixed/find_LTP_FIX.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/find_LTP_FIX.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object='find_LTP_FIX.o' 12 | 13 | -------------------------------------------------------------------------------- /src/libopus/silk/fixed/k2a_Q16_FIX.lo: -------------------------------------------------------------------------------- 1 | # silk/fixed/k2a_Q16_FIX.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/k2a_Q16_FIX.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object='k2a_Q16_FIX.o' 12 | 13 | -------------------------------------------------------------------------------- /src/libopus/silk/fixed/schur64_FIX.lo: -------------------------------------------------------------------------------- 1 | # silk/fixed/schur64_FIX.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/schur64_FIX.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object='schur64_FIX.o' 12 | 13 | -------------------------------------------------------------------------------- /src/libopus/silk/fixed/corrMatrix_FIX.lo: -------------------------------------------------------------------------------- 1 | # silk/fixed/corrMatrix_FIX.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/corrMatrix_FIX.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object='corrMatrix_FIX.o' 12 | 13 | -------------------------------------------------------------------------------- /src/libopus/silk/fixed/vector_ops_FIX.lo: -------------------------------------------------------------------------------- 1 | # silk/fixed/vector_ops_FIX.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/vector_ops_FIX.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object='vector_ops_FIX.o' 12 | 13 | -------------------------------------------------------------------------------- /src/libopus/silk/fixed/burg_modified_FIX.lo: -------------------------------------------------------------------------------- 1 | # silk/fixed/burg_modified_FIX.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/burg_modified_FIX.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object='burg_modified_FIX.o' 12 | 13 | -------------------------------------------------------------------------------- /src/libopus/silk/fixed/encode_frame_FIX.lo: -------------------------------------------------------------------------------- 1 | # silk/fixed/encode_frame_FIX.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/encode_frame_FIX.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object='encode_frame_FIX.o' 12 | 13 | -------------------------------------------------------------------------------- /src/libopus/silk/fixed/process_gains_FIX.lo: -------------------------------------------------------------------------------- 1 | # silk/fixed/process_gains_FIX.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/process_gains_FIX.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object='process_gains_FIX.o' 12 | 13 | -------------------------------------------------------------------------------- /src/libopus/silk/fixed/LTP_scale_ctrl_FIX.lo: -------------------------------------------------------------------------------- 1 | # silk/fixed/LTP_scale_ctrl_FIX.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/LTP_scale_ctrl_FIX.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object='LTP_scale_ctrl_FIX.o' 12 | 13 | -------------------------------------------------------------------------------- /src/libopus/silk/fixed/find_pitch_lags_FIX.lo: -------------------------------------------------------------------------------- 1 | # silk/fixed/find_pitch_lags_FIX.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/find_pitch_lags_FIX.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object='find_pitch_lags_FIX.o' 12 | 13 | -------------------------------------------------------------------------------- /src/libopus/silk/fixed/find_pred_coefs_FIX.lo: -------------------------------------------------------------------------------- 1 | # silk/fixed/find_pred_coefs_FIX.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/find_pred_coefs_FIX.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object='find_pred_coefs_FIX.o' 12 | 13 | -------------------------------------------------------------------------------- /src/libopus/silk/fixed/residual_energy_FIX.lo: -------------------------------------------------------------------------------- 1 | # silk/fixed/residual_energy_FIX.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/residual_energy_FIX.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object='residual_energy_FIX.o' 12 | 13 | -------------------------------------------------------------------------------- /src/libopus/silk/fixed/apply_sine_window_FIX.lo: -------------------------------------------------------------------------------- 1 | # silk/fixed/apply_sine_window_FIX.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/apply_sine_window_FIX.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object='apply_sine_window_FIX.o' 12 | 13 | -------------------------------------------------------------------------------- /src/libopus/silk/fixed/residual_energy16_FIX.lo: -------------------------------------------------------------------------------- 1 | # silk/fixed/residual_energy16_FIX.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/residual_energy16_FIX.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object='residual_energy16_FIX.o' 12 | 13 | -------------------------------------------------------------------------------- /src/opusfile/opusfile.pc: -------------------------------------------------------------------------------- 1 | # opusfile installed pkg-config file 2 | 3 | prefix=/usr/local 4 | exec_prefix=${prefix} 5 | libdir=${exec_prefix}/lib 6 | includedir=${prefix}/include 7 | 8 | Name: opusfile 9 | Description: High-level Opus decoding library 10 | Version: 0.12 11 | Requires.private: ogg >= 1.3 opus >= 1.0.1 12 | Conflicts: 13 | Libs: -L${libdir} -lopusfile 14 | Libs.private: 15 | Cflags: -I${includedir}/opus 16 | -------------------------------------------------------------------------------- /src/libopus/silk/fixed/LTP_analysis_filter_FIX.lo: -------------------------------------------------------------------------------- 1 | # silk/fixed/LTP_analysis_filter_FIX.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/LTP_analysis_filter_FIX.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object='LTP_analysis_filter_FIX.o' 12 | 13 | -------------------------------------------------------------------------------- /src/libopus/silk/fixed/pitch_analysis_core_FIX.lo: -------------------------------------------------------------------------------- 1 | # silk/fixed/pitch_analysis_core_FIX.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/pitch_analysis_core_FIX.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object='pitch_analysis_core_FIX.o' 12 | 13 | -------------------------------------------------------------------------------- /src/libopus/silk/fixed/noise_shape_analysis_FIX.lo: -------------------------------------------------------------------------------- 1 | # silk/fixed/noise_shape_analysis_FIX.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/noise_shape_analysis_FIX.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object='noise_shape_analysis_FIX.o' 12 | 13 | -------------------------------------------------------------------------------- /src/libopus/opus.pc: -------------------------------------------------------------------------------- 1 | # Opus codec reference implementation pkg-config file 2 | 3 | prefix=/usr/local 4 | exec_prefix=${prefix} 5 | libdir=${exec_prefix}/lib 6 | includedir=${prefix}/include 7 | 8 | Name: Opus 9 | Description: Opus IETF audio codec (fixed-point build) 10 | URL: https://opus-codec.org/ 11 | Version: 1.3.1 12 | Requires: 13 | Conflicts: 14 | Libs: -L${libdir} -lopus 15 | Libs.private: -lm 16 | Cflags: -I${includedir}/opus 17 | -------------------------------------------------------------------------------- /src/libopus/silk/fixed/regularize_correlations_FIX.lo: -------------------------------------------------------------------------------- 1 | # silk/fixed/regularize_correlations_FIX.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/regularize_correlations_FIX.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object='regularize_correlations_FIX.o' 12 | 13 | -------------------------------------------------------------------------------- /src/libopus/silk/fixed/warped_autocorrelation_FIX.lo: -------------------------------------------------------------------------------- 1 | # silk/fixed/warped_autocorrelation_FIX.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/warped_autocorrelation_FIX.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object='warped_autocorrelation_FIX.o' 12 | 13 | -------------------------------------------------------------------------------- /src/AudioLogger.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #ifndef _AUDIOLOGGER_H 5 | #define _AUDIOLOGGER_H 6 | 7 | class DevNullOut: public Print 8 | { 9 | public: 10 | virtual size_t write(uint8_t) { return 1; } 11 | }; 12 | 13 | extern DevNullOut silencedLogger; 14 | 15 | // Global `audioLogger` is initialized to &silencedLogger 16 | // It can be initialized anytime to &Serial or any other Print:: derivative instance. 17 | extern Print* audioLogger; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=ESP8266Audio 2 | version=1.9.3 3 | author=Earle F. Philhower, III 4 | maintainer=Earle F. Philhower, III 5 | sentence=Audio file and I2S sound playing routines for ESP8266, ESP32, and Raspberry Pi Pico RP2040 6 | paragraph=Decode compressed MP3, AAC, FLAC, Screamtracker MOD, MIDI, RTTL, TI Talkie, and WAV and play on an I2S DAC or a software-driven delta-sigma DAC and 1-transistor amplifier. 7 | category=Signal Input/Output 8 | url=https://github.com/earlephilhower/ESP8266Audio 9 | architectures=esp8266,esp32,rp2040 10 | -------------------------------------------------------------------------------- /tests/host/wav.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "AudioFileSourceSTDIO.h" 3 | #include "AudioOutputSTDIO.h" 4 | #include "AudioGeneratorWAV.h" 5 | 6 | 7 | int main(int argc, char **argv) 8 | { 9 | (void) argc; 10 | (void) argv; 11 | AudioFileSourceSTDIO *in = new AudioFileSourceSTDIO("test_8u_16.wav"); 12 | AudioOutputSTDIO *out = new AudioOutputSTDIO(); 13 | out->SetFilename("pcm.wav"); 14 | AudioGeneratorWAV *wav = new AudioGeneratorWAV(); 15 | 16 | wav->begin(in, out); 17 | while (wav->loop()) { /*noop*/ } 18 | wav->stop(); 19 | 20 | delete wav; 21 | delete out; 22 | delete in; 23 | } 24 | -------------------------------------------------------------------------------- /src/libogg/ogg/config_types.h: -------------------------------------------------------------------------------- 1 | #ifndef __CONFIG_TYPES_H__ 2 | #define __CONFIG_TYPES_H__ 3 | 4 | /* these are filled in by configure or cmake*/ 5 | #define INCLUDE_INTTYPES_H 1 6 | #define INCLUDE_STDINT_H 1 7 | #define INCLUDE_SYS_TYPES_H 1 8 | 9 | #if INCLUDE_INTTYPES_H 10 | # include 11 | #endif 12 | #if INCLUDE_STDINT_H 13 | # include 14 | #endif 15 | #if INCLUDE_SYS_TYPES_H 16 | # include 17 | #endif 18 | 19 | typedef int16_t ogg_int16_t; 20 | typedef uint16_t ogg_uint16_t; 21 | typedef int32_t ogg_int32_t; 22 | typedef uint32_t ogg_uint32_t; 23 | typedef int64_t ogg_int64_t; 24 | typedef uint64_t ogg_uint64_t; 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /tests/host/flac.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "AudioFileSourceSTDIO.h" 3 | #include "AudioOutputSTDIO.h" 4 | #include "AudioGeneratorFLAC.h" 5 | 6 | #define AAC "gs-16b-2c-44100hz.flac" 7 | 8 | int main(int argc, char **argv) 9 | { 10 | (void) argc; 11 | (void) argv; 12 | AudioFileSourceSTDIO *in = new AudioFileSourceSTDIO(AAC); 13 | AudioOutputSTDIO *out = new AudioOutputSTDIO(); 14 | out->SetFilename("out.flac.wav"); 15 | AudioGeneratorFLAC *flac = new AudioGeneratorFLAC(); 16 | 17 | flac->begin(in, out); 18 | while (flac->loop()) { /*noop*/ } 19 | flac->stop(); 20 | 21 | delete flac; 22 | delete out; 23 | delete in; 24 | } 25 | -------------------------------------------------------------------------------- /tests/host/opus.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "AudioFileSourceSTDIO.h" 3 | #include "AudioOutputSTDIO.h" 4 | #include "AudioGeneratorOpus.h" 5 | 6 | #define OPUS "../../examples/PlayOpusFromSPIFFS/data/gs-16b-2c-44100hz.opus" 7 | 8 | int main(int argc, char **argv) 9 | { 10 | (void) argc; 11 | (void) argv; 12 | 13 | AudioFileSourceSTDIO *file = new AudioFileSourceSTDIO(OPUS); 14 | AudioOutputSTDIO *out = new AudioOutputSTDIO(); 15 | out->SetFilename("opus.wav"); 16 | AudioGeneratorOpus *opus = new AudioGeneratorOpus(); 17 | 18 | opus->begin(file, out); 19 | while (opus->loop()) { /*noop*/ } 20 | opus->stop(); 21 | 22 | delete out; 23 | delete opus; 24 | delete file; 25 | } 26 | -------------------------------------------------------------------------------- /examples/PlayAACFromPROGMEM/PlayAACFromPROGMEM.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include "AudioGeneratorAAC.h" 3 | #include "AudioOutputI2S.h" 4 | #include "AudioFileSourcePROGMEM.h" 5 | #include "sampleaac.h" 6 | 7 | AudioFileSourcePROGMEM *in; 8 | AudioGeneratorAAC *aac; 9 | AudioOutputI2S *out; 10 | 11 | void setup() 12 | { 13 | Serial.begin(115200); 14 | 15 | audioLogger = &Serial; 16 | in = new AudioFileSourcePROGMEM(sampleaac, sizeof(sampleaac)); 17 | aac = new AudioGeneratorAAC(); 18 | out = new AudioOutputI2S(); 19 | 20 | aac->begin(in, out); 21 | } 22 | 23 | 24 | void loop() 25 | { 26 | if (aac->isRunning()) { 27 | aac->loop(); 28 | } else { 29 | Serial.printf("AAC done\n"); 30 | delay(1000); 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /tests/host/aac.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "AudioFileSourceSTDIO.h" 3 | #include "AudioOutputSTDIO.h" 4 | #include "AudioGeneratorAAC.h" 5 | 6 | #define AAC "../../examples/PlayAACFromPROGMEM/homer.aac" 7 | 8 | int main(int argc, char **argv) 9 | { 10 | (void) argc; 11 | (void) argv; 12 | AudioFileSourceSTDIO *in = new AudioFileSourceSTDIO(AAC); 13 | AudioOutputSTDIO *out = new AudioOutputSTDIO(); 14 | out->SetFilename("out.aac.wav"); 15 | void *space = malloc(28000+60000); 16 | AudioGeneratorAAC *aac = new AudioGeneratorAAC(space, 28000+60000); 17 | 18 | aac->begin(in, out); 19 | while (aac->loop()) { /*noop*/ } 20 | aac->stop(); 21 | 22 | delete aac; 23 | delete out; 24 | delete in; 25 | 26 | free(space); 27 | } 28 | -------------------------------------------------------------------------------- /examples/PlayFLACFromPROGMEMToDAC/PlayFLACFromPROGMEMToDAC.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "sample.h" 7 | 8 | AudioOutputI2S *out; 9 | AudioFileSourcePROGMEM *file; 10 | AudioGeneratorFLAC *flac; 11 | 12 | void setup() 13 | { 14 | Serial.begin(115200); 15 | Serial.println("Starting up...\n"); 16 | 17 | audioLogger = &Serial; 18 | file = new AudioFileSourcePROGMEM( sample_flac, sizeof(sample_flac) ); 19 | out = new AudioOutputI2S(); 20 | flac = new AudioGeneratorFLAC(); 21 | flac->begin(file, out); 22 | } 23 | 24 | void loop() 25 | { 26 | if (flac->isRunning()) { 27 | if (!flac->loop()) flac->stop(); 28 | } else { 29 | Serial.printf("FLAC done\n"); 30 | delay(1000); 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ESP8266Audio", 3 | "description": "Audio file format and I2S DAC library for ESP8266, ESP32, and Raspberry Pi Pico RP2040", 4 | "keywords": "ESP8266, ESP32, MP3, AAC, WAV, MOD, FLAC, RTTTL, MIDI, I2S, DAC, Delta-Sigma, TTS", 5 | "authors": [ 6 | { 7 | "name": "Earle F. Philhower, III", 8 | "email": "earlephilhower@yahoo.com", 9 | "url": "https://github.com/earlephilhower/ESP8266Audio", 10 | "maintainer": true 11 | } 12 | ], 13 | "repository": { 14 | "type": "git", 15 | "url": "https://github.com/earlephilhower/ESP8266Audio" 16 | }, 17 | "version": "1.9.3", 18 | "homepage": "https://github.com/earlephilhower/ESP8266Audio", 19 | "frameworks": "Arduino", 20 | "examples": [ 21 | "examples/*/*.ino" 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /examples/PlayWAVFromPROGMEM/PlayWAVFromPROGMEM.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "AudioFileSourcePROGMEM.h" 4 | #include "AudioGeneratorWAV.h" 5 | #include "AudioOutputI2SNoDAC.h" 6 | 7 | // VIOLA sample taken from https://ccrma.stanford.edu/~jos/pasp/Sound_Examples.html 8 | #include "viola.h" 9 | 10 | AudioGeneratorWAV *wav; 11 | AudioFileSourcePROGMEM *file; 12 | AudioOutputI2SNoDAC *out; 13 | 14 | void setup() 15 | { 16 | Serial.begin(115200); 17 | delay(1000); 18 | Serial.printf("WAV start\n"); 19 | 20 | audioLogger = &Serial; 21 | file = new AudioFileSourcePROGMEM( viola, sizeof(viola) ); 22 | out = new AudioOutputI2SNoDAC(); 23 | wav = new AudioGeneratorWAV(); 24 | wav->begin(file, out); 25 | } 26 | 27 | void loop() 28 | { 29 | if (wav->isRunning()) { 30 | if (!wav->loop()) wav->stop(); 31 | } else { 32 | Serial.printf("WAV done\n"); 33 | delay(1000); 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /src/libflac/share/utf8.h: -------------------------------------------------------------------------------- 1 | #ifndef SHARE__UTF8_H 2 | #define SHARE__UTF8_H 3 | 4 | /* 5 | * Convert a string between UTF-8 and the locale's charset. 6 | * Invalid bytes are replaced by '#', and characters that are 7 | * not available in the target encoding are replaced by '?'. 8 | * 9 | * If the locale's charset is not set explicitly then it is 10 | * obtained using nl_langinfo(CODESET), where available, the 11 | * environment variable CHARSET, or assumed to be US-ASCII. 12 | * 13 | * Return value of conversion functions: 14 | * 15 | * -1 : memory allocation failed 16 | * 0 : data was converted exactly 17 | * 1 : valid data was converted approximately (using '?') 18 | * 2 : input was invalid (but still converted, using '#') 19 | * 3 : unknown encoding (but still converted, using '?') 20 | */ 21 | 22 | int utf8_encode(const char *from, char **to); 23 | int utf8_decode(const char *from, char **to); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /tests/host/midi.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "AudioFileSourceSTDIO.h" 3 | #include "AudioOutputSTDIO.h" 4 | #include "AudioGeneratorMIDI.h" 5 | 6 | #define SF2 "../../examples/PlayMIDIFromLittleFS/data/1mgm.sf2" 7 | #define MIDI "../../examples/PlayMIDIFromLittleFS/data/furelise.mid" 8 | 9 | 10 | int main(int argc, char **argv) 11 | { 12 | (void) argc; 13 | (void) argv; 14 | AudioFileSourceSTDIO *midifile = new AudioFileSourceSTDIO(MIDI); 15 | AudioFileSourceSTDIO *sf2file = new AudioFileSourceSTDIO(SF2); 16 | AudioOutputSTDIO *out = new AudioOutputSTDIO(); 17 | out->SetFilename("midi.wav"); 18 | AudioGeneratorMIDI *midi = new AudioGeneratorMIDI(); 19 | 20 | midi->SetSoundfont(sf2file); 21 | midi->SetSampleRate(22050); 22 | 23 | midi->begin(midifile, out); 24 | while (midi->loop()) { /*noop*/ } 25 | midi->stop(); 26 | 27 | delete out; 28 | delete midi; 29 | delete midifile; 30 | delete sf2file; 31 | } 32 | -------------------------------------------------------------------------------- /src/opusfile/README.md: -------------------------------------------------------------------------------- 1 | # Opusfile 2 | 3 | [![GitLab Pipeline Status](https://gitlab.xiph.org/xiph/opusfile/badges/master/pipeline.svg)](https://gitlab.xiph.org/xiph/opusfile/commits/master) 4 | [![Travis Build Status](https://travis-ci.org/xiph/opusfile.svg?branch=master)](https://travis-ci.org/xiph/opusfile) 5 | [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/xiph/opusfile?branch=master&svg=true)](https://ci.appveyor.com/project/rillian/opusfile) 6 | 7 | The opusfile and opusurl libraries provide a high-level API for 8 | decoding and seeking within .opus files on disk or over http(s). 9 | 10 | opusfile depends on libopus and libogg. 11 | opusurl depends on opusfile and openssl. 12 | 13 | The library is functional, but there are likely issues 14 | we didn't find in our own testing. Please give feedback 15 | in #opus on irc.freenode.net or at opus@xiph.org. 16 | 17 | Programming documentation is available in tree and online at 18 | https://opus-codec.org/docs/ 19 | -------------------------------------------------------------------------------- /src/libmad/COPYRIGHT: -------------------------------------------------------------------------------- 1 | 2 | libmad - MPEG audio decoder library 3 | Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | If you would like to negotiate alternate licensing terms, you may do 20 | so by contacting: Underbit Technologies, Inc. 21 | 22 | -------------------------------------------------------------------------------- /keywords.txt: -------------------------------------------------------------------------------- 1 | AudioFileSource KEYWORD1 2 | AudioFileSourceSPIFFS KEYWORD1 3 | AudioFileSourceLittleFS KEYWORD1 4 | AudioFileSourceFS KEYWORD1 5 | AudioFileSourcePROGMEM KEYWORD1 6 | AudioFileSourceHTTPStream KEYWORD1 7 | AudioFileSourceICYStream KEYWORD1 8 | AudioFileSourceID3 KEYWORD1 9 | AudioFileSourceSD KEYWORD1 10 | AudioFileSourceBuffer KEYWORD1 11 | AudioFileSourceSPIRAMBuffer KEYWORD1 12 | AudioGenerator KEYWORD1 13 | AudioGeneratorAAC KEYWORD1 14 | AudioGeneratorFLAC KEYWORD1 15 | AudioGeneratorMOD KEYWORD1 16 | AudioGeneratorMIDI KEYWORD1 17 | AudioGeneratorMP3 KEYWORD1 18 | AudioGeneratorOpus KEYWORD1 19 | AudioGeneratorRTTTL KEYWORD1 20 | AudioGeneratorTalkie KEYWORD1 21 | AudioGeneratorWAV KEYWORD1 22 | AudioOutput KEYWORD1 23 | AudioOutputI2S KEYWORD1 24 | AudioOutputI2SNoDAC KEYWORD1 25 | AudioOutputI2SClass KEYWORD1 26 | AudioOutputNull KEYWORD1 27 | AudioOutputBuffer KEYWORD1 28 | AudioOutputSerialWAV KEYWORD1 29 | AudioOutputSPIFFSWAV KEYWORD1 30 | AudioOutputMixer KEYWORD1 31 | AudioOutputMixerStub KEYWORD1 32 | AudioOutputSPDIF KEYWORD1 33 | -------------------------------------------------------------------------------- /src/libmad/mad.h.sed: -------------------------------------------------------------------------------- 1 | # 2 | # libmad - MPEG audio decoder library 3 | # Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 2 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | # 19 | # $Id: mad.h.sed,v 1.9 2004/01/23 09:41:32 rob Exp $ 20 | # 21 | 22 | /^\/\*$/{ 23 | N 24 | s/ \* libmad - /&/ 25 | t copy 26 | b next 27 | : copy 28 | g 29 | n 30 | s|^ \* \$\(Id: .*\) \$$|/* \1 */|p 31 | /^ \*\/$/d 32 | b copy 33 | } 34 | /^# *include "/d 35 | : next 36 | p 37 | -------------------------------------------------------------------------------- /examples/PlayOpusFromSPIFFS/PlayOpusFromSPIFFS.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #ifdef ESP32 3 | #include 4 | #include "SPIFFS.h" 5 | #else 6 | #include 7 | #endif 8 | #include "AudioFileSourceSPIFFS.h" 9 | #include "AudioGeneratorOpus.h" 10 | #include "AudioOutputI2S.h" 11 | 12 | // The includes OPUS file is from Kevin MacLeod (incompetech.com), Licensed under Creative Commons: By Attribution 3.0, http://creativecommons.org/licenses/by/3.0/ 13 | 14 | AudioGeneratorOpus *opus; 15 | AudioFileSourceSPIFFS *file; 16 | AudioOutputI2S *out; 17 | 18 | void setup() 19 | { 20 | WiFi.mode(WIFI_OFF); 21 | Serial.begin(115200); 22 | delay(1000); 23 | SPIFFS.begin(); 24 | Serial.printf("Sample Opus playback begins...\n"); 25 | 26 | audioLogger = &Serial; 27 | file = new AudioFileSourceSPIFFS("/gs-16b-2c-44100hz.opus"); 28 | out = new AudioOutputI2S(); 29 | opus = new AudioGeneratorOpus(); 30 | opus->begin(file, out); 31 | } 32 | 33 | void loop() 34 | { 35 | if (opus->isRunning()) { 36 | if (!opus->loop()) opus->stop(); 37 | } else { 38 | Serial.printf("Opus done\n"); 39 | delay(1000); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/libmad/layer3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: layer3.h,v 1.10 2004/01/23 09:41:32 rob Exp $ 20 | */ 21 | 22 | # ifndef LIBMAD_LAYER3_H 23 | # define LIBMAD_LAYER3_H 24 | 25 | # include "stream.h" 26 | # include "frame.h" 27 | 28 | int mad_layer_III(struct mad_stream *, struct mad_frame *); 29 | 30 | # endif 31 | -------------------------------------------------------------------------------- /src/libtinysoundfont/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2017 Bernhard Schelling 2 | Based on SFZero, Copyright (C) 2012 Steve Folta (https://github.com/stevefolta/SFZero) 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | this software and associated documentation files (the "Software"), to deal in 6 | the Software without restriction, including without limitation the rights to 7 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | of the Software, and to permit persons to whom the Software is furnished to do 9 | so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | -------------------------------------------------------------------------------- /examples/PlayMODFromPROGMEMToDAC/PlayMODFromPROGMEMToDAC.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include "AudioFileSourcePROGMEM.h" 3 | #include "AudioGeneratorMOD.h" 4 | #include "AudioOutputI2S.h" 5 | #ifdef ESP32 6 | #include 7 | #else 8 | #include 9 | #endif 10 | 11 | // enigma.mod sample from the mod archive: https://modarchive.org/index.php?request=view_by_moduleid&query=42146 12 | #include "enigma.h" 13 | 14 | AudioGeneratorMOD *mod; 15 | AudioFileSourcePROGMEM *file; 16 | AudioOutputI2S *out; 17 | 18 | void setup() 19 | { 20 | WiFi.mode(WIFI_OFF); //WiFi.forceSleepBegin(); 21 | Serial.begin(115200); 22 | delay(1000); 23 | 24 | audioLogger = &Serial; 25 | file = new AudioFileSourcePROGMEM( enigma_mod, sizeof(enigma_mod) ); 26 | // out = new AudioOutputI2S(0, 1); Uncomment this line, comment the next one to use the internal DAC channel 1 (pin25) on ESP32 27 | out = new AudioOutputI2S(); 28 | mod = new AudioGeneratorMOD(); 29 | mod->SetBufferSize(3*1024); 30 | mod->SetSampleRate(44100); 31 | mod->SetStereoSeparation(32); 32 | mod->begin(file, out); 33 | } 34 | 35 | void loop() 36 | { 37 | if (mod->isRunning()) { 38 | if (!mod->loop()) mod->stop(); 39 | } else { 40 | Serial.printf("MOD done\n"); 41 | delay(1000); 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /src/AudioFileStream.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "AudioFileStream.h" 3 | 4 | 5 | AudioFileStream::AudioFileStream(AudioFileSource *source, int definedLen) 6 | { 7 | src = source; 8 | len = definedLen; 9 | ptr = 0; 10 | saved = -1; 11 | } 12 | 13 | AudioFileStream::~AudioFileStream() 14 | { 15 | // If there's a defined len, read until we're empty 16 | if (len) { 17 | while (ptr++ < len) (void)read(); 18 | } 19 | } 20 | 21 | 22 | int AudioFileStream::available() 23 | { 24 | if (saved >= 0) return 1; 25 | else if (len) return ptr - len; 26 | else if (src->getSize()) return (src->getPos() - src->getSize()); 27 | else return 1; 28 | } 29 | 30 | int AudioFileStream::read() 31 | { 32 | uint8_t c; 33 | int r; 34 | if (ptr >= len) return -1; 35 | ptr++; 36 | if (saved >= 0) { 37 | c = (uint8_t)saved; 38 | saved = -1; 39 | r = 1; 40 | } else { 41 | r = src->read(&c, 1); 42 | } 43 | if (r != 1) return -1; 44 | return (int)c; 45 | } 46 | 47 | int AudioFileStream::peek() 48 | { 49 | uint8_t c; 50 | if ((ptr+1) >= len) return -1; 51 | if (saved >= 0) return saved; 52 | int r = src->read(&c, 1); 53 | if (r<1) return -1; 54 | saved = c; 55 | return saved; 56 | } 57 | 58 | void AudioFileStream::flush() 59 | { 60 | /* noop? */ 61 | } 62 | -------------------------------------------------------------------------------- /examples/PlayRTTTLToI2SDAC/PlayRTTTLToI2SDAC.ino: -------------------------------------------------------------------------------- 1 | #include "AudioFileSourcePROGMEM.h" 2 | #include "AudioGeneratorRTTTL.h" 3 | #include "AudioOutputI2S.h" 4 | 5 | const char rudolph[] PROGMEM = 6 | "Rudolph the Red Nosed Raindeer:d=8,o=5,b=250:g,4a,g,4e,4c6,4a,2g.,g,a,g,a,4g,4c6,2b.,4p,f,4g,f,4d,4b,4a,2g.,g,a,g,a,4g,4a,2e.,4p,g,4a,a,4e,4c6,4a,2g.,g,a,g,a,4g,4c6,2b.,4p,f,4g,f,4d,4b,4a,2g.,g,a,g,a,4g,4d6,2c.6,4p,4a,4a,4c6,4a,4g,4e,2g,4d,4e,4g,4a,4b,4b,2b,4c6,4c6,4b,4a,4g,4f,2d,g,4a,g,4e,4c6,4a,2g.,g,a,g,a,4g,4c6,2b.,4p,f,4g,f,4d,4b,4a,2g.,4g,4a,4g,4a,2g,2d6,1c.6."; 7 | // Plenty more at: http://mines.lumpylumpy.com/Electronics/Computers/Software/Cpp/MFC/RingTones.RTTTL 8 | 9 | AudioGeneratorRTTTL *rtttl; 10 | AudioFileSourcePROGMEM *file; 11 | AudioOutputI2S *out; 12 | 13 | void setup() 14 | { 15 | Serial.begin(115200); 16 | delay(1000); 17 | 18 | Serial.printf("RTTTL start\n"); 19 | 20 | audioLogger = &Serial; 21 | file = new AudioFileSourcePROGMEM( rudolph, strlen_P(rudolph) ); 22 | out = new AudioOutputI2S(); 23 | rtttl = new AudioGeneratorRTTTL(); 24 | rtttl->begin(file, out); 25 | } 26 | 27 | void loop() 28 | { 29 | if (rtttl->isRunning()) { 30 | if (!rtttl->loop()) rtttl->stop(); 31 | } else { 32 | Serial.printf("RTTTL done\n"); 33 | delay(1000); 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /examples/PlayMIDIFromSPIFFS/PlayMIDIFromSPIFFS.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #ifdef ESP32 3 | #include 4 | #include "SPIFFS.h" 5 | #else 6 | #include 7 | #endif 8 | 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | AudioFileSourceSPIFFS *sf2; 16 | AudioFileSourceSPIFFS *mid; 17 | AudioOutputI2S *dac; 18 | AudioGeneratorMIDI *midi; 19 | 20 | void setup() 21 | { 22 | const char *soundfont = "/1mgm.sf2"; 23 | const char *midifile = "/furelise.mid"; 24 | 25 | WiFi.mode(WIFI_OFF); 26 | 27 | Serial.begin(115200); 28 | Serial.println("Starting up...\n"); 29 | 30 | audioLogger = &Serial; 31 | sf2 = new AudioFileSourceSPIFFS(soundfont); 32 | mid = new AudioFileSourceSPIFFS(midifile); 33 | 34 | dac = new AudioOutputI2S(); 35 | midi = new AudioGeneratorMIDI(); 36 | midi->SetSoundfont(sf2); 37 | midi->SetSampleRate(22050); 38 | Serial.printf("BEGIN...\n"); 39 | midi->begin(mid, dac); 40 | } 41 | 42 | void loop() 43 | { 44 | if (midi->isRunning()) { 45 | if (!midi->loop()) { 46 | uint32_t e = millis(); 47 | midi->stop(); 48 | } 49 | } else { 50 | Serial.printf("MIDI done\n"); 51 | delay(1000); 52 | } 53 | } 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/AudioOutputSerialWAV.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioOutputSerialWAV 3 | Writes a mostly correct WAV file to the serial port 4 | 5 | Copyright (C) 2017 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #ifndef _AUDIOOUTPUTSERIALWAV_H 22 | #define _AUDIOOUTPUTSERIALWAV_H 23 | 24 | #include "AudioOutput.h" 25 | 26 | class AudioOutputSerialWAV : public AudioOutput 27 | { 28 | public: 29 | AudioOutputSerialWAV() {}; 30 | ~AudioOutputSerialWAV() {}; 31 | virtual bool begin() override; 32 | virtual bool ConsumeSample(int16_t sample[2]) override; 33 | virtual bool stop() override; 34 | private: 35 | int count; 36 | }; 37 | 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /examples/PlayMIDIFromLittleFS/PlayMIDIFromLittleFS.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #ifdef ESP32 3 | void setup() { 4 | Serial.begin(115200); 5 | Serial.printf("ERROR - ESP32 does not support LittleFS\n"); 6 | } 7 | void loop() {} 8 | #else 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | AudioFileSourceLittleFS *sf2; 15 | AudioFileSourceLittleFS *mid; 16 | AudioOutputI2S *dac; 17 | AudioGeneratorMIDI *midi; 18 | 19 | void setup() 20 | { 21 | const char *soundfont = "/1mgm.sf2"; 22 | const char *midifile = "/furelise.mid"; 23 | 24 | WiFi.mode(WIFI_OFF); 25 | 26 | Serial.begin(115200); 27 | Serial.println("Starting up...\n"); 28 | 29 | audioLogger = &Serial; 30 | sf2 = new AudioFileSourceLittleFS(soundfont); 31 | mid = new AudioFileSourceLittleFS(midifile); 32 | 33 | dac = new AudioOutputI2S(); 34 | midi = new AudioGeneratorMIDI(); 35 | midi->SetSoundfont(sf2); 36 | midi->SetSampleRate(22050); 37 | Serial.printf("BEGIN...\n"); 38 | midi->begin(mid, dac); 39 | } 40 | 41 | void loop() 42 | { 43 | if (midi->isRunning()) { 44 | if (!midi->loop()) { 45 | uint32_t e = millis(); 46 | midi->stop(); 47 | } 48 | } else { 49 | Serial.printf("MIDI done\n"); 50 | delay(1000); 51 | } 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/AudioFileSourceSPIFFS.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioFileSourceFS 3 | Input Arduion "file" to be used by AudioGenerator 4 | 5 | Copyright (C) 2017 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #ifndef _AUDIOFILESOURCESPIFFS_H 22 | #define _AUDIOFILESOURCESPIFFS_H 23 | 24 | #include 25 | #include 26 | 27 | #include "AudioFileSource.h" 28 | #include "AudioFileSourceFS.h" 29 | 30 | class AudioFileSourceSPIFFS : public AudioFileSourceFS 31 | { 32 | public: 33 | AudioFileSourceSPIFFS() : AudioFileSourceFS(SPIFFS) { }; 34 | AudioFileSourceSPIFFS(const char *filename) : AudioFileSourceFS(SPIFFS, filename) {}; 35 | // Others are inherited from base 36 | }; 37 | 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /src/AudioFileSourceLittleFS.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioFileSourceFS 3 | Input Arduion "file" to be used by AudioGenerator 4 | 5 | Copyright (C) 2017 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #ifndef _AUDIOFILESOURCESPIFFS_H 22 | #define _AUDIOFILESOURCESPIFFS_H 23 | 24 | #include 25 | #include 26 | 27 | #include "AudioFileSource.h" 28 | #include "AudioFileSourceFS.h" 29 | 30 | class AudioFileSourceLittleFS : public AudioFileSourceFS 31 | { 32 | public: 33 | AudioFileSourceLittleFS() : AudioFileSourceFS(LittleFS) { }; 34 | AudioFileSourceLittleFS(const char *filename) : AudioFileSourceFS(LittleFS, filename) {}; 35 | // Others are inherited from base 36 | }; 37 | 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /src/AudioOutputSPIFFSWAV.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioOutputSPIFFSWAV 3 | Writes a WAV file to the SPIFFS filesystem 4 | 5 | Copyright (C) 2017 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #ifndef _AUDIOOUTPUTSPIFFSWAV_H 22 | #define _AUDIOOUTPUTSPIFFSWAV_H 23 | 24 | #include 25 | #include 26 | 27 | #include "AudioOutput.h" 28 | 29 | class AudioOutputSPIFFSWAV : public AudioOutput 30 | { 31 | public: 32 | AudioOutputSPIFFSWAV() { filename = NULL; }; 33 | ~AudioOutputSPIFFSWAV() { free(filename); }; 34 | virtual bool begin() override; 35 | virtual bool ConsumeSample(int16_t sample[2]) override; 36 | virtual bool stop() override; 37 | void SetFilename(const char *name); 38 | 39 | private: 40 | File f; 41 | char *filename; 42 | }; 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /src/libtinysoundfont/README.md: -------------------------------------------------------------------------------- 1 | # TinySoundFont 2 | SoundFont2 synthesizer library in a single C/C++ file 3 | 4 | ## Overview 5 | 6 | TinySoundFont is a software synthesizer using SoundFont2 sound bank files. 7 | 8 | The library is a single C header file so it is extremely simple to integrate in your C/C++ projects. 9 | 10 | ```c++ 11 | #define TSF_IMPLEMENTATION 12 | #include "tsf.h" 13 | 14 | ... 15 | 16 | tsf* TinySoundFont = tsf_load_filename("soundfont.sf2"); 17 | tsf_set_output(TinySoundFont, TSF_MONO, 44100, 0); //sample rate 18 | tsf_note_on(TinySoundFont, 0, 60, 1.0f); //preset 0, middle C 19 | short HalfSecond[22050]; //synthesize 0.5 seconds 20 | tsf_render_short(TinySoundFont, HalfSecond, 22050, 0); 21 | ``` 22 | 23 | The library code is based on [SFZero by Steve Folta](https://github.com/stevefolta/SFZero). 24 | 25 | ## Documentation 26 | 27 | The API documentation can be found on [top of the library source code](https://github.com/schellingb/TinySoundFont/blob/master/tsf.h). 28 | 29 | There are also [examples available](https://github.com/schellingb/TinySoundFont/tree/master/examples) which come with a sample SoundFont file and build and play sound on Win32, Win64, Linux and MacOSX with no further dependencies. 30 | 31 | ## Dependencies 32 | 33 | C standard libraries for fopen, math and malloc (can be removed by providing custom functions with #defines). 34 | 35 | ## License 36 | 37 | TinySoundFont is available under the [MIT license](https://choosealicense.com/licenses/mit/). 38 | -------------------------------------------------------------------------------- /src/AudioOutputSTDIO.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioOutputSTDIO 3 | Writes a WAV file to the STDIO filesystem 4 | Only for host-based testing 5 | 6 | Copyright (C) 2017 Earle F. Philhower, III 7 | 8 | This program is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program. If not, see . 20 | */ 21 | 22 | #ifndef _AUDIOOUTPUTSTDIO_H 23 | #define _AUDIOOUTPUTSTDIO_H 24 | 25 | #include 26 | #ifndef ARDUINO 27 | 28 | #include "AudioOutput.h" 29 | 30 | class AudioOutputSTDIO : public AudioOutput 31 | { 32 | public: 33 | AudioOutputSTDIO() { filename = NULL; f = NULL; }; 34 | ~AudioOutputSTDIO() { free(filename); }; 35 | virtual bool begin() override; 36 | virtual bool ConsumeSample(int16_t sample[2]) override; 37 | virtual bool stop() override; 38 | void SetFilename(const char *name); 39 | 40 | private: 41 | FILE *f; 42 | char *filename; 43 | }; 44 | 45 | #endif 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/AudioFileStream.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioFileStream 3 | Convert an AudioFileSource* to a Stream* 4 | 5 | Copyright (C) 2017 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #ifndef AUDIOFILESTREAM_H 22 | #define AUDIOFILESTREAM_H 23 | 24 | #include 25 | #include "AudioFileSource.h" 26 | 27 | class AudioFileStream : public Stream 28 | { 29 | public: 30 | AudioFileStream(AudioFileSource *source, int definedLen); 31 | virtual ~AudioFileStream(); 32 | 33 | public: 34 | // Stream interface - see the Arduino library documentation. 35 | virtual int available() override; 36 | virtual int read() override; 37 | virtual int peek() override; 38 | virtual void flush() override; 39 | virtual size_t write(uint8_t x) override { (void)x; return 0; }; 40 | 41 | private: 42 | AudioFileSource *src; 43 | int saved; 44 | int len; 45 | int ptr; 46 | }; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/libogg/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2002, Xiph.org Foundation 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | are met: 6 | 7 | - Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | - Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 14 | - Neither the name of the Xiph.org Foundation nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION 22 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /src/AudioFileSourceICYStream.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioFileSourceHTTPStream 3 | Connect to a HTTP based streaming service 4 | 5 | Copyright (C) 2017 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #if defined(ESP32) || defined(ESP8266) 22 | #pragma once 23 | 24 | #include 25 | #ifdef ESP32 26 | #include 27 | #else 28 | #include 29 | #endif 30 | 31 | #include "AudioFileSourceHTTPStream.h" 32 | 33 | class AudioFileSourceICYStream : public AudioFileSourceHTTPStream 34 | { 35 | public: 36 | AudioFileSourceICYStream(); 37 | AudioFileSourceICYStream(const char *url); 38 | virtual ~AudioFileSourceICYStream() override; 39 | 40 | virtual bool open(const char *url) override; 41 | 42 | private: 43 | virtual uint32_t readInternal(void *data, uint32_t len, bool nonBlock) override; 44 | int icyMetaInt; 45 | int icyByteCount; 46 | }; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/AudioOutputNull.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioOutput 3 | Base class of an audio output player 4 | 5 | Copyright (C) 2017 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #ifndef _AUDIOOUTPUTNULL_H 22 | #define _AUDIOOUTPUTNULL_H 23 | 24 | #include "AudioOutput.h" 25 | 26 | class AudioOutputNull : public AudioOutput 27 | { 28 | public: 29 | AudioOutputNull() {}; 30 | ~AudioOutputNull() {}; 31 | virtual bool begin() { samples = 0; startms = millis(); return true; } 32 | virtual bool ConsumeSample(int16_t sample[2]) { (void)sample; samples++; return true; } 33 | virtual bool stop() { endms = millis(); return true; }; 34 | unsigned long GetMilliseconds() { return endms - startms; } 35 | int GetSamples() { return samples; } 36 | int GetFrequency() { return hertz; } 37 | 38 | protected: 39 | unsigned long startms; 40 | unsigned long endms; 41 | int samples; 42 | }; 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /src/opusfile/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 1994-2013 Xiph.Org Foundation and contributors 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | are met: 6 | 7 | - Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | - Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 14 | - Neither the name of the Xiph.Org Foundation nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION 22 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /src/AudioFileSourceID3.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioFileSourceID3 3 | ID3 filter that extracts any ID3 fields and sends to CB function 4 | 5 | Copyright (C) 2017 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #ifndef _AUDIOFILESOURCEID3_H 22 | #define _AUDIOFILESOURCEID3_H 23 | 24 | #include 25 | 26 | #include "AudioFileSource.h" 27 | 28 | class AudioFileSourceID3 : public AudioFileSource 29 | { 30 | public: 31 | AudioFileSourceID3(AudioFileSource *src); 32 | virtual ~AudioFileSourceID3() override; 33 | 34 | virtual uint32_t read(void *data, uint32_t len) override; 35 | virtual bool seek(int32_t pos, int dir) override; 36 | virtual bool close() override; 37 | virtual bool isOpen() override; 38 | virtual uint32_t getSize() override; 39 | virtual uint32_t getPos() override; 40 | 41 | private: 42 | AudioFileSource *src; 43 | bool checked; 44 | }; 45 | 46 | 47 | #endif 48 | 49 | -------------------------------------------------------------------------------- /src/opusfile/internal.c: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE libopusfile SOFTWARE CODEC SOURCE CODE. * 4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 7 | * * 8 | * THE libopusfile SOURCE CODE IS (C) COPYRIGHT 2012-2020 * 9 | * by the Xiph.Org Foundation and contributors https://xiph.org/ * 10 | * * 11 | ********************************************************************/ 12 | //#ifdef HAVE_CONFIG_H 13 | #include "config.h" 14 | //#endif 15 | 16 | #include "internal.h" 17 | 18 | #if defined(OP_ENABLE_ASSERTIONS) 19 | void op_fatal_impl(const char *_str,const char *_file,int _line){ 20 | fprintf(stderr,"Fatal (internal) error in %s, line %i: %s\n", 21 | _file,_line,_str); 22 | abort(); 23 | } 24 | #endif 25 | 26 | /*A version of strncasecmp() that is guaranteed to only ignore the case of 27 | ASCII characters.*/ 28 | int op_strncasecmp(const char *_a,const char *_b,int _n){ 29 | int i; 30 | for(i=0;i<_n;i++){ 31 | int a; 32 | int b; 33 | int d; 34 | a=_a[i]; 35 | b=_b[i]; 36 | if(a>='a'&&a<='z')a-='a'-'A'; 37 | if(b>='a'&&b<='z')b-='a'-'A'; 38 | d=a-b; 39 | if(d)return d; 40 | } 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /src/AudioFileSourceSD.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioFileSourceSPIFFS 3 | Input SD card "file" to be used by AudioGenerator 4 | 5 | Copyright (C) 2017 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #ifndef _AUDIOFILESOURCESD_H 22 | #define _AUDIOFILESOURCESD_H 23 | 24 | #include "AudioFileSource.h" 25 | #include 26 | 27 | 28 | class AudioFileSourceSD : public AudioFileSource 29 | { 30 | public: 31 | AudioFileSourceSD(); 32 | AudioFileSourceSD(const char *filename); 33 | virtual ~AudioFileSourceSD() override; 34 | 35 | virtual bool open(const char *filename) override; 36 | virtual uint32_t read(void *data, uint32_t len) override; 37 | virtual bool seek(int32_t pos, int dir) override; 38 | virtual bool close() override; 39 | virtual bool isOpen() override; 40 | virtual uint32_t getSize() override; 41 | virtual uint32_t getPos() override; 42 | 43 | private: 44 | File f; 45 | }; 46 | 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /src/libflac/COPYING.Xiph: -------------------------------------------------------------------------------- 1 | Copyright (C) 2000-2009 Josh Coalson 2 | Copyright (C) 2011-2016 Xiph.Org Foundation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | - Neither the name of the Xiph.org Foundation nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 23 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /src/AudioOutputBuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioOutputBuffer 3 | Adds additional bufferspace to the output chain 4 | 5 | Copyright (C) 2017 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #ifndef _AUDIOOUTPUTBUFFER_H 22 | #define _AUDIOOUTPUTBUFFER_H 23 | 24 | #include "AudioOutput.h" 25 | 26 | class AudioOutputBuffer : public AudioOutput 27 | { 28 | public: 29 | AudioOutputBuffer(int bufferSizeSamples, AudioOutput *dest); 30 | virtual ~AudioOutputBuffer() override; 31 | virtual bool SetRate(int hz) override; 32 | virtual bool SetBitsPerSample(int bits) override; 33 | virtual bool SetChannels(int channels) override; 34 | virtual bool begin() override; 35 | virtual bool ConsumeSample(int16_t sample[2]) override; 36 | virtual bool stop() override; 37 | 38 | protected: 39 | AudioOutput *sink; 40 | int buffSize; 41 | int16_t *leftSample; 42 | int16_t *rightSample; 43 | int writePtr; 44 | int readPtr; 45 | bool filled; 46 | }; 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /src/libhelix-mp3/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved. 2 | 3 | The contents of this directory, and (except where otherwise 4 | indicated) the directories included within this directory, are 5 | subject to the current version of the RealNetworks Public Source 6 | License (the "RPSL") available at RPSL.txt in this directory, unless 7 | you have licensed the directory under the current version of the 8 | RealNetworks Community Source License (the "RCSL") available at 9 | RCSL.txt in this directory, in which case the RCSL will apply. You 10 | may also obtain the license terms directly from RealNetworks. You 11 | may not use the files in this directory except in compliance with the 12 | RPSL or, if you have a valid RCSL with RealNetworks applicable to 13 | this directory, the RCSL. Please see the applicable RPSL or RCSL for 14 | the rights, obligations and limitations governing use of the contents 15 | of the directory. 16 | 17 | This directory is part of the Helix DNA Technology. RealNetworks is 18 | the developer of the Original Code and owns the copyrights in the 19 | portions it created. 20 | 21 | This directory, and the directories included with this directory, are 22 | distributed and made available on an 'AS IS' basis, WITHOUT WARRANTY 23 | OF ANY KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY 24 | DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY 25 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, 26 | QUIET ENJOYMENT OR NON-INFRINGEMENT. 27 | 28 | Technology Compatibility Kit Test Suite(s) Location: 29 | http://www.helixcommunity.org/content/tck 30 | 31 | -------------------------------------------------------------------------------- /src/ESP8266Audio.h: -------------------------------------------------------------------------------- 1 | // Lazy "include all the things" header for simplicity. 2 | // In general a user should only include the specific headers they need 3 | // to miniimize build times. 4 | 5 | // Input stage 6 | #include "AudioFileSourceBuffer.h" 7 | #include "AudioFileSourceFATFS.h" 8 | #include "AudioFileSourceFS.h" 9 | #include "AudioFileSource.h" 10 | #include "AudioFileSourceHTTPStream.h" 11 | #include "AudioFileSourceICYStream.h" 12 | #include "AudioFileSourceID3.h" 13 | #include "AudioFileSourceLittleFS.h" 14 | #include "AudioFileSourcePROGMEM.h" 15 | #include "AudioFileSourceSD.h" 16 | #include "AudioFileSourceSPIFFS.h" 17 | #include "AudioFileSourceSPIRAMBuffer.h" 18 | #include "AudioFileSourceSTDIO.h" 19 | 20 | // Misc. plumbing 21 | #include "AudioFileStream.h" 22 | #include "AudioLogger.h" 23 | #include "AudioStatus.h" 24 | 25 | // Actual decode/audio generation logic 26 | #include "AudioGeneratorAAC.h" 27 | #include "AudioGeneratorFLAC.h" 28 | #include "AudioGenerator.h" 29 | #include "AudioGeneratorMIDI.h" 30 | #include "AudioGeneratorMOD.h" 31 | #include "AudioGeneratorMP3a.h" 32 | #include "AudioGeneratorMP3.h" 33 | #include "AudioGeneratorOpus.h" 34 | #include "AudioGeneratorRTTTL.h" 35 | #include "AudioGeneratorTalkie.h" 36 | #include "AudioGeneratorWAV.h" 37 | 38 | // Render(output) sounds 39 | #include "AudioOutputBuffer.h" 40 | #include "AudioOutputFilterDecimate.h" 41 | #include "AudioOutput.h" 42 | #include "AudioOutputI2S.h" 43 | #include "AudioOutputI2SNoDAC.h" 44 | #include "AudioOutputMixer.h" 45 | #include "AudioOutputNull.h" 46 | #include "AudioOutputSerialWAV.h" 47 | #include "AudioOutputSPDIF.h" 48 | #include "AudioOutputSPIFFSWAV.h" 49 | #include "AudioOutputSTDIO.h" 50 | #include "AudioOutputULP.h" 51 | -------------------------------------------------------------------------------- /src/AudioOutputI2SNoDAC.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioOutputI2SNoDAC 3 | Audio player using SW delta-sigma to generate "analog" on I2S data 4 | 5 | Copyright (C) 2017 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "AudioOutputI2S.h" 24 | 25 | class AudioOutputI2SNoDAC : public AudioOutputI2S 26 | { 27 | public: 28 | AudioOutputI2SNoDAC(int port = 0); 29 | virtual ~AudioOutputI2SNoDAC() override; 30 | virtual bool begin() override { return AudioOutputI2S::begin(false); } 31 | virtual bool ConsumeSample(int16_t sample[2]) override; 32 | 33 | bool SetOversampling(int os); 34 | 35 | protected: 36 | virtual int AdjustI2SRate(int hz) override { return hz * oversample/32; } 37 | uint8_t oversample; 38 | void DeltaSigma(int16_t sample[2], uint32_t dsBuff[4]); 39 | typedef int32_t fixed24p8_t; 40 | enum {fixedPosValue=0x007fff00}; /* 24.8 of max-signed-int */ 41 | fixed24p8_t lastSamp; // Last sample value 42 | fixed24p8_t cumErr; // Running cumulative error since time began 43 | }; 44 | -------------------------------------------------------------------------------- /src/AudioFileSourceFS.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioFileSourceFS 3 | Input Arduion "file" to be used by AudioGenerator 4 | 5 | Copyright (C) 2017 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #ifndef _AUDIOFILESOURCEFS_H 22 | #define _AUDIOFILESOURCEFS_H 23 | 24 | #include 25 | #include 26 | 27 | #include "AudioFileSource.h" 28 | 29 | class AudioFileSourceFS : public AudioFileSource 30 | { 31 | public: 32 | AudioFileSourceFS(fs::FS &fs) { filesystem = &fs; } 33 | AudioFileSourceFS(fs::FS &fs, const char *filename); 34 | virtual ~AudioFileSourceFS() override; 35 | 36 | virtual bool open(const char *filename) override; 37 | virtual uint32_t read(void *data, uint32_t len) override; 38 | virtual bool seek(int32_t pos, int dir) override; 39 | virtual bool close() override; 40 | virtual bool isOpen() override; 41 | virtual uint32_t getSize() override; 42 | virtual uint32_t getPos() override { if (!f) return 0; else return f.position(); }; 43 | 44 | private: 45 | fs::FS *filesystem; 46 | fs::File f; 47 | }; 48 | 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /src/AudioFileSourcePROGMEM.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioFileSourcePROGMEM 3 | Store a "file" as a PROGMEM array and use it as audio source data 4 | 5 | Copyright (C) 2017 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #ifndef _AUDIOFILESOURCEPROGMEM_H 22 | #define _AUDIOFILESOURCEPROGMEM_H 23 | 24 | #include "AudioFileSource.h" 25 | 26 | class AudioFileSourcePROGMEM : public AudioFileSource 27 | { 28 | public: 29 | AudioFileSourcePROGMEM(); 30 | AudioFileSourcePROGMEM(const void *data, uint32_t len); 31 | virtual ~AudioFileSourcePROGMEM() override; 32 | virtual uint32_t read(void *data, uint32_t len) override; 33 | virtual bool seek(int32_t pos, int dir) override; 34 | virtual bool close() override; 35 | virtual bool isOpen() override; 36 | virtual uint32_t getSize() override; 37 | virtual uint32_t getPos() override { if (!opened) return 0; else return filePointer; }; 38 | 39 | bool open(const void *data, uint32_t len); 40 | 41 | private: 42 | bool opened; 43 | const void *progmemData; 44 | uint32_t progmemLen; 45 | uint32_t filePointer; 46 | }; 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /src/AudioFileSourceSTDIO.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioFileSourceSTDIO 3 | Input SPIFFS "file" to be used by AudioGenerator 4 | Only for host-based testing, not Arduino 5 | 6 | Copyright (C) 2017 Earle F. Philhower, III 7 | 8 | This program is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program. If not, see . 20 | */ 21 | 22 | #ifndef _AUDIOFILESOURCESTDIO_H 23 | #define _AUDIOFILESOURCESTDIO_H 24 | 25 | #include 26 | 27 | #ifndef ARDUINO 28 | 29 | #include "AudioFileSource.h" 30 | 31 | class AudioFileSourceSTDIO : public AudioFileSource 32 | { 33 | public: 34 | AudioFileSourceSTDIO(); 35 | AudioFileSourceSTDIO(const char *filename); 36 | virtual ~AudioFileSourceSTDIO() override; 37 | 38 | virtual bool open(const char *filename) override; 39 | virtual uint32_t read(void *data, uint32_t len) override; 40 | virtual bool seek(int32_t pos, int dir) override; 41 | virtual bool close() override; 42 | virtual bool isOpen() override; 43 | virtual uint32_t getSize() override; 44 | virtual uint32_t getPos() override { if (!f) return 0; else return (uint32_t)ftell(f); }; 45 | 46 | private: 47 | FILE *f; 48 | }; 49 | 50 | #endif // !ARDUINO 51 | 52 | #endif 53 | 54 | -------------------------------------------------------------------------------- /src/libmad/bit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: bit.h,v 1.12 2004/01/23 09:41:32 rob Exp $ 20 | */ 21 | 22 | # ifndef LIBMAD_BIT_H 23 | # define LIBMAD_BIT_H 24 | 25 | struct mad_bitptr { 26 | unsigned char const *byte; 27 | unsigned short cache; 28 | unsigned short left; 29 | }; 30 | 31 | void mad_bit_init(struct mad_bitptr *, unsigned char const *); 32 | 33 | # define mad_bit_finish(bitptr) /* nothing */ 34 | 35 | unsigned int mad_bit_length(struct mad_bitptr const *, 36 | struct mad_bitptr const *); 37 | 38 | # define mad_bit_bitsleft(bitptr) ((bitptr)->left) 39 | unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *); 40 | 41 | void mad_bit_skip(struct mad_bitptr *, unsigned int); 42 | unsigned long mad_bit_read(struct mad_bitptr *, unsigned int); 43 | void mad_bit_write(struct mad_bitptr *, unsigned int, unsigned long); 44 | 45 | unsigned short mad_bit_crc(struct mad_bitptr, unsigned int, unsigned short); 46 | 47 | # endif 48 | -------------------------------------------------------------------------------- /src/libmad/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: version.h,v 1.26 2004/01/23 09:41:33 rob Exp $ 20 | */ 21 | 22 | # ifndef LIBMAD_VERSION_H 23 | # define LIBMAD_VERSION_H 24 | 25 | # define MAD_VERSION_MAJOR 0 26 | # define MAD_VERSION_MINOR 15 27 | # define MAD_VERSION_PATCH 1 28 | # define MAD_VERSION_EXTRA " (beta)" 29 | 30 | # define MAD_VERSION_STRINGIZE(str) #str 31 | # define MAD_VERSION_STRING(num) MAD_VERSION_STRINGIZE(num) 32 | 33 | # define MAD_VERSION MAD_VERSION_STRING(MAD_VERSION_MAJOR) "." \ 34 | MAD_VERSION_STRING(MAD_VERSION_MINOR) "." \ 35 | MAD_VERSION_STRING(MAD_VERSION_PATCH) \ 36 | MAD_VERSION_EXTRA 37 | 38 | # define MAD_PUBLISHYEAR "2000-2004" 39 | # define MAD_AUTHOR "Underbit Technologies, Inc." 40 | # define MAD_EMAIL "info@underbit.com" 41 | 42 | extern char const mad_version[]; 43 | extern char const mad_copyright[]; 44 | extern char const mad_author[]; 45 | extern char const mad_build[]; 46 | 47 | # endif 48 | -------------------------------------------------------------------------------- /src/AudioOutputFilterDecimate.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioOutputFilterDecimate 3 | Implements a user-defined FIR on a passthrough w/rational decimation 4 | 5 | Copyright (C) 2017 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #ifndef _AUDIOOUTPUTFILTERDECIMATE_H 22 | #define _AUDIOOUTPUTFILTERDECIMATE_H 23 | 24 | #include "AudioOutput.h" 25 | 26 | class AudioOutputFilterDecimate : public AudioOutput 27 | { 28 | public: 29 | AudioOutputFilterDecimate(uint8_t taps, const int16_t *tap, int num, int den, AudioOutput *sink); 30 | virtual ~AudioOutputFilterDecimate() override; 31 | virtual bool SetRate(int hz) override; 32 | virtual bool SetBitsPerSample(int bits) override; 33 | virtual bool SetChannels(int chan) override; 34 | virtual bool SetGain(float f) override; 35 | virtual bool begin() override; 36 | virtual bool ConsumeSample(int16_t sample[2]) override; 37 | virtual bool stop() override; 38 | 39 | protected: 40 | AudioOutput *sink; 41 | uint8_t taps; 42 | int16_t *tap; 43 | int16_t *hist[2]; 44 | int idx; 45 | int num; 46 | int den; 47 | int err; 48 | }; 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /src/libflac/private/md5.h: -------------------------------------------------------------------------------- 1 | #ifndef FLAC__PRIVATE__MD5_H 2 | #define FLAC__PRIVATE__MD5_H 3 | 4 | /* 5 | * This is the header file for the MD5 message-digest algorithm. 6 | * The algorithm is due to Ron Rivest. This code was 7 | * written by Colin Plumb in 1993, no copyright is claimed. 8 | * This code is in the public domain; do with it what you wish. 9 | * 10 | * Equivalent code is available from RSA Data Security, Inc. 11 | * This code has been tested against that, and is equivalent, 12 | * except that you don't need to include two pages of legalese 13 | * with every copy. 14 | * 15 | * To compute the message digest of a chunk of bytes, declare an 16 | * MD5Context structure, pass it to MD5Init, call MD5Update as 17 | * needed on buffers full of bytes, and then call MD5Final, which 18 | * will fill a supplied 16-byte array with the digest. 19 | * 20 | * Changed so as no longer to depend on Colin Plumb's `usual.h' 21 | * header definitions; now uses stuff from dpkg's config.h 22 | * - Ian Jackson . 23 | * Still in the public domain. 24 | * 25 | * Josh Coalson: made some changes to integrate with libFLAC. 26 | * Still in the public domain, with no warranty. 27 | */ 28 | 29 | #include "../FLAC/ordinals.h" 30 | 31 | typedef union { 32 | FLAC__byte *p8; 33 | FLAC__int16 *p16; 34 | FLAC__int32 *p32; 35 | } FLAC__multibyte; 36 | 37 | typedef struct { 38 | FLAC__uint32 in[16]; 39 | FLAC__uint32 buf[4]; 40 | FLAC__uint32 bytes[2]; 41 | FLAC__multibyte internal_buf; 42 | size_t capacity; 43 | } FLAC__MD5Context; 44 | 45 | void FLAC__MD5Init(FLAC__MD5Context *context); 46 | void FLAC__MD5Final(FLAC__byte digest[16], FLAC__MD5Context *context); 47 | 48 | FLAC__bool FLAC__MD5Accumulate(FLAC__MD5Context *ctx, const FLAC__int32 * const signal[], uint32_t channels, uint32_t samples, uint32_t bytes_per_sample); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/libmad/global.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: global.h,v 1.11 2004/01/23 09:41:32 rob Exp $ 20 | */ 21 | 22 | # ifndef LIBMAD_GLOBAL_H 23 | # define LIBMAD_GLOBAL_H 24 | 25 | /* conditional debugging */ 26 | 27 | # if defined(DEBUG) && defined(NDEBUG) 28 | # error "cannot define both DEBUG and NDEBUG" 29 | # endif 30 | 31 | # if defined(DEBUG) 32 | # include 33 | # endif 34 | 35 | /* conditional features */ 36 | 37 | # if defined(OPT_SPEED) && defined(OPT_ACCURACY) 38 | # error "cannot optimize for both speed and accuracy" 39 | # endif 40 | 41 | # if defined(OPT_SPEED) && !defined(OPT_SSO) 42 | # define OPT_SSO 43 | # endif 44 | 45 | # if defined(HAVE_UNISTD_H) && defined(HAVE_WAITPID) && \ 46 | defined(HAVE_FCNTL) && defined(HAVE_PIPE) && defined(HAVE_FORK) 47 | # define USE_ASYNC 48 | # endif 49 | 50 | # if !defined(HAVE_ASSERT_H) 51 | # undef assert 52 | # if defined(NDEBUG) 53 | # define assert(x) /* nothing */ 54 | # else 55 | # define assert(x) do { if (!(x)) abort(); } while (0) 56 | # endif 57 | # endif 58 | 59 | # endif 60 | -------------------------------------------------------------------------------- /src/libflac/protected/all.h: -------------------------------------------------------------------------------- 1 | /* libFLAC - Free Lossless Audio Codec library 2 | * Copyright (C) 2001-2009 Josh Coalson 3 | * Copyright (C) 2011-2016 Xiph.Org Foundation 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * - Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * - Neither the name of the Xiph.org Foundation nor the names of its 17 | * contributors may be used to endorse or promote products derived from 18 | * this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef FLAC__PROTECTED__ALL_H 34 | #define FLAC__PROTECTED__ALL_H 35 | 36 | #include "stream_decoder.h" 37 | #include "stream_encoder.h" 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /examples/MixerSample/MixerSample.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #ifdef ESP32 3 | #include 4 | #else 5 | #include 6 | #endif 7 | 8 | #include "AudioFileSourcePROGMEM.h" 9 | #include "AudioGeneratorWAV.h" 10 | #include "AudioOutputI2S.h" 11 | #include "AudioOutputMixer.h" 12 | 13 | // VIOLA sample taken from https://ccrma.stanford.edu/~jos/pasp/Sound_Examples.html 14 | #include "viola.h" 15 | 16 | AudioGeneratorWAV *wav[2]; 17 | AudioFileSourcePROGMEM *file[2]; 18 | AudioOutputI2S *out; 19 | AudioOutputMixer *mixer; 20 | AudioOutputMixerStub *stub[2]; 21 | 22 | void setup() 23 | { 24 | WiFi.mode(WIFI_OFF); 25 | Serial.begin(115200); 26 | delay(1000); 27 | Serial.printf("WAV start\n"); 28 | 29 | audioLogger = &Serial; 30 | file[0] = new AudioFileSourcePROGMEM( viola, sizeof(viola) ); 31 | out = new AudioOutputI2S(); 32 | mixer = new AudioOutputMixer(32, out); 33 | stub[0] = mixer->NewInput(); 34 | stub[0]->SetGain(0.3); 35 | wav[0] = new AudioGeneratorWAV(); 36 | wav[0]->begin(file[0], stub[0]); 37 | // Begin wav[1] later in loop() 38 | Serial.printf("starting 1\n"); 39 | } 40 | 41 | void loop() 42 | { 43 | static uint32_t start = 0; 44 | static bool go = false; 45 | 46 | if (!start) start = millis(); 47 | 48 | if (wav[0]->isRunning()) { 49 | if (!wav[0]->loop()) { wav[0]->stop(); stub[0]->stop(); Serial.printf("stopping 1\n"); } 50 | } 51 | 52 | if (millis()-start > 3000) { 53 | if (!go) { 54 | Serial.printf("starting 2\n"); 55 | stub[1] = mixer->NewInput(); 56 | stub[1]->SetGain(0.4); 57 | wav[1] = new AudioGeneratorWAV(); 58 | file[1] = new AudioFileSourcePROGMEM( viola, sizeof(viola) ); 59 | wav[1]->begin(file[1], stub[1]); 60 | go = true; 61 | } 62 | if (wav[1]->isRunning()) { 63 | if (!wav[1]->loop()) { wav[1]->stop(); stub[1]->stop(); Serial.printf("stopping 2\n");} 64 | } 65 | } 66 | 67 | } 68 | 69 | -------------------------------------------------------------------------------- /src/AudioFileSourceFS.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | AudioFileSourceFS 3 | Input "file" to be used by AudioGenerator 4 | 5 | Copyright (C) 2017 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #include "AudioFileSourceFS.h" 22 | #ifdef ESP32 23 | #include "SPIFFS.h" 24 | #endif 25 | 26 | AudioFileSourceFS::AudioFileSourceFS(FS &fs, const char *filename) 27 | { 28 | filesystem = &fs; 29 | open(filename); 30 | } 31 | 32 | bool AudioFileSourceFS::open(const char *filename) 33 | { 34 | #ifndef ESP32 35 | filesystem->begin(); 36 | #endif 37 | f = filesystem->open(filename, "r"); 38 | return f; 39 | } 40 | 41 | AudioFileSourceFS::~AudioFileSourceFS() 42 | { 43 | if (f) f.close(); 44 | } 45 | 46 | uint32_t AudioFileSourceFS::read(void *data, uint32_t len) 47 | { 48 | return f.read(reinterpret_cast(data), len); 49 | } 50 | 51 | bool AudioFileSourceFS::seek(int32_t pos, int dir) 52 | { 53 | return f.seek(pos, (dir==SEEK_SET)?SeekSet:(dir==SEEK_CUR)?SeekCur:SeekEnd); 54 | } 55 | 56 | bool AudioFileSourceFS::close() 57 | { 58 | f.close(); 59 | return true; 60 | } 61 | 62 | bool AudioFileSourceFS::isOpen() 63 | { 64 | return f?true:false; 65 | } 66 | 67 | uint32_t AudioFileSourceFS::getSize() 68 | { 69 | if (!f) return 0; 70 | return f.size(); 71 | } 72 | 73 | 74 | -------------------------------------------------------------------------------- /src/AudioGenerator.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioGenerator 3 | Base class of an audio output generator 4 | 5 | Copyright (C) 2017 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #ifndef _AUDIOGENERATOR_H 22 | #define _AUDIOGENERATOR_H 23 | 24 | #include 25 | #include "AudioStatus.h" 26 | #include "AudioFileSource.h" 27 | #include "AudioOutput.h" 28 | 29 | class AudioGenerator 30 | { 31 | public: 32 | AudioGenerator() { lastSample[0] = 0; lastSample[1] = 0; }; 33 | virtual ~AudioGenerator() {}; 34 | virtual bool begin(AudioFileSource *source, AudioOutput *output) { (void)source; (void)output; return false; }; 35 | virtual bool loop() { return false; }; 36 | virtual bool stop() { return false; }; 37 | virtual bool isRunning() { return false;}; 38 | virtual void desync () { }; 39 | 40 | public: 41 | virtual bool RegisterMetadataCB(AudioStatus::metadataCBFn fn, void *data) { return cb.RegisterMetadataCB(fn, data); } 42 | virtual bool RegisterStatusCB(AudioStatus::statusCBFn fn, void *data) { return cb.RegisterStatusCB(fn, data); } 43 | 44 | protected: 45 | bool running; 46 | AudioFileSource *file; 47 | AudioOutput *output; 48 | int16_t lastSample[2]; 49 | 50 | protected: 51 | AudioStatus cb; 52 | }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/libmad/README.ESP8266: -------------------------------------------------------------------------------- 1 | This is the LIBMAD library, ported and optimized for the ESP8266 by 2 | Earle F. Philhower, III . The entire GIT 3 | history is preserved in GitHub at: 4 | https://github.com/earlephilhower/libmad-8266 5 | 6 | Unlike the "port" in NONOS-SDK from Espressif, this works in STEREO 7 | with an external I2S, or a full dynamic 32x oversampled mono using 8 | the AudioOutputI2SNoDAC which sounds poretty good @ 44.1KHz. 9 | 10 | The only functional changes made were in the synth section, where the 11 | amount of data synthesized in one pass was reduces from 1156 to 32 bytes 12 | and pre-scaled to minimize memory usage. Most other work involved 13 | shrinking the HEAP footprint by moving any constants to PROGMEM and 14 | adjusting the code to work. Often shorts could just be made to ints 15 | and then pointer/array access "just worked." In other cases accessor 16 | functions or macros were required to make the mad_fixed_t accesses 17 | use a 32-bit read before operating on a local register/RAM copy of 18 | a value. 19 | 20 | Massive stack variables were moved to the heap and dynamically 21 | allocated/deallocated on function entrance/exit. The xr[] array 22 | and the tmp[] array in layer3.c took around 8KB stack space, whereas 23 | the standard Arduino only has 4K total stack. That lead to some very 24 | interesting crashes, believe you me. 25 | 26 | Present memory needs to decode 128kb/sec MP3s are around 34KB heap 27 | and 1KB stack. Of this, about 24KB are required at all times once 28 | the MP3 object is instantiated, while the additional 10KB are for the 29 | stack-to-heap variables mentioned above. 30 | 31 | Any bugs in the port are most likely my fault, not Underbit's. I'd 32 | like to thank them for producing such a readable MP3 decoder and 33 | releasing it under the GPL. Their web page is: 34 | http://www.underbit.com/products/mad/ 35 | 36 | -Earle F. Philhower, III 37 | earlephilhower@yahoo.com 38 | -------------------------------------------------------------------------------- /examples/PlayMP3FromSPIFFS/PlayMP3FromSPIFFS.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #ifdef ESP32 3 | #include 4 | #include "SPIFFS.h" 5 | #else 6 | #include 7 | #endif 8 | #include "AudioFileSourceSPIFFS.h" 9 | #include "AudioFileSourceID3.h" 10 | #include "AudioGeneratorMP3.h" 11 | #include "AudioOutputI2SNoDAC.h" 12 | 13 | // To run, set your ESP8266 build to 160MHz, and include a SPIFFS of 512KB or greater. 14 | // Use the "Tools->ESP8266/ESP32 Sketch Data Upload" menu to write the MP3 to SPIFFS 15 | // Then upload the sketch normally. 16 | 17 | // pno_cs from https://ccrma.stanford.edu/~jos/pasp/Sound_Examples.html 18 | 19 | AudioGeneratorMP3 *mp3; 20 | AudioFileSourceSPIFFS *file; 21 | AudioOutputI2SNoDAC *out; 22 | AudioFileSourceID3 *id3; 23 | 24 | 25 | // Called when a metadata event occurs (i.e. an ID3 tag, an ICY block, etc. 26 | void MDCallback(void *cbData, const char *type, bool isUnicode, const char *string) 27 | { 28 | (void)cbData; 29 | Serial.printf("ID3 callback for: %s = '", type); 30 | 31 | if (isUnicode) { 32 | string += 2; 33 | } 34 | 35 | while (*string) { 36 | char a = *(string++); 37 | if (isUnicode) { 38 | string++; 39 | } 40 | Serial.printf("%c", a); 41 | } 42 | Serial.printf("'\n"); 43 | Serial.flush(); 44 | } 45 | 46 | 47 | void setup() 48 | { 49 | WiFi.mode(WIFI_OFF); 50 | Serial.begin(115200); 51 | delay(1000); 52 | SPIFFS.begin(); 53 | Serial.printf("Sample MP3 playback begins...\n"); 54 | 55 | audioLogger = &Serial; 56 | file = new AudioFileSourceSPIFFS("/pno-cs.mp3"); 57 | id3 = new AudioFileSourceID3(file); 58 | id3->RegisterMetadataCB(MDCallback, (void*)"ID3TAG"); 59 | out = new AudioOutputI2SNoDAC(); 60 | mp3 = new AudioGeneratorMP3(); 61 | mp3->begin(id3, out); 62 | } 63 | 64 | void loop() 65 | { 66 | if (mp3->isRunning()) { 67 | if (!mp3->loop()) mp3->stop(); 68 | } else { 69 | Serial.printf("MP3 done\n"); 70 | delay(1000); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /examples/StreamOnHost/onHost: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ino=${PWD##*/} 4 | 5 | if [ ! -d "${ESP8266ARDUINO}/tests/host" ]; then 6 | echo "\${ESP8266ARDUINO} should point to ESP8266 Arduino core directory" 7 | exit 1 8 | fi 9 | 10 | THISLIB=$(pwd)/../.. 11 | MAD=$(ls ${THISLIB}/src/libmad/*.c) 12 | PAGER=${PAGER:-less} 13 | 14 | cd ${ESP8266ARDUINO}/tests/host 15 | 16 | if [ "$1" = "clean" ]; then 17 | make clean 18 | cd ${THISLIB} 19 | rm -f src/*.o src/libmad/*.o 20 | exit 0 21 | elif [ "$1" = diff ]; then 22 | cd ${THISLIB}/examples 23 | diff -u StreamMP3FromHTTP/StreamMP3FromHTTP.ino ${ino}/${ino}.ino | ${PAGER} 24 | exit 0 25 | else 26 | echo "" 27 | echo "usage:" 28 | echo " $0" 29 | echo " $0 clean" 30 | echo " $0 diff" 31 | echo " AUDIO=a VALGRIND=v FORCE32=f $0" 32 | echo " a=1 play sound (use padsp, open /dev/dsp)" 33 | echo " v=1 run in native mode (FORCE32=0) with valgrind" 34 | echo " f=1 run in 32 bits mode (if gcc-multilib is installed)" 35 | echo "variable ESP8266ARDUINO must point to esp8266 Arduino core directory" 36 | echo "" 37 | [ "$1" = "-h" ] && exit 0 38 | sleep 1 39 | fi 40 | 41 | run="" 42 | 43 | [ -z "${FORCE32}" ] && FORCE32=0 44 | [ -z "${AUDIO}" ] && AUDIO=1 45 | 46 | if [ "${AUDIO}" = 1 ]; then 47 | run="${run} padsp" 48 | fi 49 | 50 | if [ "${VALGRIND}" = 1 ]; then 51 | FORCE32=0 52 | run="$run valgrind" 53 | fi 54 | 55 | touch ${THISLIB}/examples/${ino}/${ino}.ino # rebuild 56 | 57 | eval make FORCE32=${FORCE32} -j \ 58 | USERCSOURCES=\"${MAD}\" \ 59 | USERCXXSOURCES=\"${THISLIB}/src/AudioFileSourceBuffer.cpp ${THISLIB}/src/AudioLogger.cpp ${THISLIB}/src/AudioGeneratorMP3.cpp ${THISLIB}/src/AudioFileSourceICYStream.cpp ${THISLIB}/src/AudioFileSourceHTTPStream.cpp\" \ 60 | USERCFLAGS=\"-I${THISLIB}/src/ -DAUDIO=${AUDIO}\" \ 61 | ${THISLIB}/examples/${ino}/${ino} 62 | 63 | set -x 64 | 65 | $run ./bin/${ino}/${ino} "$@" 66 | stty sane 67 | -------------------------------------------------------------------------------- /examples/StreamOnHost/AudioOutputNullSlow.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioOutput 3 | Base class of an audio output player 4 | 5 | Copyright (C) 2017 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #ifndef _AUDIOOUTPUTNULLSLOW_H 22 | #define _AUDIOOUTPUTNULLSLOW_H 23 | 24 | #include "AudioOutput.h" 25 | 26 | class AudioOutputNullSlow : public AudioOutput 27 | { 28 | public: 29 | AudioOutputNullSlow() { }; 30 | ~AudioOutputNullSlow() {}; 31 | virtual bool begin() { samples = 0; startms = millis(); return true; } 32 | virtual bool ConsumeSample(int16_t sample[2]) { 33 | // return false (= output buffer full) 34 | // sometimes to let the main loop running 35 | constexpr int everylog2 = 10; 36 | if ((++samples & ((1< 0) { 38 | // simulate real time 39 | delay(1000/(hertz >> everylog2)); 40 | } 41 | return false; 42 | } 43 | return true; 44 | } 45 | virtual bool stop() { endms = millis(); return true; }; 46 | unsigned long GetMilliseconds() { return endms - startms; } 47 | int GetSamples() { return samples; } 48 | int GetFrequency() { return hertz; } 49 | 50 | protected: 51 | unsigned long startms; 52 | unsigned long endms; 53 | int samples; 54 | }; 55 | 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /src/AudioFileSource.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioFileSource 3 | Base class of an input "file" to be used by AudioGenerator 4 | 5 | Copyright (C) 2017 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #ifndef _AUDIOFILESOURCE_H 22 | #define _AUDIOFILESOURCE_H 23 | 24 | #include 25 | #include "AudioStatus.h" 26 | 27 | class AudioFileSource 28 | { 29 | public: 30 | AudioFileSource() {}; 31 | virtual ~AudioFileSource() {}; 32 | virtual bool open(const char *filename) { (void)filename; return false; }; 33 | virtual uint32_t read(void *data, uint32_t len) { (void)data; (void)len; return 0; }; 34 | virtual uint32_t readNonBlock(void *data, uint32_t len) { return read(data, len); }; 35 | virtual bool seek(int32_t pos, int dir) { (void)pos; (void)dir; return false; }; 36 | virtual bool close() { return false; }; 37 | virtual bool isOpen() { return false; }; 38 | virtual uint32_t getSize() { return 0; }; 39 | virtual uint32_t getPos() { return 0; }; 40 | virtual bool loop() { return true; }; 41 | 42 | public: 43 | virtual bool RegisterMetadataCB(AudioStatus::metadataCBFn fn, void *data) { return cb.RegisterMetadataCB(fn, data); } 44 | virtual bool RegisterStatusCB(AudioStatus::statusCBFn fn, void *data) { return cb.RegisterStatusCB(fn, data); } 45 | 46 | protected: 47 | AudioStatus cb; 48 | }; 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /src/AudioGeneratorMP3a.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioGeneratorMP3 3 | Audio output generator using the Helix MP3 decoder 4 | 5 | Copyright (C) 2017 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #ifndef _AUDIOGENERATORMP3A_H 22 | #define _AUDIOGENERATORMP3A_H 23 | 24 | #include "AudioGenerator.h" 25 | #include "libhelix-mp3/mp3dec.h" 26 | 27 | class AudioGeneratorMP3a : public AudioGenerator 28 | { 29 | public: 30 | AudioGeneratorMP3a(); 31 | virtual ~AudioGeneratorMP3a() override; 32 | virtual bool begin(AudioFileSource *source, AudioOutput *output) override; 33 | virtual bool loop() override; 34 | virtual bool stop() override; 35 | virtual bool isRunning() override; 36 | 37 | protected: 38 | // Helix MP3 decoder 39 | HMP3Decoder hMP3Decoder; 40 | 41 | // Input buffering 42 | uint8_t buff[1600]; // File buffer required to store at least a whole compressed frame 43 | int16_t buffValid; 44 | int16_t lastFrameEnd; 45 | bool FillBufferWithValidFrame(); // Read until we get a valid syncword and min(feof, 2048) butes in the buffer 46 | 47 | // Output buffering 48 | int16_t outSample[1152 * 2]; // Interleaved L/R 49 | int16_t validSamples; 50 | int16_t curSample; 51 | 52 | // Each frame may change this if they're very strange, I guess 53 | unsigned int lastRate; 54 | int lastChannels; 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/AudioFileSourceBuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioFileSourceBuffer 3 | Double-buffered input file using system RAM 4 | 5 | Copyright (C) 2017 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #ifndef _AUDIOFILESOURCEBUFFER_H 22 | #define _AUDIOFILESOURCEBUFFER_H 23 | 24 | #include "AudioFileSource.h" 25 | 26 | 27 | class AudioFileSourceBuffer : public AudioFileSource 28 | { 29 | public: 30 | AudioFileSourceBuffer(AudioFileSource *in, uint32_t bufferBytes); 31 | AudioFileSourceBuffer(AudioFileSource *in, void *buffer, uint32_t bufferBytes); // Pre-allocated buffer by app 32 | virtual ~AudioFileSourceBuffer() override; 33 | 34 | virtual uint32_t read(void *data, uint32_t len) override; 35 | virtual bool seek(int32_t pos, int dir) override; 36 | virtual bool close() override; 37 | virtual bool isOpen() override; 38 | virtual uint32_t getSize() override; 39 | virtual uint32_t getPos() override; 40 | virtual bool loop() override; 41 | 42 | virtual uint32_t getFillLevel(); 43 | 44 | enum { STATUS_FILLING=2, STATUS_UNDERFLOW }; 45 | 46 | private: 47 | virtual void fill(); 48 | 49 | private: 50 | AudioFileSource *src; 51 | uint32_t buffSize; 52 | uint8_t *buffer; 53 | bool deallocateBuffer; 54 | uint32_t writePtr; 55 | uint32_t readPtr; 56 | uint32_t length; 57 | bool filled; 58 | }; 59 | 60 | 61 | #endif 62 | 63 | -------------------------------------------------------------------------------- /src/libopus/celt/cwrs.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007-2008 CSIRO 2 | Copyright (c) 2007-2009 Xiph.Org Foundation 3 | Copyright (c) 2007-2009 Timothy B. Terriberry 4 | Written by Timothy B. Terriberry and Jean-Marc Valin */ 5 | /* 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | - Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | - Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 21 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 23 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef CWRS_H 31 | #define CWRS_H 32 | 33 | #include "arch.h" 34 | #include "stack_alloc.h" 35 | #include "entenc.h" 36 | #include "entdec.h" 37 | 38 | #ifdef CUSTOM_MODES 39 | int log2_frac(opus_uint32 val, int frac); 40 | #endif 41 | 42 | void get_required_bits(opus_int16 *bits, int N, int K, int frac); 43 | 44 | void encode_pulses(const int *_y, int N, int K, ec_enc *enc); 45 | 46 | opus_val32 decode_pulses(int *_y, int N, int K, ec_dec *dec); 47 | 48 | #endif /* CWRS_H */ 49 | -------------------------------------------------------------------------------- /src/libopus/COPYING: -------------------------------------------------------------------------------- 1 | Copyright 2001-2011 Xiph.Org, Skype Limited, Octasic, 2 | Jean-Marc Valin, Timothy B. Terriberry, 3 | CSIRO, Gregory Maxwell, Mark Borgerding, 4 | Erik de Castro Lopo 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | - Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | - Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | - Neither the name of Internet Society, IETF or IETF Trust, nor the 18 | names of specific contributors, may be used to endorse or promote 19 | products derived from this software without specific prior written 20 | permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 26 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | 34 | Opus is subject to the royalty-free patent licenses which are 35 | specified at: 36 | 37 | Xiph.Org Foundation: 38 | https://datatracker.ietf.org/ipr/1524/ 39 | 40 | Microsoft Corporation: 41 | https://datatracker.ietf.org/ipr/1914/ 42 | 43 | Broadcom Corporation: 44 | https://datatracker.ietf.org/ipr/1526/ 45 | -------------------------------------------------------------------------------- /src/libtinysoundfont/README.ESP8266: -------------------------------------------------------------------------------- 1 | This is a ported and significantly modified version of TinySoundFont by 2 | Bernhard Schelling. https://github.com/schellingb/TinySoundFont 3 | 4 | TinySoundFont lets you use a SoundFont2 library (sampled MIDI instruments) 5 | to play high quality music with a single #include. 6 | 7 | Porting and modifications done by Earle F. Philhower, III 8 | and released under the GPL v3 or later. 9 | 10 | The changes to allow it to work on the ESP8266 consisted mostly in making 11 | it significantly less memory intensive and speeding up the inner loops by 12 | using fixed point arithmetic instead of floating point. This change to 13 | fixed point lets us use simple integer math, which is massively faster than 14 | the software FP libraries on the ESP8266, but does come at the cost of a 15 | slightly increased noise floor. 16 | 17 | On the memory side, all data structures were converted into a "lazy" 18 | allocation which means that instead of loading the full contents of the 19 | header bits into RAM (which is often WAY more than the 40KB available on 20 | the EPS8266), only those bits needed are loaded, and only when they are 21 | needed. 22 | 23 | Also, instead of loading the entire sample array into memory (i.e. nearly 24 | 500MB for a good piano sample), only a very small portion is loaded into a 25 | LRU *cache* area. 26 | 27 | Even with the caching, it was found that SPIFFS, while having great 28 | functionality, was horrbly slow. So I wrote a new "faster" ROM filesystem 29 | called, surprisingly, FastROMFilesystem. 30 | https://github.com/earlephilhower/ESP8266FastROMFS 31 | If you are getting choppy playback, try this new filesytem or using a SD 32 | card (not tested by myself, but it'd be hard top be slower than SPIFFS). 33 | Simply going from SPIFFS to FastROMFilesystem took my testing of 34 | FURELISE.MID and 1MGM.SF2 from 0.5x realtime to 2.5x (i.e. from unusable 35 | stuttering to plenty of time to do other tings on the ESP8266) for the 36 | first 20 seconds or so tested. 37 | 38 | -Earle F. Philhower, III 39 | earlephilhower@yahoo.com 40 | 41 | -------------------------------------------------------------------------------- /src/AudioFileSourceSD.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | AudioFileSourceSPIFFS 3 | Input SD card "file" to be used by AudioGenerator 4 | 5 | Copyright (C) 2017 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #include "AudioFileSourceSD.h" 22 | 23 | AudioFileSourceSD::AudioFileSourceSD() 24 | { 25 | } 26 | 27 | AudioFileSourceSD::AudioFileSourceSD(const char *filename) 28 | { 29 | open(filename); 30 | } 31 | 32 | bool AudioFileSourceSD::open(const char *filename) 33 | { 34 | f = SD.open(filename, FILE_READ); 35 | return f; 36 | } 37 | 38 | AudioFileSourceSD::~AudioFileSourceSD() 39 | { 40 | if (f) f.close(); 41 | } 42 | 43 | uint32_t AudioFileSourceSD::read(void *data, uint32_t len) 44 | { 45 | return f.read(reinterpret_cast(data), len); 46 | } 47 | 48 | bool AudioFileSourceSD::seek(int32_t pos, int dir) 49 | { 50 | if (!f) return false; 51 | if (dir==SEEK_SET) return f.seek(pos); 52 | else if (dir==SEEK_CUR) return f.seek(f.position() + pos); 53 | else if (dir==SEEK_END) return f.seek(f.size() + pos); 54 | return false; 55 | } 56 | 57 | bool AudioFileSourceSD::close() 58 | { 59 | f.close(); 60 | return true; 61 | } 62 | 63 | bool AudioFileSourceSD::isOpen() 64 | { 65 | return f?true:false; 66 | } 67 | 68 | uint32_t AudioFileSourceSD::getSize() 69 | { 70 | if (!f) return 0; 71 | return f.size(); 72 | } 73 | 74 | uint32_t AudioFileSourceSD::getPos() 75 | { 76 | if (!f) return 0; 77 | return f.position(); 78 | } 79 | -------------------------------------------------------------------------------- /src/libmad/TODO: -------------------------------------------------------------------------------- 1 | 2 | libmad - MPEG audio decoder library 3 | Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | 5 | $Id: TODO,v 1.3 2004/02/05 09:02:39 rob Exp $ 6 | 7 | =============================================================================== 8 | 9 | libmad: 10 | - more API layers (buffering, PCM samples, dithering, etc.) 11 | - x86 performance optimization compiler flags 12 | - function documentation, general docs 13 | - finish async API 14 | - parse system streams? 15 | - MPEG-2 MC, AAC? 16 | - logarithmic multiplication? 17 | - multiple frame decoding for better locality of reference? 18 | - frame serial numbers, Layer III frame continuity checks 19 | 20 | fixed.h: 21 | - experiment with FPM_INTEL: 22 | 23 | # if 1 24 | # define mad_f_scale64(hi, lo) \ 25 | ({ mad_fixed_t __result; \ 26 | asm ("shrl %3,%1\n\t" \ 27 | "shll %4,%2\n\t" \ 28 | "orl %2,%1" \ 29 | : "=rm" (__result) \ 30 | : "0" (lo), "r" (hi), \ 31 | "I" (MAD_F_SCALEBITS), "I" (32 - MAD_F_SCALEBITS) \ 32 | : "cc"); \ 33 | __result; \ 34 | }) 35 | # else 36 | # define mad_f_scale64(hi, lo) \ 37 | ({ mad_fixed64hi_t __hi_; \ 38 | mad_fixed64lo_t __lo_; \ 39 | mad_fixed_t __result; \ 40 | asm ("sall %2,%1" \ 41 | : "=r" (__hi_) \ 42 | : "0" (hi), "I" (32 - MAD_F_SCALEBITS) \ 43 | : "cc"); \ 44 | asm ("shrl %2,%1" \ 45 | : "=r" (__lo_) \ 46 | : "0" (lo), "I" (MAD_F_SCALEBITS) \ 47 | : "cc"); \ 48 | asm ("orl %1,%2" \ 49 | : "=rm" (__result) \ 50 | : "r" (__hi_), "0" (__lo_) \ 51 | : "cc"); \ 52 | __result; \ 53 | }) 54 | # endif 55 | 56 | libmad Layer I: 57 | - check frame length sanity 58 | 59 | libmad Layer II: 60 | - check frame length sanity 61 | 62 | libmad Layer III: 63 | - circular buffer 64 | - optimize zero_part from Huffman decoding throughout 65 | - MPEG 2.5 8000 Hz sf bands? mixed blocks? 66 | - stereo->mono conversion optimization? 67 | - enable frame-at-a-time decoding 68 | - improve portability of huffman.c 69 | 70 | -------------------------------------------------------------------------------- /src/AudioFileSourceFATFS.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioFileSourceFS 3 | Input Arduion "file" to be used by AudioGenerator 4 | 5 | Copyright (C) 2017 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #ifndef _AUDIOFILESOURCEFATFS_H 22 | #define _AUDIOFILESOURCEFATFS_H 23 | 24 | #ifdef ESP32 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include "AudioFileSource.h" 31 | #include "AudioFileSourceFS.h" 32 | 33 | /* 34 | AudioFileSource for FAT filesystem. 35 | */ 36 | class AudioFileSourceFATFS : public AudioFileSourceFS 37 | { 38 | public: 39 | AudioFileSourceFATFS() : AudioFileSourceFS(FFat) {}; 40 | AudioFileSourceFATFS(const char *filename) : AudioFileSourceFS(FFat) { 41 | // We call open() ourselves because calling AudioFileSourceFS(FFat, filename) 42 | // would call the parent open() and we do not want that 43 | open(filename); 44 | }; 45 | 46 | virtual bool open(const char *filename) override { 47 | // make sure that the FATFS filesystem has been mounted 48 | if (!FFat.begin()) { 49 | audioLogger->printf_P(PSTR("Unable to initialize FATFS filesystem\n")); 50 | return false; 51 | } else { 52 | // now that the fielsystem has been mounted, we can call the regular parent open() function 53 | return AudioFileSourceFS::open(filename); 54 | } 55 | }; 56 | 57 | // Others are inherited from base 58 | }; 59 | 60 | #endif 61 | 62 | 63 | #endif 64 | 65 | -------------------------------------------------------------------------------- /src/AudioStatus.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioStatus 3 | Base class for Audio* status/metadata reporting 4 | 5 | Copyright (C) 2017 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #ifndef _AUDIOSTATUS_H 22 | #define _AUDIOSTATUS_H 23 | 24 | #include 25 | 26 | #include "AudioLogger.h" 27 | 28 | class AudioStatus 29 | { 30 | public: 31 | AudioStatus() { ClearCBs(); }; 32 | virtual ~AudioStatus() {}; 33 | 34 | void ClearCBs() { mdFn = NULL; stFn = NULL; }; 35 | 36 | typedef void (*metadataCBFn)(void *cbData, const char *type, bool isUnicode, const char *str); 37 | bool RegisterMetadataCB(metadataCBFn f, void *cbData) { mdFn = f; mdData = cbData; return true; } 38 | 39 | // Returns a unique warning/error code, varying by the object. The string may be a PSTR, use _P functions! 40 | typedef void (*statusCBFn)(void *cbData, int code, const char *string); 41 | bool RegisterStatusCB(statusCBFn f, void *cbData) { stFn = f; stData = cbData; return true; } 42 | 43 | // Safely call the md function, if defined 44 | inline void md(const char *type, bool isUnicode, const char *string) { if (mdFn) mdFn(mdData, type, isUnicode, string); } 45 | 46 | // Safely call the st function, if defined 47 | inline void st(int code, const char *string) { if (stFn) stFn(stData, code, string); } 48 | 49 | private: 50 | metadataCBFn mdFn; 51 | void *mdData; 52 | statusCBFn stFn; 53 | void *stData; 54 | }; 55 | 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /src/libmad/huffman.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: huffman.h,v 1.11 2004/01/23 09:41:32 rob Exp $ 20 | */ 21 | 22 | # ifndef LIBMAD_HUFFMAN_H 23 | # define LIBMAD_HUFFMAN_H 24 | 25 | // Use ints instead of bitfields. This'll make the structure way larger, but allow 26 | // for easy direct access w/o any helper functions when placed in PROGMEM 27 | 28 | union huffquad { 29 | struct { 30 | unsigned int final; 31 | unsigned int bits; 32 | unsigned int offset; 33 | } ptr; 34 | struct { 35 | unsigned int final; 36 | unsigned int hlen; 37 | unsigned int v; 38 | unsigned int w; 39 | unsigned int x; 40 | unsigned int y; 41 | } value; 42 | unsigned int final ; 43 | }; 44 | 45 | union huffpair { 46 | struct { 47 | unsigned int final; 48 | unsigned int bits; 49 | unsigned int offset; 50 | } ptr; 51 | struct { 52 | unsigned int final; 53 | unsigned int hlen; 54 | unsigned int x; 55 | unsigned int y; 56 | } value; 57 | unsigned int final; 58 | }; 59 | 60 | struct hufftable { 61 | union huffpair const *table; 62 | unsigned int linbits; 63 | unsigned int startbits; 64 | }; 65 | 66 | extern union huffquad const *const mad_huff_quad_table[2]; 67 | extern struct hufftable const mad_huff_pair_table[32]; 68 | 69 | # endif 70 | -------------------------------------------------------------------------------- /src/libmad/fixed.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: fixed.c,v 1.13 2004/01/23 09:41:32 rob Exp $ 20 | */ 21 | 22 | #pragma GCC optimize ("O3") 23 | 24 | # include "config.h" 25 | 26 | # include "global.h" 27 | 28 | # include "fixed.h" 29 | 30 | /* 31 | * NAME: fixed->abs() 32 | * DESCRIPTION: return absolute value of a fixed-point number 33 | */ 34 | mad_fixed_t mad_f_abs(mad_fixed_t x) 35 | { 36 | return x < 0 ? -x : x; 37 | } 38 | 39 | /* 40 | * NAME: fixed->div() 41 | * DESCRIPTION: perform division using fixed-point math 42 | */ 43 | mad_fixed_t mad_f_div(mad_fixed_t x, mad_fixed_t y) 44 | { 45 | mad_fixed_t q, r; 46 | unsigned int bits; 47 | 48 | q = mad_f_abs(x / y); 49 | 50 | if (x < 0) { 51 | x = -x; 52 | y = -y; 53 | } 54 | 55 | r = x % y; 56 | 57 | if (y < 0) { 58 | x = -x; 59 | y = -y; 60 | } 61 | 62 | if (q > mad_f_intpart(MAD_F_MAX) && 63 | !(q == -mad_f_intpart(MAD_F_MIN) && r == 0 && (x < 0) != (y < 0))) 64 | return 0; 65 | 66 | for (bits = MAD_F_FRACBITS; bits && r; --bits) { 67 | q <<= 1, r <<= 1; 68 | if (r >= y) 69 | r -= y, ++q; 70 | } 71 | 72 | /* round */ 73 | if (2 * r >= y) 74 | ++q; 75 | 76 | /* fix sign */ 77 | if ((x < 0) != (y < 0)) 78 | q = -q; 79 | 80 | return q << bits; 81 | } 82 | -------------------------------------------------------------------------------- /src/AudioGeneratorWAV.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioGeneratorWAV 3 | Audio output generator that reads 8 and 16-bit WAV files 4 | 5 | Copyright (C) 2017 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #ifndef _AUDIOGENERATORWAV_H 22 | #define _AUDIOGENERATORWAV_H 23 | 24 | #include "AudioGenerator.h" 25 | 26 | class AudioGeneratorWAV : public AudioGenerator 27 | { 28 | public: 29 | AudioGeneratorWAV(); 30 | virtual ~AudioGeneratorWAV() override; 31 | virtual bool begin(AudioFileSource *source, AudioOutput *output) override; 32 | virtual bool loop() override; 33 | virtual bool stop() override; 34 | virtual bool isRunning() override; 35 | void SetBufferSize(int sz) { buffSize = sz; } 36 | 37 | private: 38 | bool ReadU32(uint32_t *dest) { return file->read(reinterpret_cast(dest), 4); } 39 | bool ReadU16(uint16_t *dest) { return file->read(reinterpret_cast(dest), 2); } 40 | bool ReadU8(uint8_t *dest) { return file->read(reinterpret_cast(dest), 1); } 41 | bool GetBufferedData(int bytes, void *dest); 42 | bool ReadWAVInfo(); 43 | 44 | 45 | protected: 46 | // WAV info 47 | uint16_t channels; 48 | uint32_t sampleRate; 49 | uint16_t bitsPerSample; 50 | 51 | uint32_t availBytes; 52 | 53 | // We need to buffer some data in-RAM to avoid doing 1000s of small reads 54 | uint32_t buffSize; 55 | uint8_t *buff; 56 | uint16_t buffPtr; 57 | uint16_t buffLen; 58 | }; 59 | 60 | #endif 61 | 62 | -------------------------------------------------------------------------------- /src/AudioGeneratorRTTTL.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioGeneratorRTTTL 3 | Audio output generator that plays RTTTL (Nokia ringtones) 4 | 5 | Based on the Rtttl Arduino library by James BM, https://github.com/spicajames/Rtttl 6 | Based on the gist from Daniel Hall https://gist.github.com/smarthall/1618800 7 | 8 | Copyright (C) 2018 Earle F. Philhower, III 9 | 10 | This program is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with this program. If not, see . 22 | */ 23 | 24 | #ifndef _AUDIOGENERATORRTTTL_H 25 | #define _AUDIOGENERATORRTTTL_H 26 | 27 | #include "AudioGenerator.h" 28 | 29 | class AudioGeneratorRTTTL : public AudioGenerator 30 | { 31 | public: 32 | AudioGeneratorRTTTL(); 33 | virtual ~AudioGeneratorRTTTL() override; 34 | virtual bool begin(AudioFileSource *source, AudioOutput *output) override; 35 | virtual bool loop() override; 36 | virtual bool stop() override; 37 | virtual bool isRunning() override; 38 | void SetRate(uint16_t hz) { rate = hz; } 39 | 40 | private: 41 | bool SkipWhitespace(); 42 | bool ReadInt(int *dest); 43 | bool ParseHeader(); 44 | bool GetNextNote(); 45 | 46 | protected: 47 | uint16_t rate; 48 | 49 | // We copy the entire tiny song to a buffer for easier access 50 | char *buff; 51 | int len; 52 | int ptr; 53 | 54 | // Song-global settings 55 | int defaultDuration; 56 | int defaultOctave; 57 | int wholeNoteMS; 58 | 59 | // The note we're currently playing 60 | int ttlSamplesPerWaveFP10; 61 | int ttlSamples; 62 | int samplesSent; 63 | }; 64 | 65 | #endif 66 | 67 | -------------------------------------------------------------------------------- /src/AudioFileSourceSPIRAMBuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioFileSourceSPIRAMBuffer 3 | Buffered file source in external SPI RAM 4 | 5 | Copyright (C) 2017 Sebastien Decourriere 6 | Based on AudioFileSourceBuffer class from Earle F. Philhower, III 7 | 8 | This program is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program. If not, see . 20 | */ 21 | 22 | #if defined(ESP32) || defined(ESP8266) 23 | #pragma once 24 | 25 | #include "AudioFileSource.h" 26 | #include 27 | #include "spiram-fast.h" 28 | //#define FAKERAM 29 | // #define SPIBUF_DEBUG 30 | 31 | class AudioFileSourceSPIRAMBuffer : public AudioFileSource 32 | { 33 | public: 34 | #ifdef FAKERAM 35 | AudioFileSourceSPIRAMBuffer(AudioFileSource *in, uint8_t csPin = 15, uint32_t bufferBytes = 2048); 36 | #else 37 | AudioFileSourceSPIRAMBuffer(AudioFileSource *in, uint8_t csPin = 15, uint32_t bufferBytes = 128*1024); 38 | #endif 39 | virtual ~AudioFileSourceSPIRAMBuffer() override; 40 | 41 | virtual uint32_t read(void *data, uint32_t len) override; 42 | virtual bool seek(int32_t pos, int dir) override; 43 | virtual bool close() override; 44 | virtual bool isOpen() override; 45 | virtual uint32_t getSize() override; 46 | virtual uint32_t getPos() override; 47 | virtual bool loop() override; 48 | 49 | private: 50 | virtual void fill(); 51 | 52 | private: 53 | AudioFileSource *src; 54 | ESP8266SPIRAM ram; 55 | size_t ramSize; 56 | size_t writePtr; 57 | size_t readPtr; 58 | bool filled; 59 | 60 | #ifdef FAKERAM 61 | char fakeRAM[2048]; 62 | #endif 63 | }; 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /src/libflac/FLAC/assert.h: -------------------------------------------------------------------------------- 1 | /* libFLAC - Free Lossless Audio Codec library 2 | * Copyright (C) 2001-2009 Josh Coalson 3 | * Copyright (C) 2011-2016 Xiph.Org Foundation 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * - Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * - Neither the name of the Xiph.org Foundation nor the names of its 17 | * contributors may be used to endorse or promote products derived from 18 | * this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef FLAC__ASSERT_H 34 | #define FLAC__ASSERT_H 35 | 36 | /* we need this since some compilers (like MSVC) leave assert()s on release code (and we don't want to use their ASSERT) */ 37 | #ifndef NDEBUG 38 | #include 39 | #define FLAC__ASSERT(x) assert(x) 40 | #define FLAC__ASSERT_DECLARATION(x) x 41 | #else 42 | #define FLAC__ASSERT(x) 43 | #define FLAC__ASSERT_DECLARATION(x) 44 | #endif 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/AudioGeneratorAAC.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioGeneratorAAC 3 | Audio output generator using the Helix AAC decoder 4 | 5 | Copyright (C) 2017 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #ifndef _AUDIOGENERATORAAC_H 22 | #define _AUDIOGENERATORAAC_H 23 | 24 | #include "AudioGenerator.h" 25 | #include "libhelix-aac/aacdec.h" 26 | 27 | class AudioGeneratorAAC : public AudioGenerator 28 | { 29 | public: 30 | AudioGeneratorAAC(); 31 | AudioGeneratorAAC(void *preallocateData, int preallocateSize); 32 | virtual ~AudioGeneratorAAC() override; 33 | virtual bool begin(AudioFileSource *source, AudioOutput *output) override; 34 | virtual bool loop() override; 35 | virtual bool stop() override; 36 | virtual bool isRunning() override; 37 | 38 | protected: 39 | void *preallocateSpace; 40 | int preallocateSize; 41 | 42 | // Helix AAC decoder 43 | HAACDecoder hAACDecoder; 44 | 45 | // Input buffering 46 | const int buffLen = 1600; 47 | uint8_t *buff; //[1600]; // File buffer required to store at least a whole compressed frame 48 | int16_t buffValid; 49 | int16_t lastFrameEnd; 50 | bool FillBufferWithValidFrame(); // Read until we get a valid syncword and min(feof, 2048) butes in the buffer 51 | 52 | // Output buffering 53 | int16_t *outSample; //[1024 * 2]; // Interleaved L/R 54 | int16_t validSamples; 55 | int16_t curSample; 56 | 57 | // Each frame may change this if they're very strange, I guess 58 | unsigned int lastRate; 59 | int lastChannels; 60 | 61 | }; 62 | 63 | #endif 64 | 65 | -------------------------------------------------------------------------------- /src/libflac/share/macros.h: -------------------------------------------------------------------------------- 1 | /* libFLAC - Free Lossless Audio Codec library 2 | * Copyright (C) 2013-2016 Xiph.org Foundation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * - Neither the name of the Xiph.org Foundation nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | 34 | /* FLAC_CHECK_RETURN : Check the return value of the provided function and 35 | * print an error message if it fails (ie returns a value < 0). 36 | * 37 | * Ideally, a library should not print anything, but this macro is only used 38 | * for things that extremely unlikely to fail, like `chown` to a previoulsy 39 | * saved `uid`. 40 | */ 41 | 42 | #define FLAC_CHECK_RETURN(x) \ 43 | { if ((x) < 0) \ 44 | fprintf (stderr, "%s : %s\n", #x, strerror (errno)) ; \ 45 | } 46 | -------------------------------------------------------------------------------- /src/libopus/mlp.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017 Jean-Marc Valin */ 2 | /* 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | are met: 6 | 7 | - Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | - Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 18 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 22 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 23 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef _MLP_H_ 28 | #define _MLP_H_ 29 | 30 | #include "opus_types.h" 31 | 32 | #define WEIGHTS_SCALE (1.f/128) 33 | 34 | #define MAX_NEURONS 32 35 | 36 | typedef struct { 37 | const opus_int8 *bias; 38 | const opus_int8 *input_weights; 39 | int nb_inputs; 40 | int nb_neurons; 41 | int sigmoid; 42 | } DenseLayer; 43 | 44 | typedef struct { 45 | const opus_int8 *bias; 46 | const opus_int8 *input_weights; 47 | const opus_int8 *recurrent_weights; 48 | int nb_inputs; 49 | int nb_neurons; 50 | } GRULayer; 51 | 52 | extern const DenseLayer layer0; 53 | extern const GRULayer layer1; 54 | extern const DenseLayer layer2; 55 | 56 | void compute_dense(const DenseLayer *layer, float *output, const float *input); 57 | 58 | void compute_gru(const GRULayer *gru, float *state, const float *input); 59 | 60 | #endif /* _MLP_H_ */ 61 | -------------------------------------------------------------------------------- /src/libflac/private/metadata.h: -------------------------------------------------------------------------------- 1 | /* libFLAC - Free Lossless Audio Codec library 2 | * Copyright (C) 2002-2009 Josh Coalson 3 | * Copyright (C) 2011-2016 Xiph.Org Foundation 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * - Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * - Neither the name of the Xiph.org Foundation nor the names of its 17 | * contributors may be used to endorse or promote products derived from 18 | * this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef FLAC__PRIVATE__METADATA_H 34 | #define FLAC__PRIVATE__METADATA_H 35 | 36 | #include "../FLAC/metadata.h" 37 | 38 | /* WATCHOUT: all malloc()ed data in the block is free()ed; this may not 39 | * be a consistent state (e.g. PICTURE) or equivalent to the initial 40 | * state after FLAC__metadata_object_new() 41 | */ 42 | void FLAC__metadata_object_delete_data(FLAC__StreamMetadata *object); 43 | 44 | void FLAC__metadata_object_cuesheet_track_delete_data(FLAC__StreamMetadata_CueSheet_Track *object); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/libopus/celt/laplace.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007 CSIRO 2 | Copyright (c) 2007-2009 Xiph.Org Foundation 3 | Written by Jean-Marc Valin */ 4 | /* 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | - Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | - Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 20 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #include "entenc.h" 30 | #include "entdec.h" 31 | 32 | /** Encode a value that is assumed to be the realisation of a 33 | Laplace-distributed random process 34 | @param enc Entropy encoder state 35 | @param value Value to encode 36 | @param fs Probability of 0, multiplied by 32768 37 | @param decay Probability of the value +/- 1, multiplied by 16384 38 | */ 39 | void ec_laplace_encode(ec_enc *enc, int *value, unsigned fs, int decay); 40 | 41 | /** Decode a value that is assumed to be the realisation of a 42 | Laplace-distributed random process 43 | @param dec Entropy decoder state 44 | @param fs Probability of 0, multiplied by 32768 45 | @param decay Probability of the value +/- 1, multiplied by 16384 46 | @return Value decoded 47 | */ 48 | int ec_laplace_decode(ec_dec *dec, unsigned fs, int decay); 49 | -------------------------------------------------------------------------------- /tests/host/mp3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "AudioFileSourceSTDIO.h" 3 | #include "AudioOutputSTDIO.h" 4 | #include "AudioGeneratorMP3.h" 5 | #include "AudioFileSourceID3.h" 6 | #include "AudioFileSourceBuffer.h" 7 | #include "AudioOutputMixer.h" 8 | 9 | #define MP3 "../../examples/PlayMP3FromSPIFFS/data/pno-cs.mp3" 10 | 11 | // Called when a metadata event occurs (i.e. an ID3 tag, an ICY block, etc. 12 | void MDCallback(void *cbData, const char *type, bool isUnicode, const char *string) 13 | { 14 | (void)cbData; 15 | Serial.printf("ID3 callback for: %s = '", type); 16 | 17 | if (isUnicode) { 18 | string += 2; 19 | } 20 | 21 | while (*string) { 22 | char a = *(string++); 23 | if (isUnicode) { 24 | string++; 25 | } 26 | Serial.printf("%c", a); 27 | } 28 | Serial.printf("'\n"); 29 | Serial.flush(); 30 | } 31 | 32 | 33 | // Called when there's a warning or error (like a buffer underflow or decode hiccup) 34 | void StatusCallback(void *cbData, int code, const char *string) 35 | { 36 | const char *ptr = reinterpret_cast(cbData); 37 | // Note that the string may be in PROGMEM, so copy it to RAM for printf 38 | char s1[64]; 39 | strncpy_P(s1, string, sizeof(s1)); 40 | s1[sizeof(s1)-1]=0; 41 | Serial.printf("STATUS(%s) '%d' = '%s'\n", ptr, code, s1); 42 | Serial.flush(); 43 | } 44 | 45 | 46 | int main(int argc, char **argv) 47 | { 48 | (void) argc; 49 | (void) argv; 50 | AudioFileSourceSTDIO *in = new AudioFileSourceSTDIO(MP3); 51 | AudioFileSourceBuffer *buff = new AudioFileSourceBuffer(in, 2048); 52 | buff->RegisterStatusCB(StatusCallback, (void*)"buffer"); 53 | AudioFileSourceID3 *id3 = new AudioFileSourceID3(buff); 54 | id3->RegisterMetadataCB(MDCallback, (void*)"ID3TAG"); 55 | AudioOutputSTDIO *out = new AudioOutputSTDIO(); 56 | out->SetFilename("jamonit.wav"); 57 | AudioOutputMixer *mix = new AudioOutputMixer(17, out); 58 | AudioOutputMixerStub *stub = mix->NewInput(); 59 | void *space = malloc(29192); 60 | AudioGeneratorMP3 *mp3 = new AudioGeneratorMP3(space, 29192); 61 | 62 | mp3->begin(id3, stub); 63 | while (mp3->loop()) { /*noop*/ } 64 | mp3->stop(); 65 | out->stop(); 66 | 67 | free(space); 68 | delete stub; 69 | delete mix; 70 | delete mp3; 71 | delete out; 72 | delete id3; 73 | delete buff; 74 | delete in; 75 | } 76 | -------------------------------------------------------------------------------- /src/libflac/AUTHORS: -------------------------------------------------------------------------------- 1 | /* FLAC - Free Lossless Audio Codec 2 | * Copyright (C) 2001-2009 Josh Coalson 3 | * Copyright (C) 2011-2016 Xiph.Org Foundation 4 | * 5 | * This file is part the FLAC project. FLAC is comprised of several 6 | * components distributed under different licenses. The codec libraries 7 | * are distributed under Xiph.Org's BSD-like license (see the file 8 | * COPYING.Xiph in this distribution). All other programs, libraries, and 9 | * plugins are distributed under the GPL (see COPYING.GPL). The documentation 10 | * is distributed under the Gnu FDL (see COPYING.FDL). Each file in the 11 | * FLAC distribution contains at the top the terms under which it may be 12 | * distributed. 13 | * 14 | * Since this particular file is relevant to all components of FLAC, 15 | * it may be distributed under the Xiph.Org license, which is the least 16 | * restrictive of those mentioned above. See the file COPYING.Xiph in this 17 | * distribution. 18 | */ 19 | 20 | Current FLAC maintainer: Erik de Castro Lopo 21 | 22 | Original author: Josh Coalson 23 | 24 | Website : https://www.xiph.org/flac/ 25 | 26 | FLAC is an Open Source lossless audio codec originally developed by Josh Coalson 27 | between 2001 and 2009. From 2009 to 2012 FLAC was basically unmaintained. In 28 | 2012 the Erik de Castro Lopo became the chief maintainer as part of the 29 | Xiph.Org Foundation. 30 | 31 | Other major contributors and their contributions: 32 | 33 | "lvqcl" 34 | * Visual Studio build system. 35 | * Optimisations in the encoder and decoder. 36 | 37 | "Janne Hyvärinen" 38 | * Visual Studio build system. 39 | * Unicode handling on Windows. 40 | 41 | "Andrey Astafiev" 42 | * Russian translation of the HTML documentation 43 | 44 | "Miroslav Lichvar" 45 | * IA-32 assembly versions of several libFLAC routines 46 | 47 | "Brady Patterson" 48 | * AIFF file support, PPC assembly versions of libFLAC routines 49 | 50 | "Daisuke Shimamura" 51 | * i18n support in the XMMS plugin 52 | 53 | "X-Fixer" 54 | * Configuration system, tag editing, and file info in the Winamp2 plugin 55 | 56 | "Matt Zimmerman" 57 | * Libtool/autoconf/automake make system, flac man page 58 | 59 | -------------------------------------------------------------------------------- /src/AudioFileSourceHTTPStream.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioFileSourceHTTPStream 3 | Connect to a HTTP based streaming service 4 | 5 | Copyright (C) 2017 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #if defined(ESP32) || defined(ESP8266) 22 | #pragma once 23 | 24 | #include 25 | #ifdef ESP32 26 | #include 27 | #else 28 | #include 29 | #endif 30 | #include "AudioFileSource.h" 31 | 32 | class AudioFileSourceHTTPStream : public AudioFileSource 33 | { 34 | friend class AudioFileSourceICYStream; 35 | 36 | public: 37 | AudioFileSourceHTTPStream(); 38 | AudioFileSourceHTTPStream(const char *url); 39 | virtual ~AudioFileSourceHTTPStream() override; 40 | 41 | virtual bool open(const char *url) override; 42 | virtual uint32_t read(void *data, uint32_t len) override; 43 | virtual uint32_t readNonBlock(void *data, uint32_t len) override; 44 | virtual bool seek(int32_t pos, int dir) override; 45 | virtual bool close() override; 46 | virtual bool isOpen() override; 47 | virtual uint32_t getSize() override; 48 | virtual uint32_t getPos() override; 49 | bool SetReconnect(int tries, int delayms) { reconnectTries = tries; reconnectDelayMs = delayms; return true; } 50 | void useHTTP10 () { http.useHTTP10(true); } 51 | 52 | enum { STATUS_HTTPFAIL=2, STATUS_DISCONNECTED, STATUS_RECONNECTING, STATUS_RECONNECTED, STATUS_NODATA }; 53 | 54 | private: 55 | virtual uint32_t readInternal(void *data, uint32_t len, bool nonBlock); 56 | WiFiClient client; 57 | HTTPClient http; 58 | int pos; 59 | int size; 60 | int reconnectTries; 61 | int reconnectDelayMs; 62 | char saveURL[128]; 63 | }; 64 | 65 | 66 | #endif 67 | 68 | -------------------------------------------------------------------------------- /src/AudioGeneratorTalkie.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioGeneratorTalkie 3 | Audio output generator that speaks using the LPC code in old TI speech chips 4 | Output is locked at 8khz as that's that the hardcoded LPC coefficients are built around 5 | 6 | Based on the Talkie Arduino library by Peter Knight, https://github.com/going-digital/Talkie 7 | 8 | Copyright (C) 2020 Earle F. Philhower, III 9 | 10 | This program is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with this program. If not, see . 22 | */ 23 | 24 | #ifndef _AUDIOGENERATORTALKIE_H 25 | #define _AUDIOGENERATORTALKIE_H 26 | 27 | #include "AudioGenerator.h" 28 | 29 | class AudioGeneratorTalkie : public AudioGenerator 30 | { 31 | public: 32 | AudioGeneratorTalkie(); 33 | virtual ~AudioGeneratorTalkie() override; 34 | virtual bool begin(AudioFileSource *source, AudioOutput *output) override; 35 | virtual bool loop() override; 36 | virtual bool stop() override; 37 | virtual bool isRunning() override; 38 | bool say(const uint8_t *data, size_t len, bool async = false); 39 | 40 | protected: 41 | // The data stream we're playing 42 | uint8_t *buff; 43 | 44 | // Codeword stream handlers 45 | uint8_t *ptrAddr; 46 | uint8_t ptrBit; 47 | 48 | bool lastFrame; 49 | bool genOneFrame(); // Fill up one frame's worth of data, returns if this is the last frame 50 | int16_t genOneSample(); // Generate one sample of a frame 51 | 52 | // Utilities 53 | uint8_t rev(uint8_t a); 54 | uint8_t getBits(uint8_t bits); 55 | 56 | // Synthesizer state 57 | uint8_t synthPeriod; 58 | uint16_t synthEnergy; 59 | int16_t synthK1, synthK2; 60 | int8_t synthK3, synthK4, synthK5, synthK6, synthK7, synthK8, synthK9, synthK10; 61 | 62 | int frameLeft; 63 | }; 64 | 65 | #endif 66 | 67 | -------------------------------------------------------------------------------- /src/libopus/silk/lin2log.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | //#ifdef HAVE_CONFIG_H 29 | #include "../config.h" 30 | //#endif 31 | 32 | #include "SigProc_FIX.h" 33 | /* Approximation of 128 * log2() (very close inverse of silk_log2lin()) */ 34 | /* Convert input to a log scale */ 35 | opus_int32 silk_lin2log( 36 | const opus_int32 inLin /* I input in linear scale */ 37 | ) 38 | { 39 | opus_int32 lz, frac_Q7; 40 | 41 | silk_CLZ_FRAC( inLin, &lz, &frac_Q7 ); 42 | 43 | /* Piece-wise parabolic approximation */ 44 | return silk_ADD_LSHIFT32( silk_SMLAWB( frac_Q7, silk_MUL( frac_Q7, 128 - frac_Q7 ), 179 ), 31 - lz, 7 ); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /src/libopus/celt/mfrngcod.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001-2008 Timothy B. Terriberry 2 | Copyright (c) 2008-2009 Xiph.Org Foundation */ 3 | /* 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #if !defined(_mfrngcode_H) 29 | # define _mfrngcode_H (1) 30 | # include "entcode.h" 31 | 32 | /*Constants used by the entropy encoder/decoder.*/ 33 | 34 | /*The number of bits to output at a time.*/ 35 | # define EC_SYM_BITS (8) 36 | /*The total number of bits in each of the state registers.*/ 37 | # define EC_CODE_BITS (32) 38 | /*The maximum symbol value.*/ 39 | # define EC_SYM_MAX ((1U<>EC_SYM_BITS) 46 | /*The number of bits available for the last, partial symbol in the code field.*/ 47 | # define EC_CODE_EXTRA ((EC_CODE_BITS-2)%EC_SYM_BITS+1) 48 | #endif 49 | -------------------------------------------------------------------------------- /src/AudioOutputI2S.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioOutputI2S 3 | Base class for an I2S output port 4 | 5 | Copyright (C) 2017 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "AudioOutput.h" 24 | 25 | class AudioOutputI2S : public AudioOutput 26 | { 27 | public: 28 | #if defined(ESP32) || defined(ESP8266) 29 | AudioOutputI2S(int port=0, int output_mode=EXTERNAL_I2S, int dma_buf_count = 8, int use_apll=APLL_DISABLE); 30 | bool SetPinout(int bclkPin, int wclkPin, int doutPin); 31 | enum : int { APLL_AUTO = -1, APLL_ENABLE = 1, APLL_DISABLE = 0 }; 32 | enum : int { EXTERNAL_I2S = 0, INTERNAL_DAC = 1, INTERNAL_PDM = 2 }; 33 | #elif defined(ARDUINO_ARCH_RP2040) 34 | AudioOutputI2S(long sampleRate = 44100, pin_size_t sck = 26, pin_size_t data = 28); 35 | #endif 36 | virtual ~AudioOutputI2S() override; 37 | virtual bool SetRate(int hz) override; 38 | virtual bool SetBitsPerSample(int bits) override; 39 | virtual bool SetChannels(int channels) override; 40 | virtual bool begin() override { return begin(true); } 41 | virtual bool ConsumeSample(int16_t sample[2]) override; 42 | virtual void flush() override; 43 | virtual bool stop() override; 44 | 45 | bool begin(bool txDAC); 46 | bool SetOutputModeMono(bool mono); // Force mono output no matter the input 47 | 48 | protected: 49 | bool SetPinout(); 50 | virtual int AdjustI2SRate(int hz) { return hz; } 51 | uint8_t portNo; 52 | int output_mode; 53 | bool mono; 54 | bool i2sOn; 55 | int dma_buf_count; 56 | int use_apll; 57 | // We can restore the old values and free up these pins when in NoDAC mode 58 | uint32_t orig_bck; 59 | uint32_t orig_ws; 60 | 61 | uint8_t bclkPin; 62 | uint8_t wclkPin; 63 | uint8_t doutPin; 64 | }; 65 | -------------------------------------------------------------------------------- /src/libopus/tansig_table.h: -------------------------------------------------------------------------------- 1 | /* This file is auto-generated by gen_tables */ 2 | 3 | static const float tansig_table[201] = { 4 | 0.000000f, 0.039979f, 0.079830f, 0.119427f, 0.158649f, 5 | 0.197375f, 0.235496f, 0.272905f, 0.309507f, 0.345214f, 6 | 0.379949f, 0.413644f, 0.446244f, 0.477700f, 0.507977f, 7 | 0.537050f, 0.564900f, 0.591519f, 0.616909f, 0.641077f, 8 | 0.664037f, 0.685809f, 0.706419f, 0.725897f, 0.744277f, 9 | 0.761594f, 0.777888f, 0.793199f, 0.807569f, 0.821040f, 10 | 0.833655f, 0.845456f, 0.856485f, 0.866784f, 0.876393f, 11 | 0.885352f, 0.893698f, 0.901468f, 0.908698f, 0.915420f, 12 | 0.921669f, 0.927473f, 0.932862f, 0.937863f, 0.942503f, 13 | 0.946806f, 0.950795f, 0.954492f, 0.957917f, 0.961090f, 14 | 0.964028f, 0.966747f, 0.969265f, 0.971594f, 0.973749f, 15 | 0.975743f, 0.977587f, 0.979293f, 0.980869f, 0.982327f, 16 | 0.983675f, 0.984921f, 0.986072f, 0.987136f, 0.988119f, 17 | 0.989027f, 0.989867f, 0.990642f, 0.991359f, 0.992020f, 18 | 0.992631f, 0.993196f, 0.993718f, 0.994199f, 0.994644f, 19 | 0.995055f, 0.995434f, 0.995784f, 0.996108f, 0.996407f, 20 | 0.996682f, 0.996937f, 0.997172f, 0.997389f, 0.997590f, 21 | 0.997775f, 0.997946f, 0.998104f, 0.998249f, 0.998384f, 22 | 0.998508f, 0.998623f, 0.998728f, 0.998826f, 0.998916f, 23 | 0.999000f, 0.999076f, 0.999147f, 0.999213f, 0.999273f, 24 | 0.999329f, 0.999381f, 0.999428f, 0.999472f, 0.999513f, 25 | 0.999550f, 0.999585f, 0.999617f, 0.999646f, 0.999673f, 26 | 0.999699f, 0.999722f, 0.999743f, 0.999763f, 0.999781f, 27 | 0.999798f, 0.999813f, 0.999828f, 0.999841f, 0.999853f, 28 | 0.999865f, 0.999875f, 0.999885f, 0.999893f, 0.999902f, 29 | 0.999909f, 0.999916f, 0.999923f, 0.999929f, 0.999934f, 30 | 0.999939f, 0.999944f, 0.999948f, 0.999952f, 0.999956f, 31 | 0.999959f, 0.999962f, 0.999965f, 0.999968f, 0.999970f, 32 | 0.999973f, 0.999975f, 0.999977f, 0.999978f, 0.999980f, 33 | 0.999982f, 0.999983f, 0.999984f, 0.999986f, 0.999987f, 34 | 0.999988f, 0.999989f, 0.999990f, 0.999990f, 0.999991f, 35 | 0.999992f, 0.999992f, 0.999993f, 0.999994f, 0.999994f, 36 | 0.999994f, 0.999995f, 0.999995f, 0.999996f, 0.999996f, 37 | 0.999996f, 0.999997f, 0.999997f, 0.999997f, 0.999997f, 38 | 0.999997f, 0.999998f, 0.999998f, 0.999998f, 0.999998f, 39 | 0.999998f, 0.999998f, 0.999999f, 0.999999f, 0.999999f, 40 | 0.999999f, 0.999999f, 0.999999f, 0.999999f, 0.999999f, 41 | 0.999999f, 0.999999f, 0.999999f, 0.999999f, 0.999999f, 42 | 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 43 | 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 44 | 1.000000f, 45 | }; 46 | -------------------------------------------------------------------------------- /src/libmad/synth.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: synth.h,v 1.15 2004/01/23 09:41:33 rob Exp $ 20 | */ 21 | 22 | # ifndef LIBMAD_SYNTH_H 23 | # define LIBMAD_SYNTH_H 24 | 25 | # include "fixed.h" 26 | # include "frame.h" 27 | #include 28 | 29 | struct mad_pcm { 30 | unsigned int samplerate; /* sampling frequency (Hz) */ 31 | unsigned short channels; /* number of channels */ 32 | unsigned short length; /* number of samples per channel */ 33 | int16_t samples[2][32]; //1152]; /* PCM output samples [ch][sample] */ 34 | }; 35 | 36 | struct mad_synth { 37 | mad_fixed_t filter[2][2][2][16][8]; /* polyphase filterbank outputs */ 38 | /* [ch][eo][peo][s][v] */ 39 | 40 | unsigned int phase; /* current processing phase */ 41 | 42 | struct mad_pcm pcm; /* PCM output */ 43 | }; 44 | 45 | /* single channel PCM selector */ 46 | enum { 47 | MAD_PCM_CHANNEL_SINGLE = 0 48 | }; 49 | 50 | /* dual channel PCM selector */ 51 | enum { 52 | MAD_PCM_CHANNEL_DUAL_1 = 0, 53 | MAD_PCM_CHANNEL_DUAL_2 = 1 54 | }; 55 | 56 | /* stereo PCM selector */ 57 | enum { 58 | MAD_PCM_CHANNEL_STEREO_LEFT = 0, 59 | MAD_PCM_CHANNEL_STEREO_RIGHT = 1 60 | }; 61 | 62 | void mad_synth_init(struct mad_synth *); 63 | 64 | # define mad_synth_finish(synth) /* nothing */ 65 | 66 | void mad_synth_mute(struct mad_synth *); 67 | 68 | enum mad_flow mad_synth_frame(struct mad_synth *, struct mad_frame const *, enum mad_flow (*output_func)(void *s, struct mad_header const *, struct mad_pcm *), void *cbdata ); 69 | enum mad_flow mad_synth_frame_onens(struct mad_synth *synth, struct mad_frame const *frame, unsigned int ns); 70 | 71 | # endif 72 | -------------------------------------------------------------------------------- /src/libmad/version.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: version.c,v 1.15 2004/01/23 09:41:33 rob Exp $ 20 | */ 21 | 22 | #pragma GCC optimize ("O3") 23 | 24 | # include "config.h" 25 | 26 | # include "global.h" 27 | 28 | # include "version.h" 29 | 30 | char const mad_version[] = "MPEG Audio Decoder " MAD_VERSION; 31 | char const mad_copyright[] = "Copyright (C) " MAD_PUBLISHYEAR " " MAD_AUTHOR; 32 | char const mad_author[] = MAD_AUTHOR " <" MAD_EMAIL ">"; 33 | 34 | char const mad_build[] = "" 35 | # if defined(DEBUG) 36 | "DEBUG " 37 | # elif defined(NDEBUG) 38 | "NDEBUG " 39 | # endif 40 | 41 | # if defined(EXPERIMENTAL) 42 | "EXPERIMENTAL " 43 | # endif 44 | 45 | # if defined(FPM_64BIT) 46 | "FPM_64BIT " 47 | # elif defined(FPM_INTEL) 48 | "FPM_INTEL " 49 | # elif defined(FPM_ARM) 50 | "FPM_ARM " 51 | # elif defined(FPM_MIPS) 52 | "FPM_MIPS " 53 | # elif defined(FPM_SPARC) 54 | "FPM_SPARC " 55 | # elif defined(FPM_PPC) 56 | "FPM_PPC " 57 | # elif defined(FPM_DEFAULT) 58 | "FPM_DEFAULT " 59 | # endif 60 | 61 | # if defined(ASO_IMDCT) 62 | "ASO_IMDCT " 63 | # endif 64 | # if defined(ASO_INTERLEAVE1) 65 | "ASO_INTERLEAVE1 " 66 | # endif 67 | # if defined(ASO_INTERLEAVE2) 68 | "ASO_INTERLEAVE2 " 69 | # endif 70 | # if defined(ASO_ZEROCHECK) 71 | "ASO_ZEROCHECK " 72 | # endif 73 | 74 | # if defined(OPT_SPEED) 75 | "OPT_SPEED " 76 | # elif defined(OPT_ACCURACY) 77 | "OPT_ACCURACY " 78 | # endif 79 | 80 | # if defined(OPT_SSO) 81 | "OPT_SSO " 82 | # endif 83 | 84 | # if defined(OPT_DCTO) /* never defined here */ 85 | "OPT_DCTO " 86 | # endif 87 | 88 | # if defined(OPT_STRICT) 89 | "OPT_STRICT " 90 | # endif 91 | ; 92 | -------------------------------------------------------------------------------- /src/libopus/celt/celt_lpc.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009-2010 Xiph.Org Foundation 2 | Written by Jean-Marc Valin */ 3 | /* 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef PLC_H 29 | #define PLC_H 30 | 31 | #include "arch.h" 32 | #include "cpu_support.h" 33 | 34 | #if defined(OPUS_X86_MAY_HAVE_SSE4_1) 35 | #include "x86/celt_lpc_sse.h" 36 | #endif 37 | 38 | #define LPC_ORDER 24 39 | 40 | void _celt_lpc(opus_val16 *_lpc, const opus_val32 *ac, int p); 41 | 42 | void celt_fir_c( 43 | const opus_val16 *x, 44 | const opus_val16 *num, 45 | opus_val16 *y, 46 | int N, 47 | int ord, 48 | int arch); 49 | 50 | #if !defined(OVERRIDE_CELT_FIR) 51 | #define celt_fir(x, num, y, N, ord, arch) \ 52 | (celt_fir_c(x, num, y, N, ord, arch)) 53 | #endif 54 | 55 | void celt_iir(const opus_val32 *x, 56 | const opus_val16 *den, 57 | opus_val32 *y, 58 | int N, 59 | int ord, 60 | opus_val16 *mem, 61 | int arch); 62 | 63 | int _celt_autocorr(const opus_val16 *x, opus_val32 *ac, 64 | const opus_val16 *window, int overlap, int lag, int n, int arch); 65 | 66 | #endif /* PLC_H */ 67 | -------------------------------------------------------------------------------- /examples/PlayFLAC-SD-SPDIF/PlayFLAC-SD-SPDIF.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include "AudioFileSourceSD.h" 3 | #include "AudioOutputSPDIF.h" 4 | #include "AudioGeneratorFLAC.h" 5 | 6 | // For this sketch, you need connected SD card with '.flac' music files in the root 7 | // directory. Some samples with various sampling rates are available from i.e. 8 | // Espressif Audio Development Framework at: 9 | // https://docs.espressif.com/projects/esp-adf/en/latest/design-guide/audio-samples.html 10 | // 11 | // On ESP8266 you might need to reencode FLAC files with max '-2' compression level 12 | // (i.e. 1152 maximum block size) or you will run out of memory. FLAC files will be 13 | // slightly bigger but you don't loose audio quality with reencoding (lossles codec). 14 | 15 | // You may need a fast SD card. Set this as high as it will work (40MHz max). 16 | #define SPI_SPEED SD_SCK_MHZ(40) 17 | 18 | // On ESP32 you can adjust the SPDIF_OUT_PIN (GPIO number). 19 | // On ESP8266 it is fixed to GPIO3/RX0 and this setting has no effect 20 | #define SPDIF_OUT_PIN 27 21 | 22 | File dir; 23 | AudioFileSourceSD *source = NULL; 24 | AudioOutputSPDIF *output = NULL; 25 | AudioGeneratorFLAC *decoder = NULL; 26 | 27 | void setup() { 28 | Serial.begin(115200); 29 | Serial.println(); 30 | delay(1000); 31 | 32 | audioLogger = &Serial; 33 | source = new AudioFileSourceSD(); 34 | output = new AudioOutputSPDIF(SPDIF_OUT_PIN); 35 | decoder = new AudioGeneratorFLAC(); 36 | 37 | // NOTE: SD.begin(...) should be called AFTER AudioOutputSPDIF() 38 | // to takover the the SPI pins if they share some with I2S 39 | // (i.e. D8 on Wemos D1 mini is both I2S BCK and SPI SS) 40 | #if defined(ESP8266) 41 | SD.begin(SS, SPI_SPEED); 42 | #else 43 | SD.begin(); 44 | #endif 45 | dir = SD.open("/"); 46 | } 47 | 48 | void loop() { 49 | if ((decoder) && (decoder->isRunning())) { 50 | if (!decoder->loop()) decoder->stop(); 51 | } else { 52 | File file = dir.openNextFile(); 53 | if (file) { 54 | if (String(file.name()).endsWith(".flac")) { 55 | source->close(); 56 | if (source->open(file.name())) { 57 | Serial.printf_P(PSTR("Playing '%s' from SD card...\n"), file.name()); 58 | decoder->begin(source, output); 59 | } else { 60 | Serial.printf_P(PSTR("Error opening '%s'\n"), file.name()); 61 | } 62 | } 63 | } else { 64 | Serial.println(F("Playback form SD card done\n")); 65 | delay(1000); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/libflac/share/private.h: -------------------------------------------------------------------------------- 1 | /* libFLAC - Free Lossless Audio Codec library 2 | * Copyright (C) 2013-2016 Xiph.org Foundation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * - Neither the name of the Xiph.org Foundation nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef FLAC__SHARE__PRIVATE_H 33 | #define FLAC__SHARE__PRIVATE_H 34 | 35 | /* 36 | * Unpublished debug routines from libFLAC. This should not be used from any 37 | * client code other than code shipped with the FLAC sources. 38 | */ 39 | FLAC_API FLAC__bool FLAC__stream_encoder_disable_constant_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value); 40 | FLAC_API FLAC__bool FLAC__stream_encoder_disable_fixed_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value); 41 | FLAC_API FLAC__bool FLAC__stream_encoder_disable_verbatim_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value); 42 | FLAC_API FLAC__bool FLAC__stream_encoder_set_do_md5(FLAC__StreamEncoder *encoder, FLAC__bool value); 43 | FLAC_API FLAC__bool FLAC__stream_encoder_get_do_md5(const FLAC__StreamEncoder *encoder); 44 | 45 | #endif /* FLAC__SHARE__PRIVATE_H */ 46 | -------------------------------------------------------------------------------- /src/AudioGeneratorOpus.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioGeneratorOpus 3 | Audio output generator that plays Opus audio files 4 | 5 | Copyright (C) 2020 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #ifndef _AUDIOGENERATOROPUS_H 22 | #define _AUDIOGENERATOROPUS_H 23 | 24 | #include 25 | //#include "libopus/opus.h" 26 | #include "opusfile/opusfile.h" 27 | 28 | class AudioGeneratorOpus : public AudioGenerator 29 | { 30 | public: 31 | AudioGeneratorOpus(); 32 | virtual ~AudioGeneratorOpus() override; 33 | virtual bool begin(AudioFileSource *source, AudioOutput *output) override; 34 | virtual bool loop() override; 35 | virtual bool stop() override; 36 | virtual bool isRunning() override; 37 | 38 | protected: 39 | // Opus callbacks, need static functions to bounce into C++ from C 40 | static int OPUS_read(void *_stream, unsigned char *_ptr, int _nbytes) { 41 | return static_cast(_stream)->read_cb(_ptr, _nbytes); 42 | } 43 | static int OPUS_seek(void *_stream, opus_int64 _offset, int _whence) { 44 | return static_cast(_stream)->seek_cb(_offset, _whence); 45 | } 46 | static opus_int64 OPUS_tell(void *_stream) { 47 | return static_cast(_stream)->tell_cb(); 48 | } 49 | static int OPUS_close(void *_stream) { 50 | return static_cast(_stream)->close_cb(); 51 | } 52 | 53 | // Actual Opus callbacks 54 | int read_cb(unsigned char *_ptr, int _nbytes); 55 | int seek_cb(opus_int64 _offset, int _whence); 56 | opus_int64 tell_cb(); 57 | int close_cb(); 58 | 59 | private: 60 | OpusFileCallbacks cb = {OPUS_read, OPUS_seek, OPUS_tell, OPUS_close}; 61 | OggOpusFile *of; 62 | int prev_li; // To detect changes in streams 63 | 64 | int16_t *buff; 65 | uint32_t buffPtr; 66 | uint32_t buffLen; 67 | }; 68 | 69 | #endif 70 | 71 | -------------------------------------------------------------------------------- /src/AudioOutputFilterBiquad.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioOutputFilterBiquad 3 | Implements a Biquad filter 4 | 5 | Copyright (C) 2012 Nigel Redmon 6 | Copyright (C) 2021 William Bérubé 7 | 8 | This program is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program. If not, see . 20 | */ 21 | 22 | #ifndef _AudioOutputFilterBiquad_H 23 | #define _AudioOutputFilterBiquad_H 24 | 25 | #include "AudioOutput.h" 26 | 27 | #define BQ_SHIFT 16 28 | #define BQ_DECAL 65536 29 | 30 | enum { 31 | bq_type_lowpass = 0, 32 | bq_type_highpass, 33 | bq_type_bandpass, 34 | bq_type_notch, 35 | bq_type_peak, 36 | bq_type_lowshelf, 37 | bq_type_highshelf 38 | }; 39 | 40 | class AudioOutputFilterBiquad : public AudioOutput 41 | { 42 | public: 43 | AudioOutputFilterBiquad(AudioOutput *sink); 44 | AudioOutputFilterBiquad(int type, float Fc, float Q, float peakGain, AudioOutput *sink); 45 | virtual ~AudioOutputFilterBiquad() override; 46 | virtual bool SetRate(int hz) override; 47 | virtual bool SetBitsPerSample(int bits) override; 48 | virtual bool SetChannels(int chan) override; 49 | virtual bool SetGain(float f) override; 50 | virtual bool begin() override; 51 | virtual bool ConsumeSample(int16_t sample[2]) override; 52 | virtual bool stop() override; 53 | 54 | private: 55 | void SetType(int type); 56 | void SetFc(float Fc); 57 | void SetQ(float Q); 58 | void SetPeakGain(float peakGain); 59 | void SetBiquad(int type, float Fc, float Q, float peakGain); 60 | 61 | protected: 62 | AudioOutput *sink; 63 | int buffSize; 64 | int16_t *leftSample; 65 | int16_t *rightSample; 66 | int writePtr; 67 | int readPtr; 68 | bool filled; 69 | int type; 70 | void CalcBiquad(); 71 | int64_t i_a0, i_a1, i_a2, i_b1, i_b2; 72 | int64_t i_Fc, i_Q, i_peakGain; 73 | int64_t i_lz1, i_lz2, i_rz1, i_rz2; 74 | float a0, a1, a2, b1, b2; 75 | float Fc, Q, peakGain; 76 | float z1, z2; 77 | }; 78 | 79 | #endif 80 | 81 | -------------------------------------------------------------------------------- /src/AudioOutputBuffer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | AudioOutputBuffer 3 | Adds additional bufferspace to the output chain 4 | 5 | Copyright (C) 2017 Earle F. Philhower, III 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #include 22 | #include "AudioOutputBuffer.h" 23 | 24 | AudioOutputBuffer::AudioOutputBuffer(int buffSizeSamples, AudioOutput *dest) 25 | { 26 | buffSize = buffSizeSamples; 27 | leftSample = (int16_t*)malloc(sizeof(int16_t) * buffSize); 28 | rightSample = (int16_t*)malloc(sizeof(int16_t) * buffSize); 29 | writePtr = 0; 30 | readPtr = 0; 31 | sink = dest; 32 | } 33 | 34 | AudioOutputBuffer::~AudioOutputBuffer() 35 | { 36 | free(leftSample); 37 | free(rightSample); 38 | } 39 | 40 | bool AudioOutputBuffer::SetRate(int hz) 41 | { 42 | return sink->SetRate(hz); 43 | } 44 | 45 | bool AudioOutputBuffer::SetBitsPerSample(int bits) 46 | { 47 | return sink->SetBitsPerSample(bits); 48 | } 49 | 50 | bool AudioOutputBuffer::SetChannels(int channels) 51 | { 52 | return sink->SetChannels(channels); 53 | } 54 | 55 | bool AudioOutputBuffer::begin() 56 | { 57 | filled = false; 58 | return sink->begin(); 59 | } 60 | 61 | bool AudioOutputBuffer::ConsumeSample(int16_t sample[2]) 62 | { 63 | // First, try and fill I2S... 64 | if (filled) { 65 | while (readPtr != writePtr) { 66 | int16_t s[2] = {leftSample[readPtr], rightSample[readPtr]}; 67 | if (!sink->ConsumeSample(s)) break; // Can't stuff any more in I2S... 68 | readPtr = (readPtr + 1) % buffSize; 69 | } 70 | } 71 | 72 | // Now, do we have space for a new sample? 73 | int nextWritePtr = (writePtr + 1) % buffSize; 74 | if (nextWritePtr == readPtr) { 75 | filled = true; 76 | return false; 77 | } 78 | leftSample[writePtr] = sample[LEFTCHANNEL]; 79 | rightSample[writePtr] = sample[RIGHTCHANNEL]; 80 | writePtr = nextWritePtr; 81 | return true; 82 | } 83 | 84 | bool AudioOutputBuffer::stop() 85 | { 86 | return sink->stop(); 87 | } 88 | 89 | 90 | -------------------------------------------------------------------------------- /src/AudioOutputULP.h: -------------------------------------------------------------------------------- 1 | /* 2 | AudioOutputULP 3 | Outputs to ESP32 DAC through the ULP, freeing I2S for other uses 4 | 5 | Copyright (C) 2020 Martin Laclaustra, based on bitluni's code 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | // Instructions: 22 | // AudioOutputULP out = new AudioOutputULP(); // stereo 23 | // Connect left channel on pin 25 24 | // Connect right channel on pin 26 25 | // OR 26 | // Connect mono channel on either of them (stereo samples are downmixed) 27 | // AudioOutputULP out = new AudioOutputULP(1); // mono, only DAC 1 28 | // OR 29 | // AudioOutputULP out = new AudioOutputULP(2); // mono, only DAC 2 30 | 31 | 32 | #ifndef _AUDIOOUTPUTULP_H 33 | #define _AUDIOOUTPUTULP_H 34 | 35 | #include "AudioOutput.h" 36 | 37 | #ifdef ESP32 38 | 39 | class AudioOutputULP : public AudioOutput 40 | { 41 | public: 42 | AudioOutputULP(int argActiveDACs=3) {if(argActiveDACs<1||argActiveDACs>2)argActiveDACs=3;activeDACs=argActiveDACs;stereoOutput=activeDACs==3;}; 43 | ~AudioOutputULP() {}; 44 | virtual bool begin() override; 45 | virtual bool ConsumeSample(int16_t sample[2]) override; 46 | virtual bool stop() override; 47 | enum : int { DAC1 = 1, DAC2 = 2 }; 48 | private: 49 | int lastFilledWord = 0; 50 | uint8_t bufferedOddSample = 128; 51 | bool waitingOddSample = true; // must be set to false for mono output 52 | int activeDACs = 3; // 1:DAC1; 2:DAC2; 3:both; 53 | bool stereoOutput = true; 54 | const int opcodeCount = 20; 55 | const uint32_t dacTableStart1 = 2048 - 512; 56 | const uint32_t dacTableStart2 = dacTableStart1 - 512; 57 | uint32_t totalSampleWords = 2048 - 512 - 512 - (opcodeCount + 1); // add 512 for mono 58 | const int totalSamples = totalSampleWords * 2; 59 | const uint32_t indexAddress = opcodeCount; 60 | const uint32_t bufferStart = indexAddress + 1; 61 | }; 62 | 63 | #else 64 | 65 | #error Only the ESP32 supports ULP audio output 66 | 67 | #endif 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /src/libopus/silk/init_decoder.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | //#ifdef HAVE_CONFIG_H 29 | #include "../config.h" 30 | //#endif 31 | 32 | #include "main.h" 33 | 34 | /************************/ 35 | /* Init Decoder State */ 36 | /************************/ 37 | opus_int silk_init_decoder( 38 | silk_decoder_state *psDec /* I/O Decoder state pointer */ 39 | ) 40 | { 41 | /* Clear the entire encoder state, except anything copied */ 42 | silk_memset( psDec, 0, sizeof( silk_decoder_state ) ); 43 | 44 | /* Used to deactivate LSF interpolation */ 45 | psDec->first_frame_after_reset = 1; 46 | psDec->prev_gain_Q16 = 65536; 47 | psDec->arch = opus_select_arch(); 48 | 49 | /* Reset CNG state */ 50 | silk_CNG_Reset( psDec ); 51 | 52 | /* Reset PLC state */ 53 | silk_PLC_Reset( psDec ); 54 | 55 | return(0); 56 | } 57 | 58 | -------------------------------------------------------------------------------- /src/libopus/silk/inner_prod_aligned.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | //#ifdef HAVE_CONFIG_H 29 | #include "../config.h" 30 | //#endif 31 | 32 | #include "SigProc_FIX.h" 33 | 34 | opus_int32 silk_inner_prod_aligned_scale( 35 | const opus_int16 *const inVec1, /* I input vector 1 */ 36 | const opus_int16 *const inVec2, /* I input vector 2 */ 37 | const opus_int scale, /* I number of bits to shift */ 38 | const opus_int len /* I vector lengths */ 39 | ) 40 | { 41 | opus_int i; 42 | opus_int32 sum = 0; 43 | for( i = 0; i < len; i++ ) { 44 | sum = silk_ADD_RSHIFT32( sum, silk_SMULBB( inVec1[ i ], inVec2[ i ] ), scale ); 45 | } 46 | return sum; 47 | } 48 | -------------------------------------------------------------------------------- /src/AudioFileSourceSTDIO.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | AudioFileSourceSTDIO 3 | Input STDIO "file" to be used by AudioGenerator 4 | Only for hot-based testing 5 | 6 | Copyright (C) 2017 Earle F. Philhower, III 7 | 8 | This program is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program. If not, see . 20 | */ 21 | 22 | #include 23 | #ifndef ARDUINO 24 | #include 25 | 26 | #include "AudioFileSourceSTDIO.h" 27 | 28 | AudioFileSourceSTDIO::AudioFileSourceSTDIO() 29 | { 30 | f = NULL; 31 | srand(time(NULL)); 32 | } 33 | 34 | AudioFileSourceSTDIO::AudioFileSourceSTDIO(const char *filename) 35 | { 36 | open(filename); 37 | } 38 | 39 | bool AudioFileSourceSTDIO::open(const char *filename) 40 | { 41 | f = fopen(filename, "rb"); 42 | return f; 43 | } 44 | 45 | AudioFileSourceSTDIO::~AudioFileSourceSTDIO() 46 | { 47 | if (f) fclose(f); 48 | f = NULL; 49 | } 50 | 51 | uint32_t AudioFileSourceSTDIO::read(void *data, uint32_t len) 52 | { 53 | // if (rand() % 100 == 69) { // Give 0 data 1% 54 | // printf("0 read\n"); 55 | // len = 0; 56 | // } else if (rand() % 100 == 1) { // Give short reads 1% 57 | // printf("0 read\n"); 58 | // len = 0; 59 | // } 60 | int ret = fread(reinterpret_cast(data), 1, len, f); 61 | // if (ret && rand() % 100 < 5 ) { 62 | // // We're really mean...throw bad data in the mix 63 | // printf("bad data\n"); 64 | // for (int i=0; i<100; i++) 65 | // *(reinterpret_cast(data) + (rand() % ret)) = rand(); 66 | // } 67 | return ret; 68 | } 69 | 70 | bool AudioFileSourceSTDIO::seek(int32_t pos, int dir) 71 | { 72 | return fseek(f, pos, dir) == 0; 73 | } 74 | 75 | bool AudioFileSourceSTDIO::close() 76 | { 77 | fclose(f); 78 | f = NULL; 79 | return true; 80 | } 81 | 82 | bool AudioFileSourceSTDIO::isOpen() 83 | { 84 | return f?true:false; 85 | } 86 | 87 | uint32_t AudioFileSourceSTDIO::getSize() 88 | { 89 | if (!f) return 0; 90 | uint32_t p = ftell(f); 91 | fseek(f, 0, SEEK_END); 92 | uint32_t len = ftell(f); 93 | fseek(f, p, SEEK_SET); 94 | return len; 95 | } 96 | 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /src/libopus/celt/cpu_support.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2010 Xiph.Org Foundation 2 | * Copyright (c) 2013 Parrot */ 3 | /* 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef CPU_SUPPORT_H 29 | #define CPU_SUPPORT_H 30 | 31 | #include "../opus_types.h" 32 | #include "../opus_defines.h" 33 | 34 | #if defined(OPUS_HAVE_RTCD) && \ 35 | (defined(OPUS_ARM_ASM) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR)) 36 | #include "arm/armcpu.h" 37 | 38 | /* We currently support 4 ARM variants: 39 | * arch[0] -> ARMv4 40 | * arch[1] -> ARMv5E 41 | * arch[2] -> ARMv6 42 | * arch[3] -> NEON 43 | */ 44 | #define OPUS_ARCHMASK 3 45 | 46 | #elif (defined(OPUS_X86_MAY_HAVE_SSE) && !defined(OPUS_X86_PRESUME_SSE)) || \ 47 | (defined(OPUS_X86_MAY_HAVE_SSE2) && !defined(OPUS_X86_PRESUME_SSE2)) || \ 48 | (defined(OPUS_X86_MAY_HAVE_SSE4_1) && !defined(OPUS_X86_PRESUME_SSE4_1)) || \ 49 | (defined(OPUS_X86_MAY_HAVE_AVX) && !defined(OPUS_X86_PRESUME_AVX)) 50 | 51 | #include "x86/x86cpu.h" 52 | /* We currently support 5 x86 variants: 53 | * arch[0] -> non-sse 54 | * arch[1] -> sse 55 | * arch[2] -> sse2 56 | * arch[3] -> sse4.1 57 | * arch[4] -> avx 58 | */ 59 | #define OPUS_ARCHMASK 7 60 | int opus_select_arch(void); 61 | 62 | #else 63 | #define OPUS_ARCHMASK 0 64 | 65 | static OPUS_INLINE int opus_select_arch(void) 66 | { 67 | return 0; 68 | } 69 | #endif 70 | #endif 71 | -------------------------------------------------------------------------------- /src/libflac/private/format.h: -------------------------------------------------------------------------------- 1 | /* libFLAC - Free Lossless Audio Codec library 2 | * Copyright (C) 2000-2009 Josh Coalson 3 | * Copyright (C) 2011-2016 Xiph.Org Foundation 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * - Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * - Neither the name of the Xiph.org Foundation nor the names of its 17 | * contributors may be used to endorse or promote products derived from 18 | * this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef FLAC__PRIVATE__FORMAT_H 34 | #define FLAC__PRIVATE__FORMAT_H 35 | 36 | #include "../FLAC/format.h" 37 | 38 | uint32_t FLAC__format_get_max_rice_partition_order(uint32_t blocksize, uint32_t predictor_order); 39 | uint32_t FLAC__format_get_max_rice_partition_order_from_blocksize(uint32_t blocksize); 40 | uint32_t FLAC__format_get_max_rice_partition_order_from_blocksize_limited_max_and_predictor_order(uint32_t limit, uint32_t blocksize, uint32_t predictor_order); 41 | void FLAC__format_entropy_coding_method_partitioned_rice_contents_init(FLAC__EntropyCodingMethod_PartitionedRiceContents *object); 42 | void FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(FLAC__EntropyCodingMethod_PartitionedRiceContents *object); 43 | FLAC__bool FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(FLAC__EntropyCodingMethod_PartitionedRiceContents *object, uint32_t max_partition_order); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/libopus/silk/bwexpander_32.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | //#ifdef HAVE_CONFIG_H 29 | #include "../config.h" 30 | //#endif 31 | 32 | #include "SigProc_FIX.h" 33 | 34 | /* Chirp (bandwidth expand) LP AR filter */ 35 | void silk_bwexpander_32( 36 | opus_int32 *ar, /* I/O AR filter to be expanded (without leading 1) */ 37 | const opus_int d, /* I Length of ar */ 38 | opus_int32 chirp_Q16 /* I Chirp factor in Q16 */ 39 | ) 40 | { 41 | opus_int i; 42 | opus_int32 chirp_minus_one_Q16 = chirp_Q16 - 65536; 43 | 44 | for( i = 0; i < d - 1; i++ ) { 45 | ar[ i ] = silk_SMULWW( chirp_Q16, ar[ i ] ); 46 | chirp_Q16 += silk_RSHIFT_ROUND( silk_MUL( chirp_Q16, chirp_minus_one_Q16 ), 16 ); 47 | } 48 | ar[ d - 1 ] = silk_SMULWW( chirp_Q16, ar[ d - 1 ] ); 49 | } 50 | 51 | -------------------------------------------------------------------------------- /src/libflac/bitmath.c: -------------------------------------------------------------------------------- 1 | /* libFLAC - Free Lossless Audio Codec library 2 | * Copyright (C) 2001-2009 Josh Coalson 3 | * Copyright (C) 2011-2016 Xiph.Org Foundation 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * - Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * - Neither the name of the Xiph.org Foundation nor the names of its 17 | * contributors may be used to endorse or promote products derived from 18 | * this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | //#ifdef HAVE_CONFIG_H 34 | # include "config.h" 35 | //#endif 36 | 37 | #pragma GCC optimize ("O3") 38 | 39 | #include "private/bitmath.h" 40 | 41 | /* An example of what FLAC__bitmath_silog2() computes: 42 | * 43 | * silog2(-10) = 5 44 | * silog2(- 9) = 5 45 | * silog2(- 8) = 4 46 | * silog2(- 7) = 4 47 | * silog2(- 6) = 4 48 | * silog2(- 5) = 4 49 | * silog2(- 4) = 3 50 | * silog2(- 3) = 3 51 | * silog2(- 2) = 2 52 | * silog2(- 1) = 2 53 | * silog2( 0) = 0 54 | * silog2( 1) = 2 55 | * silog2( 2) = 3 56 | * silog2( 3) = 3 57 | * silog2( 4) = 4 58 | * silog2( 5) = 4 59 | * silog2( 6) = 4 60 | * silog2( 7) = 4 61 | * silog2( 8) = 5 62 | * silog2( 9) = 5 63 | * silog2( 10) = 5 64 | */ 65 | uint32_t FLAC__bitmath_silog2(FLAC__int64 v) 66 | { 67 | if(v == 0) 68 | return 0; 69 | 70 | if(v == -1) 71 | return 2; 72 | 73 | v = (v < 0) ? (-(v+1)) : v; 74 | return FLAC__bitmath_ilog2_wide(v)+2; 75 | } 76 | -------------------------------------------------------------------------------- /src/libopus/celt/modes.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007-2008 CSIRO 2 | Copyright (c) 2007-2009 Xiph.Org Foundation 3 | Copyright (c) 2008 Gregory Maxwell 4 | Written by Jean-Marc Valin and Gregory Maxwell */ 5 | /* 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | - Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | - Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 21 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 23 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef MODES_H 31 | #define MODES_H 32 | 33 | #include "../opus_types.h" 34 | #include "celt.h" 35 | #include "arch.h" 36 | #include "mdct.h" 37 | #include "entenc.h" 38 | #include "entdec.h" 39 | 40 | #define MAX_PERIOD 1024 41 | 42 | typedef struct { 43 | int size; 44 | const opus_int16 *index; 45 | const unsigned char *bits; 46 | const unsigned char *caps; 47 | } PulseCache; 48 | 49 | /** Mode definition (opaque) 50 | @brief Mode definition 51 | */ 52 | struct OpusCustomMode { 53 | opus_int32 Fs; 54 | int overlap; 55 | 56 | int nbEBands; 57 | int effEBands; 58 | opus_val16 preemph[4]; 59 | const opus_int16 *eBands; /**< Definition for each "pseudo-critical band" */ 60 | 61 | int maxLM; 62 | int nbShortMdcts; 63 | int shortMdctSize; 64 | 65 | int nbAllocVectors; /**< Number of lines in the matrix below */ 66 | const unsigned char *allocVectors; /**< Number of bits in each band for several rates */ 67 | const opus_int16 *logN; 68 | 69 | const opus_val16 *window; 70 | mdct_lookup mdct; 71 | PulseCache cache; 72 | }; 73 | 74 | 75 | #endif 76 | --------------------------------------------------------------------------------