import esp audio lib

This commit is contained in:
2021-08-27 16:42:43 +02:00
parent 489174fdc8
commit 3d437de0e6
567 changed files with 267532 additions and 38 deletions

View File

@@ -0,0 +1,20 @@
Copyright (C) 2017 Bernhard Schelling
Based on SFZero, Copyright (C) 2012 Steve Folta (https://github.com/stevefolta/SFZero)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,40 @@
This is a ported and significantly modified version of TinySoundFont by
Bernhard Schelling. https://github.com/schellingb/TinySoundFont
TinySoundFont lets you use a SoundFont2 library (sampled MIDI instruments)
to play high quality music with a single #include.
Porting and modifications done by Earle F. Philhower, III
<earlephilhower@yahoo.com> and released under the GPL v3 or later.
The changes to allow it to work on the ESP8266 consisted mostly in making
it significantly less memory intensive and speeding up the inner loops by
using fixed point arithmetic instead of floating point. This change to
fixed point lets us use simple integer math, which is massively faster than
the software FP libraries on the ESP8266, but does come at the cost of a
slightly increased noise floor.
On the memory side, all data structures were converted into a "lazy"
allocation which means that instead of loading the full contents of the
header bits into RAM (which is often WAY more than the 40KB available on
the EPS8266), only those bits needed are loaded, and only when they are
needed.
Also, instead of loading the entire sample array into memory (i.e. nearly
500MB for a good piano sample), only a very small portion is loaded into a
LRU *cache* area.
Even with the caching, it was found that SPIFFS, while having great
functionality, was horrbly slow. So I wrote a new "faster" ROM filesystem
called, surprisingly, FastROMFilesystem.
https://github.com/earlephilhower/ESP8266FastROMFS
If you are getting choppy playback, try this new filesytem or using a SD
card (not tested by myself, but it'd be hard top be slower than SPIFFS).
Simply going from SPIFFS to FastROMFilesystem took my testing of
FURELISE.MID and 1MGM.SF2 from 0.5x realtime to 2.5x (i.e. from unusable
stuttering to plenty of time to do other tings on the ESP8266) for the
first 20 seconds or so tested.
-Earle F. Philhower, III
earlephilhower@yahoo.com

View File

@@ -0,0 +1,37 @@
# TinySoundFont
SoundFont2 synthesizer library in a single C/C++ file
## Overview
TinySoundFont is a software synthesizer using SoundFont2 sound bank files.
The library is a single C header file so it is extremely simple to integrate in your C/C++ projects.
```c++
#define TSF_IMPLEMENTATION
#include "tsf.h"
...
tsf* TinySoundFont = tsf_load_filename("soundfont.sf2");
tsf_set_output(TinySoundFont, TSF_MONO, 44100, 0); //sample rate
tsf_note_on(TinySoundFont, 0, 60, 1.0f); //preset 0, middle C
short HalfSecond[22050]; //synthesize 0.5 seconds
tsf_render_short(TinySoundFont, HalfSecond, 22050, 0);
```
The library code is based on [SFZero by Steve Folta](https://github.com/stevefolta/SFZero).
## Documentation
The API documentation can be found on [top of the library source code](https://github.com/schellingb/TinySoundFont/blob/master/tsf.h).
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.
## Dependencies
C standard libraries for fopen, math and malloc (can be removed by providing custom functions with #defines).
## License
TinySoundFont is available under the [MIT license](https://choosealicense.com/licenses/mit/).

File diff suppressed because it is too large Load Diff