Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3044568f85 | ||
|
|
8adeb31d20 | ||
|
|
b0a06edde2 | ||
|
|
cdd07c92c2 | ||
|
|
aafabf2367 | ||
|
|
90b83fb95e | ||
|
|
fbe69b8cd8 | ||
|
|
2f43b3b57d | ||
|
|
0e5870a440 | ||
|
|
7e50a43b4b | ||
|
|
1278b10717 | ||
|
|
52c49afbc0 | ||
|
|
d32d8b4cc8 | ||
|
|
235bcb12de | ||
|
|
a4a974363d | ||
|
|
96dc79c9fa | ||
|
|
50bc3f7279 | ||
|
|
79208f6701 | ||
|
|
a0a4a00757 | ||
|
|
c93201483f | ||
|
|
a6141473fb | ||
|
|
b837e7d36a | ||
|
|
51a584c2b7 | ||
|
|
492a5beba4 | ||
|
|
89a5a07712 | ||
|
|
b3c41668a2 | ||
|
|
139fba4116 | ||
|
|
b7d89058dd | ||
|
|
e306df208c | ||
|
|
f6c0d562f8 | ||
|
|
60b93433d8 | ||
|
|
0abcf71012 | ||
|
|
12131e9826 | ||
|
|
4ba7df1928 | ||
|
|
0b5da0e9dd | ||
|
|
46b36574ed | ||
|
|
f95f15fcb3 | ||
|
|
72ed4f76dd | ||
|
|
a323627243 | ||
|
|
93c4e3a15a | ||
|
|
bf31f0f8be | ||
|
|
e24223e3d5 | ||
|
|
6d3b8665f4 | ||
|
|
02225bcaa9 | ||
|
|
c4bf70bccf | ||
|
|
3b329b8201 | ||
|
|
c2adbdcf88 | ||
|
|
b987ca3540 | ||
|
|
19f802923d | ||
|
|
9a9e030d90 | ||
|
|
879fe48b78 | ||
|
|
b9666d3652 | ||
|
|
a6f1eda9a2 | ||
|
|
2069060574 | ||
|
|
be8b8efbf2 | ||
|
|
9384bb0f3d | ||
|
|
76235d0e3f | ||
|
|
c87b662cb6 | ||
|
|
9ffb8a503a | ||
|
|
8b4010bf84 | ||
|
|
20943870a9 | ||
|
|
73a1821aba | ||
|
|
d5dea4f20c | ||
|
|
7a82ba2ab3 | ||
|
|
c55d240ade | ||
|
|
fe7a1f7951 | ||
|
|
4971e5ce68 | ||
|
|
29e5e016af | ||
|
|
dca33f80c7 | ||
|
|
faa8b094c9 | ||
|
|
7ac86f015f | ||
|
|
933439fa3f | ||
|
|
0d132c1391 | ||
|
|
de30f61899 | ||
|
|
2c1aeba4ab | ||
|
|
617b06d09a | ||
|
|
e254ad9543 | ||
|
|
86a1818da5 | ||
|
|
b65bc2df8f | ||
|
|
f9a78e7ef5 | ||
|
|
701ca39669 | ||
|
|
84593933e5 | ||
|
|
9485887879 | ||
|
|
62463b15f7 | ||
|
|
c55abbfba5 | ||
|
|
5411abef6b | ||
|
|
f47793bc4c | ||
|
|
9dd4f24056 | ||
|
|
627a106479 | ||
|
|
6882b6e1b6 | ||
|
|
6ed2604015 | ||
|
|
5a5c2a88a3 | ||
|
|
c3c9a147c5 | ||
|
|
4111404bac | ||
|
|
d4c09498c5 | ||
|
|
8bf52d4c11 | ||
|
|
f974af9bf3 | ||
|
|
9b4f36009b | ||
|
|
0d6e1340f0 | ||
|
|
8d6631e4ab | ||
|
|
a72bee6d73 | ||
|
|
09b1fd1788 | ||
|
|
b37e9d232b | ||
|
|
f4d4e69332 | ||
|
|
714e8cf594 | ||
|
|
6ecb6afe30 | ||
|
|
4994de7cb7 | ||
|
|
3e3bc35493 | ||
|
|
3349608b11 | ||
|
|
40d0d997a8 | ||
|
|
0cee4d410e | ||
|
|
b832ec2434 | ||
|
|
7cb02a6986 | ||
|
|
435e2cf028 | ||
|
|
dd8ac07e4e | ||
|
|
e65cc0fab0 | ||
|
|
1c548c8846 | ||
|
|
2dc245ff2e | ||
|
|
7f3908c239 | ||
|
|
299db3d03d | ||
|
|
0c4c9e1637 | ||
|
|
1c7a2f7cb5 | ||
|
|
bbd8748f86 | ||
|
|
299833dbf9 | ||
|
|
90258c566a | ||
|
|
0ec3bc3b31 | ||
|
|
2fb8d887b1 | ||
|
|
93a540da9b | ||
|
|
1c51669729 | ||
|
|
96d036087b | ||
|
|
cd42e28ca5 | ||
|
|
cdf71d6bcf | ||
|
|
197b7fe794 | ||
|
|
a0a06a9832 | ||
|
|
fae26d4010 |
No files matched your search
@@ -13,6 +13,29 @@ on:
|
||||
|
||||
jobs:
|
||||
|
||||
build-rp2040:
|
||||
name: Build RP2040
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
chunk: [0, 1, 2, 3, 4]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- name: Build Sketches
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
TRAVIS_TAG: ${{ github.ref }}
|
||||
BUILD_TYPE: build_rp2040
|
||||
BUILD_MOD: 5
|
||||
BUILD_REM: ${{ matrix.chunk }}
|
||||
run: |
|
||||
bash ./tests/common.sh
|
||||
|
||||
build-esp8266:
|
||||
name: Build ESP8266
|
||||
runs-on: ubuntu-latest
|
||||
@@ -20,10 +43,10 @@ jobs:
|
||||
matrix:
|
||||
chunk: [0, 1, 2, 3, 4]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
- uses: actions/setup-python@v2
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- name: Build Sketches
|
||||
@@ -36,7 +59,6 @@ jobs:
|
||||
run: |
|
||||
bash ./tests/common.sh
|
||||
|
||||
|
||||
build-esp32:
|
||||
name: Build ESP-32
|
||||
runs-on: ubuntu-latest
|
||||
@@ -44,10 +66,10 @@ jobs:
|
||||
matrix:
|
||||
chunk: [0, 1, 2, 3, 4]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
- uses: actions/setup-python@v2
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- name: Build Sketches
|
||||
@@ -65,10 +87,10 @@ jobs:
|
||||
name: Host tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
- uses: actions/setup-python@v2
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- name: Run host tests
|
||||
@@ -84,5 +106,33 @@ jobs:
|
||||
valgrind --leak-check=full --track-origins=yes -v --error-limit=no --show-leak-kinds=all --error-exitcode=999 ./mp3
|
||||
valgrind --leak-check=full --track-origins=yes -v --error-limit=no --show-leak-kinds=all --error-exitcode=999 ./aac
|
||||
valgrind --leak-check=full --track-origins=yes -v --error-limit=no --show-leak-kinds=all --error-exitcode=999 ./wav
|
||||
valgrind --leak-check=full --track-origins=yes -v --error-limit=no --show-leak-kinds=all --error-exitcode=999 ./flac
|
||||
valgrind --leak-check=full --track-origins=yes -v --error-limit=no --show-leak-kinds=all --error-exitcode=999 ./mod
|
||||
valgrind --leak-check=full --track-origins=yes -v --error-limit=no --show-leak-kinds=all --error-exitcode=999 ./wav
|
||||
valgrind --leak-check=full --track-origins=yes -v --error-limit=no --show-leak-kinds=all --error-exitcode=999 ./midi
|
||||
valgrind --leak-check=full --track-origins=yes -v --error-limit=no --show-leak-kinds=all --error-exitcode=999 ./opus
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: arduino/arduino-lint-action@v2
|
||||
with:
|
||||
library-manager: 'update'
|
||||
|
||||
# Validate orthography
|
||||
code-spell:
|
||||
name: Check spelling
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
- name: Run codespell
|
||||
uses: codespell-project/actions-codespell@master
|
||||
with:
|
||||
skip: ./src/libmad,./src/libhelix-aac,./src/libopus,./src/libflac
|
||||
ignore_words_list: ESP8266,esp8266,esp,dout,DOUT,ser,ans,inout,numer,hist
|
||||
@@ -1,35 +1,34 @@
|
||||
# ESP8266Audio - supports ESP8266 & ESP32 [](https://gitter.im/ESP8266Audio/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
||||
# ESP8266Audio - supports ESP8266 & ESP32 & Raspberry Pi Pico RP2040 and Pico 2 RP2350 [](https://gitter.im/ESP8266Audio/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
||||
Arduino library for parsing and decoding MOD, WAV, MP3, FLAC, MIDI, AAC, and RTTL files and playing them on an I2S DAC or even using a software-simulated delta-sigma DAC with dynamic 32x-128x oversampling.
|
||||
|
||||
# Raspberry Pi Pico (RP2040 and RP2350) Users
|
||||
Consider using [BackgroundAudio](https://github.com/earlephilhower/BackgroundAudio) instead of this library as it can provide a simpler usage model and better results and performance on the Pico by using an interrupt-based, frame-aligned output model.
|
||||
|
||||
# ESP8266 and ESP32 Users
|
||||
ESP8266 is fully supported and most mature, but ESP32 is also mostly there with built-in DAC as well as external ones.
|
||||
|
||||
For real-time, autonomous speech synthesis, check out [ESP8266SAM](https://github.com/earlephilhower/ESP8266SAM), a library which uses this one and a port of an ancient format-based synthesis program to allow your ESP8266 to talk with low memory and no network required.
|
||||
For real-time, autonomous speech synthesis, check out [ESP8266SAM](https://github.com/earlephilhower/ESP8266SAM), a library which uses this one and a port of an ancient formant-based synthesis program to allow your ESP8266 to talk with low memory and no network required.
|
||||
|
||||
## Disclaimer
|
||||
All this code is released under the GPL, and all of it is to be used at your own risk. If you find any bugs, please let me know via the GitHub issue tracker or drop me an email. The MOD and MP3 routines were taken from StellaPlayer and libMAD respectively. The software I2S delta-sigma 32x oversampling DAC was my own creation, and sounds quite good if I do say so myself.
|
||||
All this code is released under the GPL, and all of it is to be used at your own risk. If you find any bugs, please let me know via the GitHub issue tracker or drop me an email.
|
||||
|
||||
The AAC decode code is from the Helix project and licensed under RealNetwork's RSPL license. For commercial use you're still going to need the usual AAC licensing from [Via Licensing](http://www.via-corp.com/us/en/licensing/aac/overview.html).
|
||||
|
||||
On the ESP32, AAC-SBR is supported (many webradio stations use this to reduce bandwidth even further). The ESP8266, however, does not support it due to a lack of onboard RAM.
|
||||
|
||||
MIDI decoding comes from a highly ported [MIDITONES](https://github.com/LenShustek/miditones) combined with a massively memory-optimized [TinySoundFont](https://github.com/schellingb/TinySoundFont), see the respective source files for more information.
|
||||
* The MOD and MP3 routines were taken from StellarPlayer and libMAD respectively.
|
||||
* The software I2S delta-sigma 32x oversampling DAC was my own creation, and sounds quite good if I do say so myself.
|
||||
* The AAC decode code is from the Helix project and licensed under RealNetwork's RSPL license. For commercial use you're still going to need the usual AAC licensing from [Via Licensing](http://www.via-corp.com/us/en/licensing/aac/overview.html). On the ESP32, AAC-SBR is supported (many webradio stations use this to reduce bandwidth even further). The ESP8266, however, does not support it due to a lack of onboard RAM.
|
||||
* MIDI decoding comes from a highly ported [MIDITONES](https://github.com/LenShustek/miditones) combined with a massively memory-optimized [TinySoundFont](https://github.com/schellingb/TinySoundFont), see the respective source files for more information.
|
||||
* Opus, OGG, and OpusFile are from [Xiph.org](https://xiph.org) with the Xiph license and patent described in src/{opusfile,libggg,libopus}/COPYING.. **NOTE** Opus decoding currently only works on the ESP32 due to the large memory requirements of opusfile. PRs to rewrite it to be less memory intensive would be much appreciated.
|
||||
|
||||
## Neat Things People Have Done With ESP8266Audio
|
||||
If you have a neat use for this library, [I'd love to hear about it](mailto:earlephilhower@yahoo.com)!
|
||||
|
||||
My personal use of the ESP8266Audio library is only to drive a 3D-printed, network-time-setting alarm clock for my kids which can play an MP3 instead of a bell to wake them up, called [Psychoclock](https://github.com/earlephilhower/psychoclock).
|
||||
|
||||
Harald Sattler has built a neat German [word clock with MP3 alarm](http://www.harald-sattler.de/html/mini-wecker.htm). Detailed discussion on the process and models are included.
|
||||
|
||||
Erich Heinemann has developed a Stomper (instrument for playing samples in real-time during a live stage performance) that you can find more info about [here](https://github.com/ErichHeinemann/hman-stomper).
|
||||
|
||||
Dagnall53 has integrated this into a really neat MQTT based model train controller to add sounds to his set. More info is available [here](https://github.com/dagnall53/ESPMQTTRocnetSound), including STL files for 3D printed components!
|
||||
|
||||
JohannesMTC has built a similar project especially for model trains: https://github.com/JohannesMTC/ESP32_MAS
|
||||
|
||||
A neat MQTT-driven ESP8266 light-and-sound device (alarm? toy? who can say!) was built by @CosmicMac, available at https://github.com/CosmicMac/ESParkle
|
||||
|
||||
A very interesting "linear clock" with a stepper motor, NTP time keeping, and configurable recorded chimes with schematics, 3D printer plans, and source code, is now available http://home.kpn.nl/bderogee1980/projects/linear_clock/linear_clock.html
|
||||
* My personal use of the ESP8266Audio library is only to drive a 3D-printed, network-time-setting alarm clock for my kids which can play an MP3 instead of a bell to wake them up, called [Psychoclock](https://github.com/earlephilhower/psychoclock).
|
||||
* Harald Sattler has built a neat German [word clock with MP3 alarm](http://www.harald-sattler.de/html/mini-wecker.htm). Detailed discussion on the process and models are included.
|
||||
* Erich Heinemann has developed a Stomper (instrument for playing samples in real-time during a live stage performance) that you can find more info about [here](https://github.com/ErichHeinemann/hman-stomper).
|
||||
* Dagnall53 has integrated this into a really neat MQTT based model train controller to add sounds to his set. More info is available [here](https://github.com/dagnall53/ESPMQTTRocnetSound), including STL files for 3D printed components!
|
||||
* JohannesMTC has built a similar project especially for model trains: https://github.com/JohannesMTC/ESP32_MAS
|
||||
* A neat MQTT-driven ESP8266 light-and-sound device (alarm? toy? who can say!) was built by @CosmicMac, available at https://github.com/CosmicMac/ESParkle
|
||||
* A very interesting "linear clock" with a stepper motor, NTP time keeping, and configurable recorded chimes with schematics, 3D printer plans, and source code, is now available https://janderogee.com/projects/linear_clock/linear_clock.htm
|
||||
* Source and instructions for a gorgeous wooden MP3-playing clock, FM radio and a walkie-talkie using the ESP8266 and AVR microcontrollers is available https://github.com/zduka/mp3-player
|
||||
|
||||
## Prerequisites
|
||||
First, make sure you are running the 2.6.3/later or GIT head version of the Arduino libraries for ESP8266, or the latest ESP32 SDK from Espressif.
|
||||
@@ -98,7 +97,7 @@ AudioFileSourcePROGMEM: Reads a file from a PROGMEM array. Under UNIX you can
|
||||
AudioFileSourceHTTPStream: Simple implementation of a streaming HTTP reader for ShoutCast-type MP3 streaming. Not yet resilient, and at 44.1khz 128bit stutters due to CPU limitations, but it works more or less.
|
||||
|
||||
## AudioFileSourceBuffer - Double buffering, useful for HTTP streams
|
||||
AudioFileSourceBuffer is an input source that simpy adds an additional RAM buffer of the output of any other AudioFileSource. This is particularly useful for web streaming where you need to have 1-2 packets in memory to ensure hiccup-free playback.
|
||||
AudioFileSourceBuffer is an input source that simply adds an additional RAM buffer of the output of any other AudioFileSource. This is particularly useful for web streaming where you need to have 1-2 packets in memory to ensure hiccup-free playback.
|
||||
|
||||
Create your standard input file source, create the buffer with the original source as its input, and pass this buffer object to the generator.
|
||||
```cpp
|
||||
@@ -143,7 +142,7 @@ AudioGeneratorRTTTL: Enjoy the pleasures of monophonic, 4-octave ringtones on y
|
||||
## AudioOutput classes
|
||||
AudioOutput: Base class for all output drivers. Takes a sample at a time and returns true/false if there is buffer space for it. If it returns false, it is the calling object's (AudioGenerator's) job to keep the data that didn't fit and try again later.
|
||||
|
||||
AudioOutputI2S: Interface for any I2S 16-bit DAC. Sends stereo or mono signals out at whatever frequency set. Tested with Adafruit's I2SDAC and a Beyond9032 DAC from eBay. Tested up to 44.1KHz. To use the internal DAC on ESP32, instantiate this class as `AudioOutputI2S(0,1)`, see example `PlayMODFromPROGMEMToDAC` and code in [AudioOutputI2S.cpp](src/AudioOutputI2S.cpp#L29) for details.
|
||||
AudioOutputI2S: Interface for any I2S 16-bit DAC. Sends stereo or mono signals out at whatever frequency set. Tested with Adafruit's I2SDAC and a Beyond9032 DAC from eBay. Tested up to 44.1KHz. To use the internal DAC on ESP32, instantiate this class as `AudioOutputI2S(0,AudioOutputI2S::INTERNAL_DAC)`, see example `PlayMODFromPROGMEMToDAC` and code in [AudioOutputI2S.cpp](src/AudioOutputI2S.cpp#L29) for details. To use the hardware Pulse Density Modulation (PDM) on ESP32, instantiate this class as `AudioOutputI2S(0,AudioOutputI2S::INTERNAL_PDM)`. For both later cases, default output pins are GPIO25 and GPIO26.
|
||||
|
||||
AudioOutputI2SNoDAC: Abuses the I2S interface to play music without a DAC. Turns it into a 32x (or higher) oversampling delta-sigma DAC. Use the schematic below to drive a speaker or headphone from the I2STx pin (i.e. Rx). Note that with this interface, depending on the transistor used, you may need to disconnect the Rx pin from the driver to perform serial uploads. Mono-only output, of course.
|
||||
|
||||
@@ -156,7 +155,15 @@ AudioOutputSPIFFSWAV: Writes a binary WAV format with headers to a SPIFFS files
|
||||
AudioOutputNull: Just dumps samples to /dev/null. Used for speed testing as it doesn't artificially limit the AudioGenerator output speed since there are no buffers to fill/drain.
|
||||
|
||||
## I2S DACs
|
||||
I've used both the Adafruit [I2S +3W amp DAC](https://www.adafruit.com/product/3006) and a generic PCM5102 based DAC with success. The biggest problems I've seen from users involve pinouts from the ESP8266 for GPIO and hooking up all necessary pins on the DAC board.
|
||||
I've used both the Adafruit [I2S +3W amp DAC](https://www.adafruit.com/product/3006) and a generic PCM5102 based DAC with success. The biggest problems I've seen from users involve pinouts from the ESP8266 for GPIO and hooking up all necessary pins on the DAC board. The essential pins are:
|
||||
|
||||
I2S pin | Common label* | ESP8266 pin
|
||||
--------|---------------|-------------
|
||||
LRC | D4 | GPIO2
|
||||
BCLK | D8 | GPIO15
|
||||
DIN | RX | GPIO3
|
||||
|
||||
\* The "common label" column applies to common NodeMCU and D1 Mini development boards. Unfortunately some manufacturers use different mappings so the labels listed here might not apply to your particular model.
|
||||
|
||||
### Adafruit I2S DAC
|
||||
This is quite simple and only needs the GND, VIN, LRC, BCLK< and DIN pins to be wired. Be sure to use +5V on the VIN to get the loudest sound. See the [Adafruit example page](https://learn.adafruit.com/adafruit-max98357-i2s-class-d-mono-amp) for more info.
|
||||
@@ -169,7 +176,7 @@ I've used several versions of PCM5102 DAC boards purchased from eBay. They've a
|
||||
|
||||
|
||||
### Others
|
||||
There are many other variants out there, and they should all work reasonably well with this code and the ESP8266. Please be certain you've read the datasheet and are applying proper input voltages, and be sure to tie off any unused inputs to GND or VCC as appropriate. LEaving an input pin floating on any integrated circuit can cause unstable operation as it may pick up noise from the environment (very low input capacitance) and cause havoc with internal IC settings.
|
||||
There are many other variants out there, and they should all work reasonably well with this code and the ESP8266. Please be certain you've read the datasheet and are applying proper input voltages, and be sure to tie off any unused inputs to GND or VCC as appropriate. Leaving an input pin floating on any integrated circuit can cause unstable operation as it may pick up noise from the environment (very low input capacitance) and cause havoc with internal IC settings.
|
||||
|
||||
## Software I2S Delta-Sigma DAC (i.e. playing music with a single transistor and speaker)
|
||||
For the best fidelity, and stereo to boot, spend the money on a real I2S DAC. Adafruit makes a great mono one with amplifier, and you can find stereo unamplified ones on eBay or elsewhere quite cheaply. However, thanks to the software delta-sigma DAC with 32x oversampling (up to 128x if the audio rate is low enough) you can still have pretty good sound!
|
||||
@@ -187,7 +194,8 @@ Use the `AudioOutputI2S*No*DAC` object instead of the `AudioOutputI2S` in your c
|
||||
ESP8266-GND ------------------+ | +------+ K|
|
||||
| | | E|
|
||||
ESP8266-I2SOUT (Rx) -----/\/\/\--+ | \ R|
|
||||
| +-|
|
||||
or ESP32 DOUT pin | +-|
|
||||
|
|
||||
USB 5V -----------------------------+
|
||||
|
||||
You may also want to add a 220uF cap from USB5V to GND just to help filter out any voltage droop during high volume playback.
|
||||
@@ -200,11 +208,18 @@ ESP8266-RX(I2S tx) -- Resistor (~1K ohm, not critical) -- 2N3904 Base
|
||||
ESP8266-GND -- 2N3904 Emitter
|
||||
USB-5V -- Speaker + Terminal
|
||||
2N3904-Collector -- Speaker - Terminal
|
||||
|
||||
*For ESP32, default output pin is GPIO22. Note that GPIO25 ang GPIO26 are occupied by wclk/bclk and can not be used.
|
||||
```
|
||||
|
||||
*NOTE*: A prior version of this schematic had a direct connection from the ESP8266 to the base of the transistor. While this does provide the maximum amplitude, it also can draw more current from the 8266 than is safe, and can also cause the transistor to overheat.
|
||||
|
||||
As of the latest ESP8266Audio release, with the software delta-sigma DAC the LRCLK and BCLK pins *can* be used by an application. Simply use normal `pinMode` and `dicitalWrite` or `digitalRead` as desired.
|
||||
As of the latest ESP8266Audio release, with the software delta-sigma DAC the LRCLK and BCLK pins *can* be used by an application. Simply use normal `pinMode` and `digitalWrite` or `digitalRead` as desired.
|
||||
|
||||
### Hardware PDM on ESP32
|
||||
|
||||
Hardware PDM outputs 128 * 48Khz pulses regardless of sample rate.
|
||||
It seems that currently hardware PDM either does not output constant One at maximum sample level, or does not output 3.3V voltage at pulse sound is not as loud as desired. You may consider using software delta-sigma DAC instead.
|
||||
|
||||
### High pitched buzzing with the 1-T circuit
|
||||
The 1-T amp can _NOT_ drive any sort of amplified speaker. If there is a power or USB input to the speaker, or it has lights or Bluetooth or a battery, it can _NOT_ be used with this circuit.
|
||||
@@ -237,7 +252,7 @@ ESP Pin -------|____|--------+
|
||||
|
|
||||
Ground ---------------------+
|
||||
```
|
||||
For ESP8266 with red LED (~1.9Vf drop) you need minimum 150Ohm resistor (12mA max per pin), and output pin is fixed (GPIO3/RX0).On ESP32 it is confgurable with `AudioOutputSPDIF(gpio_num)`.
|
||||
For ESP8266 with red LED (~1.9Vf drop) you need minimum 150Ohm resistor (12mA max per pin), and output pin is fixed (GPIO3/RX0).On ESP32 it is configurable with `AudioOutputSPDIF(gpio_num)`.
|
||||
|
||||
## Using external SPI RAM to increase buffer
|
||||
A class allows you to use a 23lc1024 SPI RAM from Microchip as input buffer. This chip connects to ESP8266 HSPI port and provides a large buffer to help avoid hiccus in playback of web streams.
|
||||
@@ -253,10 +268,11 @@ I've been told the Wemos SD card shield uses GPIO15 as the SD chip select. This
|
||||
There's no ESP8266-specific code in the AudioGenerator routines, so porting to other controllers should be relatively easy assuming they have the same endianness as the Xtensa core used. Drop me a line if you're doing this, I may be able to help point you in the right direction.
|
||||
|
||||
## Thanks
|
||||
Thanks to the authors of StellaPlayer and libMAD for releasing their code freely, and to the maintainers and contributors to the ESP8266 Arduino port.
|
||||
Thanks to the authors of StellarPlayer and libMAD for releasing their code freely, and to the maintainers and contributors to the ESP8266 Arduino port.
|
||||
|
||||
Also, big thanks to @tueddy for getting the initial ESP32 porting into the tree!
|
||||
|
||||
-Earle F. Philhower, III
|
||||
|
||||
earlephilhower@yahoo.com
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
#include <Arduino.h>
|
||||
#ifdef ESP32
|
||||
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
#define WIFI_OFF
|
||||
class __x { public: __x() {}; void mode() {}; };
|
||||
__x WiFi;
|
||||
#elif defined(ESP32)
|
||||
#include <WiFi.h>
|
||||
#else
|
||||
#include <ESP8266WiFi.h>
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
#include <Arduino.h>
|
||||
#ifdef ARDUINO_ARCH_RP2040
|
||||
void setup() {}
|
||||
void loop() {}
|
||||
#else
|
||||
#include "AudioFileSourceSD.h"
|
||||
#include "AudioOutputSPDIF.h"
|
||||
#include "AudioGeneratorFLAC.h"
|
||||
@@ -8,7 +12,7 @@
|
||||
// Espressif Audio Development Framework at:
|
||||
// https://docs.espressif.com/projects/esp-adf/en/latest/design-guide/audio-samples.html
|
||||
//
|
||||
// On ESP8266 you might need to reencode FLAC files with max '-2' compression level
|
||||
// On ESP8266 you might need to re-encode FLAC files with max '-2' compression level
|
||||
// (i.e. 1152 maximum block size) or you will run out of memory. FLAC files will be
|
||||
// slightly bigger but you don't loose audio quality with reencoding (lossles codec).
|
||||
|
||||
@@ -61,8 +65,10 @@ void loop() {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Serial.println(F("Playback form SD card done\n"));
|
||||
Serial.println(F("Playback from SD card done\n"));
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -6,7 +6,13 @@
|
||||
}
|
||||
void loop() {}
|
||||
#else
|
||||
#include <ESP8266WiFi.h>
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
#define WIFI_OFF
|
||||
class __x { public: __x() {}; void mode() {}; };
|
||||
__x WiFi;
|
||||
#else
|
||||
#include <ESP8266WiFi.h>
|
||||
#endif
|
||||
#include <AudioOutputI2S.h>
|
||||
#include <AudioGeneratorMIDI.h>
|
||||
#include <AudioFileSourceLittleFS.h>
|
||||
@@ -42,7 +48,6 @@ void loop()
|
||||
{
|
||||
if (midi->isRunning()) {
|
||||
if (!midi->loop()) {
|
||||
uint32_t e = millis();
|
||||
midi->stop();
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
// Do not build on Espressif GCC8+, compiler bug
|
||||
|
||||
#if defined(ARDUINO_ARCH_RP2040) || (defined(ESP32) && (__GNUC__ >= 8) && (__XTENSA__))
|
||||
void setup() {}
|
||||
void loop() {}
|
||||
#else
|
||||
#ifdef ESP32
|
||||
#include <WiFi.h>
|
||||
#include "SPIFFS.h"
|
||||
@@ -25,6 +32,7 @@ void setup()
|
||||
WiFi.mode(WIFI_OFF);
|
||||
|
||||
Serial.begin(115200);
|
||||
SPIFFS.begin();
|
||||
Serial.println("Starting up...\n");
|
||||
|
||||
audioLogger = &Serial;
|
||||
@@ -43,7 +51,6 @@ void loop()
|
||||
{
|
||||
if (midi->isRunning()) {
|
||||
if (!midi->loop()) {
|
||||
uint32_t e = millis();
|
||||
midi->stop();
|
||||
}
|
||||
} else {
|
||||
@@ -52,4 +59,4 @@ void loop()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -2,7 +2,11 @@
|
||||
#include "AudioFileSourcePROGMEM.h"
|
||||
#include "AudioGeneratorMOD.h"
|
||||
#include "AudioOutputI2S.h"
|
||||
#ifdef ESP32
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
#define WIFI_OFF
|
||||
class __x { public: __x() {}; void mode() {}; };
|
||||
__x WiFi;
|
||||
#elif defined(ESP32)
|
||||
#include <WiFi.h>
|
||||
#else
|
||||
#include <ESP8266WiFi.h>
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,47 @@
|
||||
#include <Arduino.h>
|
||||
#include "AudioFileSourcePROGMEM.h"
|
||||
#include "AudioGeneratorMOD.h"
|
||||
#include "AudioOutputPWM.h"
|
||||
|
||||
#if !defined(ARDUINO_ARCH_RP2040)
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
Serial.printf("Only for the RP2040/Raspberry Pi Pico\n");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
}
|
||||
#else
|
||||
|
||||
// 5_steps.mod sample from the mod archive: https://modarchive.org/
|
||||
#include "5steps.h"
|
||||
|
||||
AudioGeneratorMOD *mod;
|
||||
AudioFileSourcePROGMEM *file;
|
||||
AudioOutputPWM *out;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
delay(1000);
|
||||
|
||||
audioLogger = &Serial;
|
||||
file = new AudioFileSourcePROGMEM(steps_mod, sizeof(steps_mod));
|
||||
out = new AudioOutputPWM();
|
||||
mod = new AudioGeneratorMOD();
|
||||
mod->SetBufferSize(3*1024);
|
||||
mod->SetSampleRate(44100);
|
||||
mod->SetStereoSeparation(32);
|
||||
mod->begin(file, out);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (mod->isRunning()) {
|
||||
if (!mod->loop()) mod->stop();
|
||||
} else {
|
||||
Serial.printf("MOD done\n");
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,9 @@
|
||||
#include <Arduino.h>
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
void setup() {}
|
||||
void loop() {}
|
||||
#else
|
||||
|
||||
#ifdef ESP32
|
||||
#include <WiFi.h>
|
||||
#include "SPIFFS.h"
|
||||
@@ -70,3 +75,4 @@ void loop()
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,8 @@
|
||||
#include <Arduino.h>
|
||||
#ifdef ARDUINO_ARCH_RP2040
|
||||
void setup() {}
|
||||
void loop() {}
|
||||
#else
|
||||
#ifdef ESP32
|
||||
#include "SPIFFS.h"
|
||||
#endif
|
||||
@@ -97,3 +101,4 @@ void loop()
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,47 @@
|
||||
#include <Arduino.h>
|
||||
#ifdef ARDUINO_ARCH_RP2040
|
||||
void setup() {}
|
||||
void loop() {}
|
||||
#else
|
||||
#ifdef ESP32
|
||||
#include <WiFi.h>
|
||||
#include "SPIFFS.h"
|
||||
#else
|
||||
#include <ESP8266WiFi.h>
|
||||
#endif
|
||||
#include "AudioFileSourceSPIFFS.h"
|
||||
#include "AudioGeneratorOpus.h"
|
||||
#include "AudioOutputI2S.h"
|
||||
|
||||
// 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/
|
||||
|
||||
AudioGeneratorOpus *opus;
|
||||
AudioFileSourceSPIFFS *file;
|
||||
AudioOutputI2S *out;
|
||||
|
||||
void setup()
|
||||
{
|
||||
WiFi.mode(WIFI_OFF);
|
||||
Serial.begin(115200);
|
||||
delay(1000);
|
||||
SPIFFS.begin();
|
||||
Serial.printf("Sample Opus playback begins...\n");
|
||||
|
||||
audioLogger = &Serial;
|
||||
file = new AudioFileSourceSPIFFS("/gs-16b-2c-44100hz.opus");
|
||||
out = new AudioOutputI2S();
|
||||
opus = new AudioGeneratorOpus();
|
||||
opus->begin(file, out);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (opus->isRunning()) {
|
||||
if (!opus->loop()) opus->stop();
|
||||
} else {
|
||||
Serial.printf("Opus done\n");
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
Binary file not shown.
@@ -0,0 +1,78 @@
|
||||
#include <Arduino.h>
|
||||
#include "AudioFileSourceFunction.h"
|
||||
#include "AudioGeneratorWAV.h"
|
||||
#include "AudioOutputI2SNoDAC.h"
|
||||
|
||||
float hz = 440.f;
|
||||
|
||||
// pre-defined function can also be used to generate the wave
|
||||
float sine_wave(const float time) {
|
||||
float v = sin(TWO_PI * hz * time); // C
|
||||
v *= fmod(time, 1.f); // change linear
|
||||
v *= 0.5; // scale
|
||||
return v;
|
||||
};
|
||||
|
||||
AudioGeneratorWAV* wav;
|
||||
AudioFileSourceFunction* file;
|
||||
AudioOutputI2SNoDAC* out;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
delay(1000);
|
||||
|
||||
// ===== create instance with length of song in [sec] =====
|
||||
file = new AudioFileSourceFunction(8.);
|
||||
//
|
||||
// you can set (sec, channels, hz, bit/sample) but you should care about
|
||||
// the trade-off between performance and the audio quality
|
||||
//
|
||||
// file = new AudioFileSourceFunction(sec, channels, hz, bit/sample);
|
||||
// channels : default = 1
|
||||
// hz : default = 8000 (8000, 11025, 22050, 44100, 48000, etc.)
|
||||
// bit/sample : default = 16 (8, 16, 32)
|
||||
|
||||
// ===== set your sound function =====
|
||||
file->addAudioGenerators([&](const float time) {
|
||||
float v = sin(TWO_PI * hz * time); // generate sine wave
|
||||
v *= fmod(time, 1.f); // change linear
|
||||
v *= 0.5; // scale
|
||||
return v;
|
||||
});
|
||||
//
|
||||
// sound function should have one argument(float) and one return(float)
|
||||
// param : float (current time [sec] of the song)
|
||||
// return : float (the amplitude of sound which varies from -1.f to +1.f)
|
||||
//
|
||||
// sound function can be registered only one or the same number with channels
|
||||
// if the channels > 1 && the number of function == 1,
|
||||
// same function are used to generate the sound in every channel
|
||||
//
|
||||
// file = new AudioFileSourceFunction(8., 2);
|
||||
// file->addAudioGenerators(
|
||||
// // L (channel 0)
|
||||
// [](const float time) {
|
||||
// return 0.25 * sin(TWO_PI * 440.f * time) * fmod(time, 1.f); // C
|
||||
// },
|
||||
// // R (channel 1)
|
||||
// [](const float time) {
|
||||
// return 0.25 * sin(TWO_PI * 550.f * time) * fmod(time, 1.f); // E
|
||||
// }
|
||||
// );
|
||||
//
|
||||
// you can also use the pre-defined function
|
||||
// file->addAudioGenerators(sine_wave);
|
||||
|
||||
out = new AudioOutputI2SNoDAC();
|
||||
wav = new AudioGeneratorWAV();
|
||||
wav->begin(file, out);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (wav->isRunning()) {
|
||||
if (!wav->loop()) wav->stop();
|
||||
} else {
|
||||
Serial.println("function done!");
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,4 @@
|
||||
#include <Arduino.h>
|
||||
#ifdef ESP32
|
||||
#include <WiFi.h>
|
||||
#else
|
||||
#include <ESP8266WiFi.h>
|
||||
#endif
|
||||
|
||||
#include "AudioFileSourcePROGMEM.h"
|
||||
#include "AudioGeneratorWAV.h"
|
||||
@@ -18,7 +13,6 @@ AudioOutputI2SNoDAC *out;
|
||||
|
||||
void setup()
|
||||
{
|
||||
WiFi.mode(WIFI_OFF);
|
||||
Serial.begin(115200);
|
||||
delay(1000);
|
||||
Serial.printf("WAV start\n");
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
#ifdef ESP32
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
void setup() {}
|
||||
void loop() {}
|
||||
|
||||
#else
|
||||
#if defined(ESP32)
|
||||
#include <WiFi.h>
|
||||
#else
|
||||
#include <ESP8266WiFi.h>
|
||||
@@ -22,7 +27,7 @@ const char* ssid = STASSID;
|
||||
const char* password = STAPSK;
|
||||
|
||||
// Randomly picked URL
|
||||
const char *URL="http://streaming.shoutcast.com/80sPlanet?lang=en-US";
|
||||
const char *URL="http://kvbstreams.dyndns.org:8000/wkvi-am";
|
||||
|
||||
AudioGeneratorMP3 *mp3;
|
||||
AudioFileSourceICYStream *file;
|
||||
@@ -104,4 +109,4 @@ void loop()
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,148 @@
|
||||
#include <Arduino.h>
|
||||
#ifdef ARDUINO_ARCH_RP2040
|
||||
void setup() {}
|
||||
void loop() {}
|
||||
#else
|
||||
|
||||
#if defined(ESP32)
|
||||
#include <WiFi.h>
|
||||
#else
|
||||
#include <ESP8266WiFi.h>
|
||||
#endif
|
||||
#include "AudioFileSourceICYStream.h"
|
||||
#include "AudioFileSourceBuffer.h"
|
||||
#include "AudioGeneratorMP3.h"
|
||||
//#include "AudioOutputI2SNoDAC.h"
|
||||
#include "AudioOutputSPDIF.h"
|
||||
|
||||
//
|
||||
// Stream MP3 from HTTP to SPDIF
|
||||
//
|
||||
|
||||
// To run, set your ESP8266 build to 160MHz, update the SSID info, and upload.
|
||||
|
||||
// Note:
|
||||
// If using ESP8266 NodeMCU connect LED to RX pin and GND pin
|
||||
|
||||
// Enter your WiFi setup here:
|
||||
#ifndef STASSID
|
||||
#define STASSID "your-ssid"
|
||||
#define STAPSK "your-password"
|
||||
#endif
|
||||
|
||||
const char* ssid = STASSID;
|
||||
const char* password = STAPSK;
|
||||
|
||||
// Examples URLs
|
||||
//const char *URL="http://kvbstreams.dyndns.org:8000/wkvi-am";
|
||||
|
||||
// Italian Rock Radio
|
||||
const char *URL="http://streamingv2.shoutcast.com/radiofreccia";
|
||||
|
||||
// Stream URL of Logitech Media Server, aka LMS, Version: 8.2.0 (August 2021)
|
||||
// const char *URL="http://192.168.1.121:9000/stream.mp3";
|
||||
|
||||
AudioGeneratorMP3 *mp3;
|
||||
AudioFileSourceICYStream *file;
|
||||
AudioFileSourceBuffer *buff;
|
||||
|
||||
// Output device is SPDIF
|
||||
AudioOutputSPDIF *out;
|
||||
|
||||
|
||||
// Called when a metadata event occurs (i.e. an ID3 tag, an ICY block, etc.
|
||||
void MDCallback(void *cbData, const char *type, bool isUnicode, const char *string)
|
||||
{
|
||||
const char *ptr = reinterpret_cast<const char *>(cbData);
|
||||
(void) isUnicode; // Punt this ball for now
|
||||
// Note that the type and string may be in PROGMEM, so copy them to RAM for printf
|
||||
char s1[32], s2[64];
|
||||
strncpy_P(s1, type, sizeof(s1));
|
||||
s1[sizeof(s1)-1]=0;
|
||||
strncpy_P(s2, string, sizeof(s2));
|
||||
s2[sizeof(s2)-1]=0;
|
||||
Serial.printf("METADATA(%s) '%s' = '%s'\n", ptr, s1, s2);
|
||||
Serial.flush();
|
||||
}
|
||||
|
||||
// Called when there's a warning or error (like a buffer underflow or decode hiccup)
|
||||
void StatusCallback(void *cbData, int code, const char *string)
|
||||
{
|
||||
const char *ptr = reinterpret_cast<const char *>(cbData);
|
||||
// Note that the string may be in PROGMEM, so copy it to RAM for printf
|
||||
char s1[64];
|
||||
strncpy_P(s1, string, sizeof(s1));
|
||||
s1[sizeof(s1)-1]=0;
|
||||
Serial.printf("STATUS(%s) '%d' = '%s'\n", ptr, code, s1);
|
||||
Serial.flush();
|
||||
}
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
delay(1000);
|
||||
Serial.println("Connecting to WiFi");
|
||||
|
||||
WiFi.disconnect();
|
||||
WiFi.softAPdisconnect(true);
|
||||
WiFi.mode(WIFI_STA);
|
||||
|
||||
WiFi.begin(ssid, password);
|
||||
|
||||
// Try forever
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
Serial.println("...Connecting to WiFi");
|
||||
delay(1000);
|
||||
}
|
||||
Serial.println("Connected");
|
||||
|
||||
audioLogger = &Serial;
|
||||
file = new AudioFileSourceICYStream(URL);
|
||||
|
||||
// Commented out for performance issues with high rate MP3 stream
|
||||
//file->RegisterMetadataCB(MDCallback, (void*)"ICY");
|
||||
|
||||
buff = new AudioFileSourceBuffer(file, 4096); // Doubled form default 2048
|
||||
|
||||
// Commented out for performance issues with high rate MP3 stream
|
||||
//buff->RegisterStatusCB(StatusCallback, (void*)"buffer");
|
||||
|
||||
// Set SPDIF output
|
||||
out = new AudioOutputSPDIF();
|
||||
mp3 = new AudioGeneratorMP3();
|
||||
|
||||
// Commented out for performance issues with high rate MP3 stream
|
||||
//mp3->RegisterStatusCB(StatusCallback, (void*)"mp3");
|
||||
|
||||
mp3->begin(buff, out);
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Commented out
|
||||
//static int lastms = 0;
|
||||
|
||||
if (mp3->isRunning()) {
|
||||
/* Commented out
|
||||
if (millis()-lastms > 1000) {
|
||||
lastms = millis();
|
||||
Serial.printf("Running for %d ms...\n", lastms);
|
||||
Serial.flush();
|
||||
}
|
||||
*/
|
||||
if (!mp3->loop()) {
|
||||
mp3->stop();
|
||||
}
|
||||
} else {
|
||||
Serial.printf("MP3 done\n");
|
||||
|
||||
// Restart ESP when streaming is done or errored
|
||||
delay(10000);
|
||||
|
||||
ESP.restart();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,9 @@
|
||||
#include <Arduino.h>
|
||||
#ifdef ESP32
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
void setup() {}
|
||||
void loop() {}
|
||||
#else
|
||||
#if defined(ESP32)
|
||||
#include <WiFi.h>
|
||||
#else
|
||||
#include <ESP8266WiFi.h>
|
||||
@@ -101,4 +105,4 @@ void loop()
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
AudioOutput
|
||||
Base class of an audio output player
|
||||
|
||||
Copyright (C) 2017 Earle F. Philhower, III
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _AUDIOOUTPUTNULLSLOW_H
|
||||
#define _AUDIOOUTPUTNULLSLOW_H
|
||||
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <linux/soundcard.h>
|
||||
|
||||
#include "AudioOutput.h"
|
||||
|
||||
class AudioOutputNullSlow : public AudioOutput
|
||||
{
|
||||
public:
|
||||
AudioOutputNullSlow() { };
|
||||
~AudioOutputNullSlow() {};
|
||||
virtual bool begin() { samples = 0; startms = millis(); return true; }
|
||||
|
||||
virtual bool ConsumeSample(int16_t sample[2]) {
|
||||
|
||||
if (fd < 0) {
|
||||
fd = open("/dev/dsp", O_RDWR);
|
||||
if (fd < 0) {
|
||||
perror("open of /dev/dsp failed (Try with 'padsp this-exec')");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (channels && lastchannels != channels) {
|
||||
Serial.printf("CHANNELS=%d\n", channels);
|
||||
int arg = channels; /* mono or stereo */
|
||||
int status = ioctl(fd, SOUND_PCM_WRITE_CHANNELS, &arg);
|
||||
if (status == -1) {
|
||||
perror("SOUND_PCM_WRITE_CHANNELS ioctl failed");
|
||||
exit(1);
|
||||
} else if (arg != channels) {
|
||||
perror("unable to set number of channels");
|
||||
exit(1);
|
||||
}
|
||||
lastchannels = channels;
|
||||
}
|
||||
|
||||
if (lastchannels > 0 && hertz && lasthertz != hertz) {
|
||||
Serial.printf("FREQ=%d\n", hertz);
|
||||
int arg = hertz*4/lastchannels; /* sampling rate */
|
||||
int status = ioctl(fd, SOUND_PCM_WRITE_RATE, &arg);
|
||||
if (status == -1) {
|
||||
perror("SOUND_PCM_WRITE_RATE ioctl failed");
|
||||
exit(1);
|
||||
}
|
||||
lasthertz = hertz;
|
||||
}
|
||||
|
||||
if (bps && lastbps != bps) {
|
||||
Serial.printf("BPS=%d\n", bps);
|
||||
int arg = bps; /* sample size */
|
||||
int status = ioctl(fd, SOUND_PCM_WRITE_BITS, &arg);
|
||||
if (status == -1) {
|
||||
perror("SOUND_PCM_WRITE_BITS ioctl failed");
|
||||
exit(1);
|
||||
} else if (arg != bps) {
|
||||
perror("unable to set sample size");
|
||||
exit(1);
|
||||
}
|
||||
lastbps = bps;
|
||||
}
|
||||
|
||||
if ((++samples & ((1<<9)-1)) == 0) {
|
||||
// let the main loop a chance to run
|
||||
return false;
|
||||
}
|
||||
|
||||
if (write(fd, sample, sizeof(sample)) != sizeof(sample)) {
|
||||
perror("doing sound");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool stop() { endms = millis(); return true; };
|
||||
unsigned long GetMilliseconds() { return endms - startms; }
|
||||
int GetSamples() { return samples; }
|
||||
int GetFrequency() { return hertz; }
|
||||
|
||||
protected:
|
||||
unsigned long startms;
|
||||
unsigned long endms;
|
||||
int samples;
|
||||
int lastchannels = -1;
|
||||
int lasthertz = -1;
|
||||
int lastbps = -1;
|
||||
int fd = -1;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
AudioOutput
|
||||
Base class of an audio output player
|
||||
|
||||
Copyright (C) 2017 Earle F. Philhower, III
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _AUDIOOUTPUTNULLSLOW_H
|
||||
#define _AUDIOOUTPUTNULLSLOW_H
|
||||
|
||||
#include "AudioOutput.h"
|
||||
|
||||
class AudioOutputNullSlow : public AudioOutput
|
||||
{
|
||||
public:
|
||||
AudioOutputNullSlow() { };
|
||||
~AudioOutputNullSlow() {};
|
||||
virtual bool begin() { samples = 0; startms = millis(); return true; }
|
||||
virtual bool ConsumeSample(int16_t sample[2]) {
|
||||
(void) sample;
|
||||
// return false (= output buffer full)
|
||||
// sometimes to let the main loop running
|
||||
constexpr int everylog2 = 10;
|
||||
if ((++samples & ((1<<everylog2)-1)) == 0) {
|
||||
if (hertz > 0) {
|
||||
// simulate real time
|
||||
delay(1000/(hertz >> everylog2));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
virtual bool stop() { endms = millis(); return true; };
|
||||
unsigned long GetMilliseconds() { return endms - startms; }
|
||||
int GetSamples() { return samples; }
|
||||
int GetFrequency() { return hertz; }
|
||||
|
||||
protected:
|
||||
unsigned long startms;
|
||||
unsigned long endms;
|
||||
int samples;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
void setup() {}
|
||||
void loop() {}
|
||||
#else
|
||||
#if defined(ESP32)
|
||||
#include <WiFi.h>
|
||||
#else
|
||||
#include <ESP8266WiFi.h>
|
||||
#endif
|
||||
#include "AudioFileSourceICYStream.h"
|
||||
#include "AudioFileSourceBuffer.h"
|
||||
#include "AudioGeneratorMP3.h"
|
||||
#if AUDIO
|
||||
// #pragma message("Outputting audio")
|
||||
#include "AudioOutputLinuxDSP.h"
|
||||
#else
|
||||
// #pragma message("No audio")
|
||||
#include "AudioOutputNullSlow.h"
|
||||
#endif
|
||||
|
||||
// To run, set your ESP8266 build to 160MHz, update the SSID info, and upload.
|
||||
|
||||
// Enter your WiFi setup here:
|
||||
#ifndef STASSID
|
||||
#define STASSID "your-ssid"
|
||||
#define STAPSK "your-password"
|
||||
#endif
|
||||
|
||||
const char* ssid = STASSID;
|
||||
const char* password = STAPSK;
|
||||
|
||||
// Randomly picked URL
|
||||
//const char *URL="http://kvbstreams.dyndns.org:8000/wkvi-am";
|
||||
//const char *URL="http://stream2.pvpjamz.com:8706/stream";
|
||||
// that one is not well decoded:
|
||||
const char *URL="http://icecast.radiofrance.fr/franceinter-lofi.mp3";
|
||||
|
||||
AudioGeneratorMP3 *mp3;
|
||||
AudioFileSourceICYStream *file;
|
||||
AudioFileSourceBuffer *buff;
|
||||
AudioOutputNullSlow *out;
|
||||
|
||||
// Called when a metadata event occurs (i.e. an ID3 tag, an ICY block, etc.
|
||||
void MDCallback(void *cbData, const char *type, bool isUnicode, const char *string)
|
||||
{
|
||||
const char *ptr = reinterpret_cast<const char *>(cbData);
|
||||
(void) isUnicode; // Punt this ball for now
|
||||
// Note that the type and string may be in PROGMEM, so copy them to RAM for printf
|
||||
char s1[32], s2[64];
|
||||
strncpy_P(s1, type, sizeof(s1));
|
||||
s1[sizeof(s1)-1]=0;
|
||||
strncpy_P(s2, string, sizeof(s2));
|
||||
s2[sizeof(s2)-1]=0;
|
||||
Serial.printf("METADATA(%s) '%s' = '%s'\n", ptr, s1, s2);
|
||||
Serial.flush();
|
||||
}
|
||||
|
||||
// Called when there's a warning or error (like a buffer underflow or decode hiccup)
|
||||
void StatusCallback(void *cbData, int code, const char *string)
|
||||
{
|
||||
const char *ptr = reinterpret_cast<const char *>(cbData);
|
||||
// Note that the string may be in PROGMEM, so copy it to RAM for printf
|
||||
char s1[64];
|
||||
strncpy_P(s1, string, sizeof(s1));
|
||||
s1[sizeof(s1)-1]=0;
|
||||
Serial.printf("STATUS(%s) '%d' = '%s'\n", ptr, code, s1);
|
||||
Serial.flush();
|
||||
}
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
delay(1000);
|
||||
Serial.println("Connecting to WiFi");
|
||||
|
||||
WiFi.disconnect();
|
||||
WiFi.softAPdisconnect(true);
|
||||
WiFi.mode(WIFI_STA);
|
||||
|
||||
WiFi.begin(ssid, password);
|
||||
|
||||
// Try forever
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
Serial.println("...Connecting to WiFi");
|
||||
delay(1000);
|
||||
}
|
||||
Serial.println("Connected");
|
||||
|
||||
audioLogger = &Serial;
|
||||
file = new AudioFileSourceICYStream();
|
||||
file->RegisterMetadataCB(MDCallback, (void*)"ICY");
|
||||
file->useHTTP10();
|
||||
file->open(URL);
|
||||
buff = new AudioFileSourceBuffer(file, 2048);
|
||||
buff->RegisterStatusCB(StatusCallback, (void*)"buffer");
|
||||
out = new AudioOutputNullSlow();
|
||||
mp3 = new AudioGeneratorMP3();
|
||||
mp3->RegisterStatusCB(StatusCallback, (void*)"mp3");
|
||||
mp3->begin(buff, out);
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
static int lastms = 0;
|
||||
|
||||
if (mp3->isRunning()) {
|
||||
if (millis()-lastms > 1000) {
|
||||
lastms = millis();
|
||||
Serial.printf("Running for %d ms...\n", lastms);
|
||||
Serial.flush();
|
||||
}
|
||||
if (!mp3->loop()) mp3->stop();
|
||||
} else {
|
||||
Serial.printf("MP3 done\n");
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Executable
+66
@@ -0,0 +1,66 @@
|
||||
#!/bin/bash
|
||||
|
||||
ino=${PWD##*/}
|
||||
|
||||
if [ ! -d "${ESP8266ARDUINO}/tests/host" ]; then
|
||||
echo "\${ESP8266ARDUINO} should point to ESP8266 Arduino core directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
THISLIB=$(pwd)/../..
|
||||
MAD=$(ls ${THISLIB}/src/libmad/*.c)
|
||||
PAGER=${PAGER:-less}
|
||||
|
||||
cd ${ESP8266ARDUINO}/tests/host
|
||||
|
||||
if [ "$1" = "clean" ]; then
|
||||
make clean
|
||||
cd ${THISLIB}
|
||||
rm -f src/*.o src/libmad/*.o
|
||||
exit 0
|
||||
elif [ "$1" = diff ]; then
|
||||
cd ${THISLIB}/examples
|
||||
diff -u StreamMP3FromHTTP/StreamMP3FromHTTP.ino ${ino}/${ino}.ino | ${PAGER}
|
||||
exit 0
|
||||
else
|
||||
echo ""
|
||||
echo "usage:"
|
||||
echo " $0"
|
||||
echo " $0 clean"
|
||||
echo " $0 diff"
|
||||
echo " AUDIO=a VALGRIND=v FORCE32=f $0"
|
||||
echo " a=1 play sound (use padsp, open /dev/dsp)"
|
||||
echo " v=1 run in native mode (FORCE32=0) with valgrind"
|
||||
echo " f=1 run in 32 bits mode (if gcc-multilib is installed)"
|
||||
echo "variable ESP8266ARDUINO must point to esp8266 Arduino core directory"
|
||||
echo ""
|
||||
[ "$1" = "-h" ] && exit 0
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
run=""
|
||||
|
||||
[ -z "${FORCE32}" ] && FORCE32=0
|
||||
[ -z "${AUDIO}" ] && AUDIO=1
|
||||
|
||||
if [ "${AUDIO}" = 1 ]; then
|
||||
run="${run} padsp"
|
||||
fi
|
||||
|
||||
if [ "${VALGRIND}" = 1 ]; then
|
||||
FORCE32=0
|
||||
run="$run valgrind"
|
||||
fi
|
||||
|
||||
touch ${THISLIB}/examples/${ino}/${ino}.ino # rebuild
|
||||
|
||||
eval make FORCE32=${FORCE32} -j \
|
||||
USERCSOURCES=\"${MAD}\" \
|
||||
USERCXXSOURCES=\"${THISLIB}/src/AudioFileSourceBuffer.cpp ${THISLIB}/src/AudioLogger.cpp ${THISLIB}/src/AudioGeneratorMP3.cpp ${THISLIB}/src/AudioFileSourceICYStream.cpp ${THISLIB}/src/AudioFileSourceHTTPStream.cpp\" \
|
||||
USERCFLAGS=\"-I${THISLIB}/src/ -DAUDIO=${AUDIO}\" \
|
||||
${THISLIB}/examples/${ino}/${ino}
|
||||
|
||||
set -x
|
||||
|
||||
$run ./bin/${ino}/${ino} "$@"
|
||||
stty sane
|
||||
@@ -2,7 +2,14 @@
|
||||
// https://github.com/going-digital/Talkie/blob/master/Talkie/examples/Vocab_US_Clock/Vocab_US_Clock.ino
|
||||
// Released under GPL v2
|
||||
|
||||
#ifdef ESP32
|
||||
#include <Arduino.h>
|
||||
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
void setup() {}
|
||||
void loop() {}
|
||||
#else
|
||||
|
||||
#if defined(ESP32)
|
||||
#include <WiFi.h>
|
||||
#else
|
||||
#include <ESP8266WiFi.h>
|
||||
@@ -183,3 +190,4 @@ void loop()
|
||||
sayTime(tmstruct.tm_hour, tmstruct.tm_min, talkie);
|
||||
delay(1000);
|
||||
}
|
||||
#endif
|
||||
@@ -19,7 +19,15 @@
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#ifdef ESP32
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
void setup() {}
|
||||
void loop() {}
|
||||
#else
|
||||
|
||||
// ESP8266 server.available() is now server.accept()
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
|
||||
#if defined(ESP32)
|
||||
#include <WiFi.h>
|
||||
#else
|
||||
#include <ESP8266WiFi.h>
|
||||
@@ -439,3 +447,4 @@ void loop()
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -19,6 +19,9 @@
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
// Nothing here
|
||||
#else
|
||||
#ifdef ESP32
|
||||
#include <WiFi.h>
|
||||
#else
|
||||
@@ -308,7 +311,4 @@ void Read4Int(char *str, byte *p)
|
||||
str += ParseInt(str, &i); p[2] = i; if (*str) str++;
|
||||
str += ParseInt(str, &i); p[3] = i;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -15,12 +15,15 @@ AudioGeneratorFLAC KEYWORD1
|
||||
AudioGeneratorMOD KEYWORD1
|
||||
AudioGeneratorMIDI KEYWORD1
|
||||
AudioGeneratorMP3 KEYWORD1
|
||||
AudioGeneratorOpus KEYWORD1
|
||||
AudioGeneratorRTTTL KEYWORD1
|
||||
AudioGeneratorTalkie KEYWORD1
|
||||
AudioGeneratorWAV KEYWORD1
|
||||
AudioOutput KEYWORD1
|
||||
AudioOutputI2S KEYWORD1
|
||||
AudioOutputI2SNoDAC KEYWORD1
|
||||
AudioOutputI2SClass KEYWORD1
|
||||
AudioOutputPWM KEYWORD1
|
||||
AudioOutputNull KEYWORD1
|
||||
AudioOutputBuffer KEYWORD1
|
||||
AudioOutputSerialWAV KEYWORD1
|
||||
|
||||
+8
-8
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ESP8266Audio",
|
||||
"description": "Audio file format and I2S DAC library",
|
||||
"description": "Audio file format and I2S DAC library for ESP8266, ESP32, and Raspberry Pi Pico RP2040",
|
||||
"keywords": "ESP8266, ESP32, MP3, AAC, WAV, MOD, FLAC, RTTTL, MIDI, I2S, DAC, Delta-Sigma, TTS",
|
||||
"authors": [
|
||||
{
|
||||
@@ -12,15 +12,15 @@
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/earlephilhower/ESP8266Audio"
|
||||
"url": "https://github.com/earlephilhower/ESP8266Audio"
|
||||
},
|
||||
"version": "1.5.0",
|
||||
"version": "2.0.0",
|
||||
"homepage": "https://github.com/earlephilhower/ESP8266Audio",
|
||||
"dependencies": {
|
||||
"SPI": "1.0"
|
||||
},
|
||||
"frameworks": "Arduino",
|
||||
"examples": [
|
||||
"examples/*/*.ino"
|
||||
]
|
||||
}
|
||||
],
|
||||
"build": {
|
||||
"libLDFMode": "deep"
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
name=ESP8266Audio
|
||||
version=1.5.0
|
||||
version=2.0.0
|
||||
author=Earle F. Philhower, III
|
||||
maintainer=Earle F. Philhower, III
|
||||
sentence=Audio file and I2S sound playing routines.
|
||||
sentence=Audio file and I2S sound playing routines for ESP8266, ESP32, and Raspberry Pi Pico RP2040
|
||||
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.
|
||||
category=Signal Input/Output
|
||||
url=https://github.com/earlephilhower/ESP8266Audio
|
||||
architectures=esp8266,esp32
|
||||
architectures=esp8266,esp32,rp2040
|
||||
@@ -29,8 +29,8 @@
|
||||
class AudioFileSourceFS : public AudioFileSource
|
||||
{
|
||||
public:
|
||||
AudioFileSourceFS(FS &fs) { filesystem = &fs; }
|
||||
AudioFileSourceFS(FS &fs, const char *filename);
|
||||
AudioFileSourceFS(fs::FS &fs) { filesystem = &fs; }
|
||||
AudioFileSourceFS(fs::FS &fs, const char *filename);
|
||||
virtual ~AudioFileSourceFS() override;
|
||||
|
||||
virtual bool open(const char *filename) override;
|
||||
@@ -42,8 +42,8 @@ class AudioFileSourceFS : public AudioFileSource
|
||||
virtual uint32_t getPos() override { if (!f) return 0; else return f.position(); };
|
||||
|
||||
private:
|
||||
FS *filesystem;
|
||||
File f;
|
||||
fs::FS *filesystem;
|
||||
fs::File f;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
AudioFileSourceFunction
|
||||
Audio output generator which can generate WAV file data from function
|
||||
|
||||
Copyright (C) 2021 Hideaki Tai
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "AudioFileSourceFunction.h"
|
||||
|
||||
AudioFileSourceFunction::AudioFileSourceFunction(float sec, uint16_t channels, uint32_t sample_per_sec, uint16_t bits_per_sample) {
|
||||
uint32_t bytes_per_sec = sample_per_sec * channels * bits_per_sample / 8;
|
||||
uint32_t len = uint32_t(sec * (float)bytes_per_sec);
|
||||
|
||||
// RIFF chunk
|
||||
memcpy(wav_header.riff.chunk_id, "RIFF", 4);
|
||||
wav_header.riff.chunk_size = 4 // size of riff chunk w/o chunk_id and chunk_size
|
||||
+ 8 + 16 // size of format chunk
|
||||
+ 8 + len; // size of data chunk
|
||||
memcpy(wav_header.riff.format, "WAVE", 4);
|
||||
|
||||
// format chunk
|
||||
memcpy(wav_header.format.chunk_id, "fmt ", 4);
|
||||
wav_header.format.chunk_size = 16;
|
||||
wav_header.format.format_tag = 0x0001; // PCM
|
||||
wav_header.format.channels = channels;
|
||||
wav_header.format.sample_per_sec = sample_per_sec;
|
||||
wav_header.format.avg_bytes_per_sec = bytes_per_sec;
|
||||
wav_header.format.block_align = channels * bits_per_sample / 8;
|
||||
wav_header.format.bits_per_sample = bits_per_sample;
|
||||
|
||||
// data chunk
|
||||
memcpy(wav_header.data.chunk_id, "data", 4);
|
||||
wav_header.data.chunk_size = len;
|
||||
|
||||
funcs.reserve(channels);
|
||||
pos = 0;
|
||||
size = sizeof(WavHeader) + len;
|
||||
is_ready = false;
|
||||
is_unique = false;
|
||||
}
|
||||
|
||||
AudioFileSourceFunction::~AudioFileSourceFunction() {
|
||||
close();
|
||||
}
|
||||
|
||||
uint32_t AudioFileSourceFunction::read(void* data, uint32_t len) {
|
||||
// callback size must be 1 or equal to channels
|
||||
if (!is_ready)
|
||||
return 0;
|
||||
|
||||
uint8_t* d = reinterpret_cast<uint8_t*>(data);
|
||||
uint32_t i = 0;
|
||||
while (i < len) {
|
||||
uint32_t p = pos + i;
|
||||
if (p < sizeof(WavHeader)) {
|
||||
// header bytes
|
||||
d[i] = wav_header.bytes[p];
|
||||
i += 1;
|
||||
} else {
|
||||
// data bytes
|
||||
float time = (float)(p - sizeof(WavHeader)) / (float)wav_header.format.avg_bytes_per_sec;
|
||||
float v = funcs[0](time);
|
||||
for (size_t ch = 0; ch < wav_header.format.channels; ++ch) {
|
||||
if (!is_unique && ch > 0)
|
||||
v = funcs[ch](time);
|
||||
|
||||
switch (wav_header.format.bits_per_sample) {
|
||||
case 8: {
|
||||
Uint8AndInt8 vs {int8_t(v * (float)0x7F)};
|
||||
d[i] = vs.u;
|
||||
break;
|
||||
}
|
||||
case 32: {
|
||||
Uint8AndInt32 vs {int32_t(v * (float)0x7FFFFFFF)};
|
||||
d[i + 0] = vs.u[0];
|
||||
d[i + 1] = vs.u[1];
|
||||
d[i + 2] = vs.u[2];
|
||||
d[i + 3] = vs.u[3];
|
||||
break;
|
||||
}
|
||||
case 16:
|
||||
default: {
|
||||
Uint8AndInt16 vs {int16_t(v * (float)0x7FFF)};
|
||||
d[i + 0] = vs.u[0];
|
||||
d[i + 1] = vs.u[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
i += wav_header.format.block_align;
|
||||
}
|
||||
}
|
||||
pos += i;
|
||||
return (pos >= size) ? 0 : i;
|
||||
}
|
||||
|
||||
bool AudioFileSourceFunction::seek(int32_t pos, int dir) {
|
||||
if (dir == SEEK_SET) {
|
||||
if (pos < 0 || (uint32_t)pos >= size)
|
||||
return false;
|
||||
this->pos = pos;
|
||||
} else if (dir == SEEK_CUR) {
|
||||
int32_t p = (int32_t)this->pos + pos;
|
||||
if (p < 0 || (uint32_t)p >= size)
|
||||
return false;
|
||||
this->pos = p;
|
||||
} else {
|
||||
int32_t p = (int32_t)this->size + pos;
|
||||
if (p < 0 || (uint32_t)p >= size)
|
||||
return false;
|
||||
this->pos = p;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AudioFileSourceFunction::close() {
|
||||
funcs.clear();
|
||||
pos = 0;
|
||||
size = 0;
|
||||
is_ready = false;
|
||||
is_unique = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AudioFileSourceFunction::isOpen() {
|
||||
return is_ready;
|
||||
}
|
||||
|
||||
uint32_t AudioFileSourceFunction::getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
uint32_t AudioFileSourceFunction::getPos() {
|
||||
return pos;
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
AudioFileSourceFunction
|
||||
Audio output generator which can generate WAV file data from function
|
||||
|
||||
Copyright (C) 2021 Hideaki Tai
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _AUDIOFILESOURCEFUNCTION_H
|
||||
#define _AUDIOFILESOURCEFUNCTION_H
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
|
||||
#include "AudioFileSource.h"
|
||||
|
||||
class AudioFileSourceFunction : public AudioFileSource {
|
||||
union WavHeader {
|
||||
struct {
|
||||
// RIFF chunk
|
||||
struct {
|
||||
char chunk_id[4]; // "RIFF"
|
||||
uint32_t chunk_size; // 4 + (8 + sizeof(format_chunk)(16)) + (8 + sizeof(data_chunk))
|
||||
char format[4]; // "WAVE"
|
||||
} riff;
|
||||
// format chunk
|
||||
struct {
|
||||
char chunk_id[4]; // "fmt "
|
||||
uint32_t chunk_size; // 16
|
||||
uint16_t format_tag; // 1: PCM
|
||||
uint16_t channels; // 1: MONO, 2: STEREO
|
||||
uint32_t sample_per_sec; // 8000, 11025, 22050, 44100, 48000
|
||||
uint32_t avg_bytes_per_sec; // sample_per_sec * channels * bits_per_sample / 8
|
||||
uint16_t block_align; // channels * bits_per_sample / 8
|
||||
uint16_t bits_per_sample; // 8, 16, 32
|
||||
} format;
|
||||
// data chunk
|
||||
struct {
|
||||
char chunk_id[4]; // "data"
|
||||
uint32_t chunk_size; // num_samples * channels * bytes_per_sample
|
||||
// audio data follows here...
|
||||
} data;
|
||||
};
|
||||
uint8_t bytes[44];
|
||||
} wav_header;
|
||||
|
||||
union Uint8AndInt8 {
|
||||
int8_t i;
|
||||
uint8_t u;
|
||||
};
|
||||
|
||||
union Uint8AndInt16 {
|
||||
int16_t i;
|
||||
uint8_t u[2];
|
||||
};
|
||||
|
||||
union Uint8AndInt32 {
|
||||
int32_t i;
|
||||
uint8_t u[4];
|
||||
};
|
||||
|
||||
using callback_t = std::function<float(float)>;
|
||||
std::vector<callback_t> funcs;
|
||||
uint32_t pos;
|
||||
uint32_t size;
|
||||
bool is_ready;
|
||||
bool is_unique;
|
||||
|
||||
public:
|
||||
AudioFileSourceFunction(float sec, uint16_t channels = 1, uint32_t sample_per_sec = 8000, uint16_t bits_per_sample = 16);
|
||||
virtual ~AudioFileSourceFunction() override;
|
||||
|
||||
template <typename F, typename... Fs>
|
||||
bool addAudioGenerators(const F& f, Fs&&... fs) {
|
||||
funcs.emplace_back(f);
|
||||
return addAudioGenerators(std::forward<Fs>(fs)...);
|
||||
}
|
||||
bool addAudioGenerators() {
|
||||
funcs.shrink_to_fit();
|
||||
if (funcs.size() == 1) {
|
||||
is_ready = true;
|
||||
is_unique = true;
|
||||
return true;
|
||||
} else if (funcs.size() == wav_header.format.channels) {
|
||||
is_ready = true;
|
||||
is_unique = false;
|
||||
return true;
|
||||
} else {
|
||||
is_ready = false;
|
||||
is_unique = false;
|
||||
funcs.clear();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
virtual uint32_t read(void* data, uint32_t len) override;
|
||||
virtual bool seek(int32_t pos, int dir) override;
|
||||
|
||||
virtual bool close() override;
|
||||
virtual bool isOpen() override;
|
||||
|
||||
virtual uint32_t getSize() override;
|
||||
virtual uint32_t getPos() override;
|
||||
};
|
||||
|
||||
#endif // _AUDIOFILESOURCEFUNCTION_H
|
||||
@@ -18,6 +18,8 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if defined(ESP32) || defined(ESP8266)
|
||||
|
||||
#include "AudioFileSourceHTTPStream.h"
|
||||
|
||||
AudioFileSourceHTTPStream::AudioFileSourceHTTPStream()
|
||||
@@ -40,7 +42,7 @@ bool AudioFileSourceHTTPStream::open(const char *url)
|
||||
http.begin(client, url);
|
||||
http.setReuse(true);
|
||||
#ifndef ESP32
|
||||
http.setFollowRedirects(true);
|
||||
http.setFollowRedirects(HTTPC_FORCE_FOLLOW_REDIRECTS);
|
||||
#endif
|
||||
int code = http.GET();
|
||||
if (code != HTTP_CODE_OK) {
|
||||
@@ -84,7 +86,7 @@ retry:
|
||||
cb.st(STATUS_DISCONNECTED, PSTR("Stream disconnected"));
|
||||
http.end();
|
||||
for (int i = 0; i < reconnectTries; i++) {
|
||||
char buff[32];
|
||||
char buff[64];
|
||||
sprintf_P(buff, PSTR("Attempting to reconnect, try %d"), i);
|
||||
cb.st(STATUS_RECONNECTING, buff);
|
||||
delay(reconnectDelayMs);
|
||||
@@ -100,7 +102,11 @@ retry:
|
||||
}
|
||||
if ((size > 0) && (pos >= size)) return 0;
|
||||
|
||||
#if defined(ESP_ARDUINO_VERSION_MAJOR) && ESP_ARDUINO_VERSION_MAJOR >= 3
|
||||
NetworkClient *stream = http.getStreamPtr();
|
||||
#else
|
||||
WiFiClient *stream = http.getStreamPtr();
|
||||
#endif
|
||||
|
||||
// Can't read past EOF...
|
||||
if ( (size > 0) && (len > (uint32_t)(pos - size)) ) len = pos - size;
|
||||
@@ -152,3 +158,5 @@ uint32_t AudioFileSourceHTTPStream::getPos()
|
||||
{
|
||||
return pos;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -18,8 +18,8 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _AUDIOFILESOURCEHTTPSTREAM_H
|
||||
#define _AUDIOFILESOURCEHTTPSTREAM_H
|
||||
#if defined(ESP32) || defined(ESP8266)
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#ifdef ESP32
|
||||
@@ -47,12 +47,17 @@ class AudioFileSourceHTTPStream : public AudioFileSource
|
||||
virtual uint32_t getSize() override;
|
||||
virtual uint32_t getPos() override;
|
||||
bool SetReconnect(int tries, int delayms) { reconnectTries = tries; reconnectDelayMs = delayms; return true; }
|
||||
void useHTTP10 () { http.useHTTP10(true); }
|
||||
|
||||
enum { STATUS_HTTPFAIL=2, STATUS_DISCONNECTED, STATUS_RECONNECTING, STATUS_RECONNECTED, STATUS_NODATA };
|
||||
|
||||
private:
|
||||
virtual uint32_t readInternal(void *data, uint32_t len, bool nonBlock);
|
||||
#if defined(ESP_ARDUINO_VERSION_MAJOR) && ESP_ARDUINO_VERSION_MAJOR >= 3
|
||||
NetworkClient client;
|
||||
#else
|
||||
WiFiClient client;
|
||||
#endif
|
||||
HTTPClient http;
|
||||
int pos;
|
||||
int size;
|
||||
|
||||
@@ -17,6 +17,12 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if defined(ESP32) || defined(ESP8266)
|
||||
|
||||
#ifdef _GNU_SOURCE
|
||||
#undef _GNU_SOURCE
|
||||
#endif
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include "AudioFileSourceICYStream.h"
|
||||
@@ -44,6 +50,7 @@ bool AudioFileSourceICYStream::open(const char *url)
|
||||
http.addHeader("Icy-MetaData", "1");
|
||||
http.collectHeaders( hdr, 4 );
|
||||
http.setReuse(true);
|
||||
http.setFollowRedirects(HTTPC_FORCE_FOLLOW_REDIRECTS);
|
||||
int code = http.GET();
|
||||
if (code != HTTP_CODE_OK) {
|
||||
http.end();
|
||||
@@ -83,12 +90,16 @@ AudioFileSourceICYStream::~AudioFileSourceICYStream()
|
||||
|
||||
uint32_t AudioFileSourceICYStream::readInternal(void *data, uint32_t len, bool nonBlock)
|
||||
{
|
||||
// Ensure we can't possibly read 2 ICY headers in a single go #355
|
||||
if (icyMetaInt > 1) {
|
||||
len = std::min((int)(icyMetaInt >> 1), (int)len);
|
||||
}
|
||||
retry:
|
||||
if (!http.connected()) {
|
||||
cb.st(STATUS_DISCONNECTED, PSTR("Stream disconnected"));
|
||||
http.end();
|
||||
for (int i = 0; i < reconnectTries; i++) {
|
||||
char buff[32];
|
||||
char buff[64];
|
||||
sprintf_P(buff, PSTR("Attempting to reconnect, try %d"), i);
|
||||
cb.st(STATUS_RECONNECTING, buff);
|
||||
delay(reconnectDelayMs);
|
||||
@@ -104,7 +115,11 @@ retry:
|
||||
}
|
||||
if ((size > 0) && (pos >= size)) return 0;
|
||||
|
||||
#if defined(ESP_ARDUINO_VERSION_MAJOR) && ESP_ARDUINO_VERSION_MAJOR >= 3
|
||||
NetworkClient *stream = http.getStreamPtr();
|
||||
#else
|
||||
WiFiClient *stream = http.getStreamPtr();
|
||||
#endif
|
||||
|
||||
// Can't read past EOF...
|
||||
if ( (size > 0) && (len > (uint32_t)(pos - size)) ) len = pos - size;
|
||||
@@ -211,3 +226,5 @@ retry:
|
||||
icyByteCount += ret;
|
||||
return read;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -18,8 +18,8 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _AUDIOFILESOURCEICYSTREAM_H
|
||||
#define _AUDIOFILESOURCEICYSTREAM_H
|
||||
#if defined(ESP32) || defined(ESP8266)
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#ifdef ESP32
|
||||
@@ -45,6 +45,4 @@ class AudioFileSourceICYStream : public AudioFileSourceHTTPStream
|
||||
int icyByteCount;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -143,6 +143,7 @@ uint32_t AudioFileSourceID3::read(void *data, uint32_t len)
|
||||
if (ret<10) return ret;
|
||||
|
||||
if ((buff[0]!='I') || (buff[1]!='D') || (buff[2]!='3') || (buff[3]>0x04) || (buff[3]<0x02) || (buff[4]!=0)) {
|
||||
cb.md("eof", false, "id3");
|
||||
return 10 + src->read(buff+10, len-10);
|
||||
}
|
||||
|
||||
@@ -212,9 +213,9 @@ uint32_t AudioFileSourceID3::read(void *data, uint32_t len)
|
||||
|
||||
// Read the value and send to callback
|
||||
char value[64];
|
||||
uint16_t i;
|
||||
uint32_t i;
|
||||
bool isUnicode = (id3.getByte()==1) ? true : false;
|
||||
for (i=0; i<framesize-1; i++) {
|
||||
for (i=0; i<(uint32_t)framesize-1; i++) {
|
||||
if (i<sizeof(value)-1) value[i] = id3.getByte();
|
||||
else (void)id3.getByte();
|
||||
}
|
||||
@@ -231,10 +232,24 @@ uint32_t AudioFileSourceID3::read(void *data, uint32_t len)
|
||||
} else if ( (frameid[0]=='T' && frameid[1]=='Y' && frameid[2]=='E' && frameid[3] == 'R') ||
|
||||
(frameid[0]=='T' && frameid[1]=='Y' && frameid[2]=='E' && rev==2) ) {
|
||||
cb.md("Year", isUnicode, value);
|
||||
} else if ( (frameid[0]=='T' && frameid[1]=='R' && frameid[2]=='C' && frameid[3] == 'K') ||
|
||||
(frameid[0]=='T' && frameid[1]=='R' && frameid[2]=='K' && rev==2) ) {
|
||||
cb.md("track", isUnicode, value);
|
||||
} else if ( (frameid[0]=='T' && frameid[1]=='P' && frameid[2]=='O' && frameid[3] == 'S') ||
|
||||
(frameid[0]=='T' && frameid[1]=='P' && frameid[2]=='A' && rev==2) ) {
|
||||
cb.md("Set", isUnicode, value);
|
||||
} else if ( (frameid[0]=='P' && frameid[1]=='O' && frameid[2]=='P' && frameid[3] == 'M') ||
|
||||
(frameid[0]=='P' && frameid[1]=='O' && frameid[2]=='P' && rev==2) ) {
|
||||
cb.md("Popularimeter", isUnicode, value);
|
||||
} else if ( (frameid[0]=='T' && frameid[1]=='C' && frameid[2]=='M' && frameid[3] == 'P') ) {
|
||||
cb.md("Compilation", isUnicode, value);
|
||||
}
|
||||
}
|
||||
} while (!id3.eof());
|
||||
|
||||
// use callback function to signal end of tags and beginning of content.
|
||||
cb.md("eof", false, "id3");
|
||||
|
||||
// All ID3 processing done, return to main caller
|
||||
return src->read(data, len);
|
||||
}
|
||||
|
||||
@@ -18,10 +18,8 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _AUDIOFILESOURCESPIFFS_H
|
||||
#define _AUDIOFILESOURCESPIFFS_H
|
||||
|
||||
#ifndef ESP32 // No LittleFS there, yet
|
||||
#ifndef _AUDIOFILESOURCELITTLEFS_H
|
||||
#define _AUDIOFILESOURCELITTLEFS_H
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <LittleFS.h>
|
||||
@@ -39,5 +37,3 @@ class AudioFileSourceLittleFS : public AudioFileSourceFS
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
#include "AudioFileSource.h"
|
||||
#include "AudioFileSourceFS.h"
|
||||
|
||||
// Yes, I know SPIFFS is deprecated
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
|
||||
class AudioFileSourceSPIFFS : public AudioFileSourceFS
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if defined(ESP32) || defined(ESP8266)
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "AudioFileSourceSPIRAMBuffer.h"
|
||||
|
||||
@@ -103,7 +105,7 @@ uint32_t AudioFileSourceSPIRAMBuffer::read(void *data, uint32_t len)
|
||||
}
|
||||
|
||||
// Read up to the entire buffer from RAM
|
||||
uint32_t toReadFromBuffer = std::min(len, writePtr - readPtr);
|
||||
uint32_t toReadFromBuffer = std::min(len, (uint32_t)(writePtr - readPtr));
|
||||
uint8_t *ptr = reinterpret_cast<uint8_t*>(data);
|
||||
if (toReadFromBuffer > 0) {
|
||||
#ifdef FAKERAM
|
||||
@@ -165,3 +167,5 @@ bool AudioFileSourceSPIRAMBuffer::loop()
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -19,8 +19,8 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _AUDIOFILESOURCESPIRAMBUFFER_H
|
||||
#define _AUDIOFILESOURCESPIRAMBUFFER_H
|
||||
#if defined(ESP32) || defined(ESP8266)
|
||||
#pragma once
|
||||
|
||||
#include "AudioFileSource.h"
|
||||
#include <SPI.h>
|
||||
|
||||
@@ -69,7 +69,7 @@ uint32_t AudioFileSourceSTDIO::read(void *data, uint32_t len)
|
||||
|
||||
bool AudioFileSourceSTDIO::seek(int32_t pos, int dir)
|
||||
{
|
||||
return fseek(f, pos, dir);
|
||||
return fseek(f, pos, dir) == 0;
|
||||
}
|
||||
|
||||
bool AudioFileSourceSTDIO::close()
|
||||
|
||||
@@ -35,6 +35,7 @@ class AudioGenerator
|
||||
virtual bool loop() { return false; };
|
||||
virtual bool stop() { return false; };
|
||||
virtual bool isRunning() { return false;};
|
||||
virtual void desync () { };
|
||||
|
||||
public:
|
||||
virtual bool RegisterMetadataCB(AudioStatus::metadataCBFn fn, void *data) { return cb.RegisterMetadataCB(fn, data); }
|
||||
|
||||
@@ -144,8 +144,13 @@ bool AudioGeneratorAAC::loop()
|
||||
|
||||
// If we've got data, try and pump it out...
|
||||
while (validSamples) {
|
||||
lastSample[0] = outSample[curSample*2];
|
||||
lastSample[1] = outSample[curSample*2 + 1];
|
||||
if (lastChannels == 1) {
|
||||
lastSample[0] = outSample[curSample];
|
||||
lastSample[1] = outSample[curSample];
|
||||
} else {
|
||||
lastSample[0] = outSample[curSample*2];
|
||||
lastSample[1] = outSample[curSample*2 + 1];
|
||||
}
|
||||
if (!output->ConsumeSample(lastSample)) goto done; // Can't send, but no error detected
|
||||
validSamples--;
|
||||
curSample++;
|
||||
|
||||
@@ -62,6 +62,9 @@ bool AudioGeneratorFLAC::begin(AudioFileSource *source, AudioOutput *output)
|
||||
|
||||
output->begin();
|
||||
running = true;
|
||||
lastSample[0] = 0;
|
||||
lastSample[1] = 0;
|
||||
channels = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -71,7 +74,7 @@ bool AudioGeneratorFLAC::loop()
|
||||
|
||||
if (!running) goto done;
|
||||
|
||||
if (!output->ConsumeSample(lastSample)) goto done; // Try and send last buffered sample
|
||||
if (channels && !output->ConsumeSample(lastSample)) goto done; // Try and send last buffered sample
|
||||
|
||||
do {
|
||||
if (buffPtr == buffLen) {
|
||||
@@ -96,7 +99,7 @@ bool AudioGeneratorFLAC::loop()
|
||||
|
||||
// Check for some weird case where above didn't give any data
|
||||
if (buffPtr == buffLen) {
|
||||
goto done; // At some point the flac better error and we'll retudn
|
||||
goto done; // At some point the flac better error and we'll return
|
||||
}
|
||||
if (bitsPerSample <= 16) {
|
||||
lastSample[AudioOutput::LEFTCHANNEL] = buff[0][buffPtr] & 0xffff;
|
||||
@@ -177,9 +180,9 @@ FLAC__StreamDecoderWriteStatus AudioGeneratorFLAC::write_cb(const FLAC__StreamDe
|
||||
// Hackish warning here. FLAC sends the buffer but doesn't free it until the next call to decode_frame, so we stash
|
||||
// the pointers here and use it in our loop() instead of memcpy()'ing into yet another buffer.
|
||||
buffLen = frame->header.blocksize;
|
||||
buff[0] = buffer[0];
|
||||
if (frame->header.channels>1) buff[1] = buffer[1];
|
||||
else buff[1] = buffer[0];
|
||||
buff[0] = (const int *)buffer[0];
|
||||
if (frame->header.channels>1) buff[1] = (const int *)buffer[1];
|
||||
else buff[1] = (const int *)buffer[0];
|
||||
buffPtr = 0;
|
||||
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
|
||||
}
|
||||
@@ -193,7 +196,7 @@ char AudioGeneratorFLAC::error_cb_str[64];
|
||||
void AudioGeneratorFLAC::error_cb(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status)
|
||||
{
|
||||
(void) decoder;
|
||||
strncpy_P(error_cb_str, FLAC__StreamDecoderErrorStatusString[status], 64);
|
||||
strncpy_P(error_cb_str, FLAC__StreamDecoderErrorStatusString[status], sizeof(AudioGeneratorFLAC::error_cb_str) - 1);
|
||||
cb.st((int)status, error_cb_str);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
AudioGeneratorMIDI
|
||||
Audio output generator that plays MIDI files using a SF2 SoundFont
|
||||
Audio output generator that plays MIDI files using an SF2 SoundFont
|
||||
|
||||
Copyright (C) 2017 Earle F. Philhower, III
|
||||
|
||||
@@ -58,6 +58,10 @@
|
||||
|
||||
#include "AudioGeneratorMIDI.h"
|
||||
|
||||
#if defined(ESP32) && (__GNUC__ >= 8) && (__XTENSA__)
|
||||
// Do not build, Espressif's GCC8+ has a compiler bug
|
||||
#else // __GNUC__ == 8
|
||||
|
||||
#pragma GCC optimize ("O3")
|
||||
|
||||
#define TSF_NO_STDIO
|
||||
@@ -172,7 +176,7 @@ unsigned int AudioGeneratorMIDI::buffer_int32 (int offset) {
|
||||
|
||||
unsigned long AudioGeneratorMIDI::get_varlen (int *ptr) {
|
||||
/* Get a 1-4 byte variable-length value and adjust the pointer past it.
|
||||
These are a succession of 7-bit values with a MSB bit of zero marking the end */
|
||||
These are a succession of 7-bit values with an MSB bit of zero marking the end */
|
||||
|
||||
unsigned long val;
|
||||
int i, byte;
|
||||
@@ -331,7 +335,7 @@ note_off:
|
||||
}
|
||||
|
||||
|
||||
// Open file, parse headers, get ready tio process MIDI
|
||||
// Open file, parse headers, get ready to process MIDI
|
||||
void AudioGeneratorMIDI::PrepareMIDI(AudioFileSource *src)
|
||||
{
|
||||
MakeStreamFromAFS(src, &afsMIDI);
|
||||
@@ -364,7 +368,7 @@ void AudioGeneratorMIDI::PrepareMIDI(AudioFileSource *src)
|
||||
int AudioGeneratorMIDI::PlayMIDI()
|
||||
{
|
||||
/* Continue processing all tracks, in an order based on the simulated time.
|
||||
This is not unlike multiway merging used for tape sorting algoritms in the 50's! */
|
||||
This is not unlike multiway merging used for tape sorting algorithms in the 50's! */
|
||||
|
||||
do { /* while there are still track notes to process */
|
||||
static struct track_status *trk;
|
||||
@@ -439,8 +443,9 @@ int AudioGeneratorMIDI::PlayMIDI()
|
||||
for (tgnum = 0; tgnum < num_tonegens; ++tgnum) { /* find which generator is playing it */
|
||||
tg = &tonegen[tgnum];
|
||||
if (tg->playing && tg->track == tracknum && tg->note == trk->note) {
|
||||
tsf_note_off (g_tsf, tg->instrument, tg->note);
|
||||
tsf_note_off_fast (g_tsf, tg->instrument, tg->note, tg->playIndex);
|
||||
tg->playing = false;
|
||||
tg->playIndex = -1;
|
||||
trk->tonegens[tgnum] = false;
|
||||
}
|
||||
}
|
||||
@@ -472,7 +477,7 @@ int AudioGeneratorMIDI::PlayMIDI()
|
||||
if (tg->instrument != midi_chan_instrument[trk->chan]) { /* new instrument for this generator */
|
||||
tg->instrument = midi_chan_instrument[trk->chan];
|
||||
}
|
||||
tsf_note_on (g_tsf, tg->instrument, tg->note, trk->velocity / 127.0); // velocity = 0...127
|
||||
tg->playIndex = tsf_note_on_fast (g_tsf, tg->instrument, tg->note, trk->velocity / 127.0); // velocity = 0...127
|
||||
} else {
|
||||
++notes_skipped;
|
||||
}
|
||||
@@ -637,3 +642,5 @@ void AudioGeneratorMIDI::MakeStreamFromAFS(AudioFileSource *src, tsf_stream *afs
|
||||
afs->size = &afs_size;
|
||||
}
|
||||
|
||||
#endif //__GNUC__ == 8
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
#ifndef _AUDIOGENERATORMIDI_H
|
||||
#define _AUDIOGENERATORMIDI_H
|
||||
|
||||
#if defined(ESP32) && (__GNUC__ >= 8) && (__XTENSA__)
|
||||
// Do not build, Espressif's GCC8+ has a compiler bug
|
||||
#else // __GNUC__ == 8
|
||||
|
||||
#include "AudioGenerator.h"
|
||||
|
||||
#define TSF_NO_STDIO
|
||||
@@ -90,10 +94,13 @@ class AudioGeneratorMIDI : public AudioGenerator
|
||||
unsigned long earliest_time = 0;
|
||||
|
||||
struct tonegen_status { /* current status of a tone generator */
|
||||
bool playing; /* is it playing? */
|
||||
bool playing; /* is it playing? */
|
||||
char track; /* if so, which track is the note from? */
|
||||
char note; /* what note is playing? */
|
||||
char instrument; /* what instrument? */
|
||||
int playIndex; /* is index provided?
|
||||
Unique identifier generated when note starts playing.
|
||||
This help us to turn the note off faster */
|
||||
} tonegen[MAX_TONEGENS];
|
||||
|
||||
struct track_status { /* current processing point of a MIDI track */
|
||||
@@ -176,6 +183,7 @@ class AudioGeneratorMIDI : public AudioGenerator
|
||||
short samplesRendered[256];
|
||||
};
|
||||
|
||||
#endif //__GNUC__ == 8
|
||||
|
||||
#endif
|
||||
|
||||
+60
-24
@@ -69,6 +69,11 @@ bool AudioGeneratorMOD::stop()
|
||||
free(FatBuffer.channels[i]);
|
||||
FatBuffer.channels[i] = NULL;
|
||||
}
|
||||
|
||||
if(running || ((file != NULL) && (file->isOpen() == true))) {
|
||||
output->flush(); //flush I2S output buffer, if the player was actually running before.
|
||||
}
|
||||
|
||||
if (file) file->close();
|
||||
running = false;
|
||||
output->stop();
|
||||
@@ -124,7 +129,7 @@ bool AudioGeneratorMOD::begin(AudioFileSource *source, AudioOutput *out)
|
||||
UpdateAmiga();
|
||||
|
||||
for (int i = 0; i < CHANNELS; i++) {
|
||||
FatBuffer.channels[i] = reinterpret_cast<uint8_t*>(malloc(fatBufferSize));
|
||||
FatBuffer.channels[i] = reinterpret_cast<uint8_t*>(calloc(fatBufferSize, 1));
|
||||
if (!FatBuffer.channels[i]) {
|
||||
stop();
|
||||
return false;
|
||||
@@ -232,6 +237,11 @@ bool AudioGeneratorMOD::LoadHeader()
|
||||
Mod.numberOfChannels = (temp[0] - '0') * 10 + temp[1] - '0';
|
||||
else
|
||||
Mod.numberOfChannels = 4;
|
||||
|
||||
if (Mod.numberOfChannels > CHANNELS) {
|
||||
audioLogger->printf("\nAudioGeneratorMOD::LoadHeader abort - too many channels (configured: %d, needed: %d)\n", CHANNELS, Mod.numberOfChannels);
|
||||
return(false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -417,7 +427,7 @@ bool AudioGeneratorMOD::ProcessRow()
|
||||
|
||||
if (sampleNumber) {
|
||||
Player.lastSampleNumber[channel] = sampleNumber - 1;
|
||||
if (!(effectParameter == 0xE && effectParameterX == NOTEDELAY))
|
||||
if (!(effectNumber == 0xE && effectParameterX == NOTEDELAY))
|
||||
Player.volume[channel] = Mod.samples[Player.lastSampleNumber[channel]].volume;
|
||||
}
|
||||
|
||||
@@ -565,7 +575,7 @@ bool AudioGeneratorMOD::ProcessRow()
|
||||
Mixer.channelFrequency[channel] = Player.amiga / Player.lastAmigaPeriod[channel];
|
||||
|
||||
if (note != NONOTE)
|
||||
Mixer.channelSampleOffset[channel] = sampleOffset << DIVIDER;
|
||||
Mixer.channelSampleOffset[channel] = sampleOffset << FIXED_DIVIDER;
|
||||
|
||||
if (sampleNumber)
|
||||
Mixer.channelSampleNumber[channel] = Player.lastSampleNumber[channel];
|
||||
@@ -735,13 +745,14 @@ bool AudioGeneratorMOD::RunPlayer()
|
||||
|
||||
void AudioGeneratorMOD::GetSample(int16_t sample[2])
|
||||
{
|
||||
int16_t sumL;
|
||||
int16_t sumR;
|
||||
int32_t sumL;
|
||||
int32_t sumR;
|
||||
uint8_t channel;
|
||||
uint32_t samplePointer;
|
||||
int8_t current;
|
||||
int8_t next;
|
||||
int16_t out;
|
||||
int32_t out32;
|
||||
|
||||
if (!running) return;
|
||||
|
||||
@@ -757,12 +768,12 @@ void AudioGeneratorMOD::GetSample(int16_t sample[2])
|
||||
if (!Mixer.channelVolume[channel]) continue;
|
||||
|
||||
samplePointer = Mixer.sampleBegin[Mixer.channelSampleNumber[channel]] +
|
||||
(Mixer.channelSampleOffset[channel] >> DIVIDER);
|
||||
(Mixer.channelSampleOffset[channel] >> FIXED_DIVIDER);
|
||||
|
||||
if (Mixer.sampleLoopLength[Mixer.channelSampleNumber[channel]]) {
|
||||
|
||||
if (samplePointer >= Mixer.sampleLoopEnd[Mixer.channelSampleNumber[channel]]) {
|
||||
Mixer.channelSampleOffset[channel] -= Mixer.sampleLoopLength[Mixer.channelSampleNumber[channel]] << DIVIDER;
|
||||
Mixer.channelSampleOffset[channel] -= Mixer.sampleLoopLength[Mixer.channelSampleNumber[channel]] << FIXED_DIVIDER;
|
||||
samplePointer -= Mixer.sampleLoopLength[Mixer.channelSampleNumber[channel]];
|
||||
}
|
||||
|
||||
@@ -779,8 +790,8 @@ void AudioGeneratorMOD::GetSample(int16_t sample[2])
|
||||
samplePointer >= FatBuffer.samplePointer[channel] + fatBufferSize - 1 ||
|
||||
Mixer.channelSampleNumber[channel] != FatBuffer.channelSampleNumber[channel]) {
|
||||
|
||||
uint16_t toRead = Mixer.sampleEnd[Mixer.channelSampleNumber[channel]] - samplePointer + 1;
|
||||
if (toRead > fatBufferSize) toRead = fatBufferSize;
|
||||
uint32_t toRead = Mixer.sampleEnd[Mixer.channelSampleNumber[channel]] - samplePointer + 1;
|
||||
if (toRead > (uint32_t)fatBufferSize) toRead = fatBufferSize;
|
||||
|
||||
if (!file->seek(samplePointer, SEEK_SET)) {
|
||||
stop();
|
||||
@@ -797,30 +808,55 @@ void AudioGeneratorMOD::GetSample(int16_t sample[2])
|
||||
|
||||
current = FatBuffer.channels[channel][(samplePointer - FatBuffer.samplePointer[channel]) /*& (FATBUFFERSIZE - 1)*/];
|
||||
next = FatBuffer.channels[channel][(samplePointer + 1 - FatBuffer.samplePointer[channel]) /*& (FATBUFFERSIZE - 1)*/];
|
||||
|
||||
// preserve a few more bits from sample interpolation, by upscaling input values.
|
||||
// This does (slightly) reduce quantization noise in higher frequencies, typically above 8kHz.
|
||||
// Actually we could could even gain more bits, I was just not sure if more bits would cause overflows in other conputations.
|
||||
int16_t current16 = (int16_t) current << 2;
|
||||
int16_t next16 = (int16_t) next << 2;
|
||||
|
||||
out = current16;
|
||||
|
||||
out = current;
|
||||
// Integer linear interpolation - only works correctly in 16bit
|
||||
out += (next16 - current16) * (Mixer.channelSampleOffset[channel] & ((1 << FIXED_DIVIDER) - 1)) >> FIXED_DIVIDER;
|
||||
|
||||
// Integer linear interpolation
|
||||
out += (next - current) * (Mixer.channelSampleOffset[channel] & ((1 << DIVIDER) - 1)) >> DIVIDER;
|
||||
|
||||
// Upscale to BITDEPTH
|
||||
out <<= BITDEPTH - 8;
|
||||
// Upscale to BITDEPTH, considering the we already gained two bits in the previous step
|
||||
out32 = (int32_t)out << (BITDEPTH - 10);
|
||||
|
||||
// Channel volume
|
||||
out = out * Mixer.channelVolume[channel] >> 6;
|
||||
out32 = out32 * Mixer.channelVolume[channel] >> 6;
|
||||
|
||||
// Channel panning
|
||||
sumL += out * min(128 - Mixer.channelPanning[channel], 64) >> 6;
|
||||
sumR += out * min(Mixer.channelPanning[channel], 64) >> 6;
|
||||
sumL += out32 * min(128 - Mixer.channelPanning[channel], 64) >> 6;
|
||||
sumR += out32 * min(Mixer.channelPanning[channel], 64) >> 6;
|
||||
}
|
||||
|
||||
// Downscale to BITDEPTH
|
||||
sumL /= Mod.numberOfChannels;
|
||||
sumR /= Mod.numberOfChannels;
|
||||
// Downscale to BITDEPTH - a bit faster because the compiler can replaced division by constants with proper "right shift" + correct handling of sign bit
|
||||
if (Mod.numberOfChannels <= 4) {
|
||||
// up to 4 channels
|
||||
sumL /= 4;
|
||||
sumR /= 4;
|
||||
} else {
|
||||
if (Mod.numberOfChannels <= 6) {
|
||||
// 5 or 6 channels - pre-multiply be 1.5, then divide by 8 -> same as division by 6
|
||||
sumL = (sumL + (sumL/2)) / 8;
|
||||
sumR = (sumR + (sumR/2)) / 8;
|
||||
} else {
|
||||
// 7,8, or more channels
|
||||
sumL /= 8;
|
||||
sumR /= 8;
|
||||
}
|
||||
}
|
||||
|
||||
// Fill the sound buffer with unsigned values
|
||||
sample[AudioOutput::LEFTCHANNEL] = sumL + (1 << (BITDEPTH - 1));
|
||||
sample[AudioOutput::RIGHTCHANNEL] = sumR + (1 << (BITDEPTH - 1));
|
||||
// clip samples to 16bit (with saturation in case of overflow)
|
||||
if(sumL <= INT16_MIN) sumL = INT16_MIN;
|
||||
else if (sumL >= INT16_MAX) sumL = INT16_MAX;
|
||||
if(sumR <= INT16_MIN) sumR = INT16_MIN;
|
||||
else if (sumR >= INT16_MAX) sumR = INT16_MAX;
|
||||
|
||||
// Fill the sound buffer with signed values
|
||||
sample[AudioOutput::LEFTCHANNEL] = sumL;
|
||||
sample[AudioOutput::RIGHTCHANNEL] = sumR;
|
||||
}
|
||||
|
||||
bool AudioGeneratorMOD::LoadMOD()
|
||||
|
||||
+10
-4
@@ -53,19 +53,25 @@ class AudioGeneratorMOD : public AudioGenerator
|
||||
|
||||
protected:
|
||||
int mixerTick;
|
||||
enum {BITDEPTH = 15};
|
||||
enum {BITDEPTH = 16};
|
||||
int sampleRate;
|
||||
int fatBufferSize; //(6*1024) // File system buffers per-CHANNEL (i.e. total mem required is 4 * FATBUFFERSIZE)
|
||||
enum {DIVIDER = 10}; // Fixed-point mantissa used for integer arithmetic
|
||||
enum {FIXED_DIVIDER = 10}; // Fixed-point mantissa used for integer arithmetic
|
||||
int stereoSeparation; //STEREOSEPARATION = 32; // 0 (max) to 64 (mono)
|
||||
bool usePAL;
|
||||
|
||||
// Hz = 7093789 / (amigaPeriod * 2) for PAL
|
||||
// Hz = 7159091 / (amigaPeriod * 2) for NTSC
|
||||
int AMIGA;
|
||||
void UpdateAmiga() { AMIGA = ((usePAL?7159091:7093789) / 2 / sampleRate << DIVIDER); }
|
||||
|
||||
void UpdateAmiga() { AMIGA = ((usePAL?7159091:7093789) / 2 / sampleRate << FIXED_DIVIDER); }
|
||||
|
||||
#ifdef ESP8266 // Not sure if C3/C2 have RAM constraints, maybe add them here?
|
||||
// support max 4 channels
|
||||
enum {ROWS = 64, SAMPLES = 31, CHANNELS = 4, NONOTE = 0xFFFF, NONOTE8 = 0xff };
|
||||
#else
|
||||
// support max 8 channels
|
||||
enum {ROWS = 64, SAMPLES = 31, CHANNELS = 8, NONOTE = 0xFFFF, NONOTE8 = 0xff };
|
||||
#endif
|
||||
|
||||
typedef struct Sample {
|
||||
uint16_t length;
|
||||
|
||||
+96
-19
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
AudioGeneratorMP3
|
||||
Wrap libmad MP3 library to play audio
|
||||
|
||||
|
||||
Copyright (C) 2017 Earle F. Philhower, III
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
@@ -27,22 +27,41 @@ AudioGeneratorMP3::AudioGeneratorMP3()
|
||||
file = NULL;
|
||||
output = NULL;
|
||||
buff = NULL;
|
||||
synth = NULL;
|
||||
frame = NULL;
|
||||
stream = NULL;
|
||||
nsCountMax = 1152/32;
|
||||
madInitted = false;
|
||||
preallocateSpace = NULL;
|
||||
preallocateSize = 0;
|
||||
}
|
||||
|
||||
AudioGeneratorMP3::AudioGeneratorMP3(void *space, int size)
|
||||
AudioGeneratorMP3::AudioGeneratorMP3(void *space, int size): preallocateSpace(space), preallocateSize(size)
|
||||
{
|
||||
running = false;
|
||||
file = NULL;
|
||||
output = NULL;
|
||||
buff = NULL;
|
||||
synth = NULL;
|
||||
frame = NULL;
|
||||
stream = NULL;
|
||||
nsCountMax = 1152/32;
|
||||
madInitted = false;
|
||||
}
|
||||
|
||||
AudioGeneratorMP3::AudioGeneratorMP3(void *buff, int buffSize, void *stream, int streamSize, void *frame, int frameSize, void *synth, int synthSize):
|
||||
preallocateSpace(buff), preallocateSize(buffSize),
|
||||
preallocateStreamSpace(stream), preallocateStreamSize(streamSize),
|
||||
preallocateFrameSpace(frame), preallocateFrameSize(frameSize),
|
||||
preallocateSynthSpace(synth), preallocateSynthSize(synthSize)
|
||||
{
|
||||
running = false;
|
||||
file = NULL;
|
||||
output = NULL;
|
||||
buff = NULL;
|
||||
synth = NULL;
|
||||
frame = NULL;
|
||||
stream = NULL;
|
||||
nsCountMax = 1152/32;
|
||||
madInitted = false;
|
||||
preallocateSpace = space;
|
||||
preallocateSize = size;
|
||||
}
|
||||
|
||||
AudioGeneratorMP3::~AudioGeneratorMP3()
|
||||
@@ -52,7 +71,7 @@ AudioGeneratorMP3::~AudioGeneratorMP3()
|
||||
free(synth);
|
||||
free(frame);
|
||||
free(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -109,7 +128,12 @@ enum mad_flow AudioGeneratorMP3::Input()
|
||||
|
||||
if (stream->next_frame) {
|
||||
unused = lastBuffLen - (stream->next_frame - buff);
|
||||
memmove(buff, stream->next_frame, unused);
|
||||
if (unused < 0) {
|
||||
desync();
|
||||
unused = 0;
|
||||
} else {
|
||||
memmove(buff, stream->next_frame, unused);
|
||||
}
|
||||
stream->next_frame = NULL;
|
||||
}
|
||||
|
||||
@@ -125,6 +149,10 @@ enum mad_flow AudioGeneratorMP3::Input()
|
||||
// Can't read any from the file, and we don't have anything left. It's done....
|
||||
return MAD_FLOW_STOP;
|
||||
}
|
||||
if (len < 0) {
|
||||
desync();
|
||||
unused = 0;
|
||||
}
|
||||
|
||||
lastBuffLen = len + unused;
|
||||
mad_stream_buffer(stream, buff, lastBuffLen);
|
||||
@@ -132,6 +160,16 @@ enum mad_flow AudioGeneratorMP3::Input()
|
||||
return MAD_FLOW_CONTINUE;
|
||||
}
|
||||
|
||||
void AudioGeneratorMP3::desync ()
|
||||
{
|
||||
audioLogger->printf_P(PSTR("MP3:desync\n"));
|
||||
if (stream) {
|
||||
stream->next_frame = nullptr;
|
||||
stream->this_frame = nullptr;
|
||||
stream->sync = 0;
|
||||
}
|
||||
lastBuffLen = 0;
|
||||
}
|
||||
|
||||
bool AudioGeneratorMP3::DecodeNextFrame()
|
||||
{
|
||||
@@ -153,7 +191,7 @@ bool AudioGeneratorMP3::GetOneSample(int16_t sample[2])
|
||||
output->SetChannels(synth->pcm.channels);
|
||||
lastChannels = synth->pcm.channels;
|
||||
}
|
||||
|
||||
|
||||
// If we're here, we have one decoded frame and sent 0 or more samples out
|
||||
if (samplePtr < synth->pcm.length) {
|
||||
sample[AudioOutput::LEFTCHANNEL ] = synth->pcm.samples[0][samplePtr];
|
||||
@@ -161,7 +199,7 @@ bool AudioGeneratorMP3::GetOneSample(int16_t sample[2])
|
||||
samplePtr++;
|
||||
} else {
|
||||
samplePtr = 0;
|
||||
|
||||
|
||||
switch ( mad_synth_frame_onens(synth, frame, nsCount++) ) {
|
||||
case MAD_FLOW_STOP:
|
||||
case MAD_FLOW_BREAK: audioLogger->printf_P(PSTR("msf1ns failed\n"));
|
||||
@@ -196,6 +234,18 @@ retry:
|
||||
}
|
||||
|
||||
if (!DecodeNextFrame()) {
|
||||
if (stream->error == MAD_ERROR_BUFLEN) {
|
||||
// randomly seeking can lead to endless
|
||||
// and unrecoverable "MAD_ERROR_BUFLEN" loop
|
||||
audioLogger->printf_P(PSTR("MP3:ERROR_BUFLEN %d\n"), unrecoverable);
|
||||
if (++unrecoverable >= 3) {
|
||||
unrecoverable = 0;
|
||||
stop();
|
||||
return running;
|
||||
}
|
||||
} else {
|
||||
unrecoverable = 0;
|
||||
}
|
||||
goto retry;
|
||||
}
|
||||
samplePtr = 9999;
|
||||
@@ -207,6 +257,10 @@ retry:
|
||||
running = false;
|
||||
goto done;
|
||||
}
|
||||
if (lastChannels == 1)
|
||||
{
|
||||
lastSample[1] = lastSample[0];
|
||||
}
|
||||
} while (running && output->ConsumeSample(lastSample));
|
||||
|
||||
done:
|
||||
@@ -229,6 +283,9 @@ bool AudioGeneratorMP3::begin(AudioFileSource *source, AudioOutput *output)
|
||||
return false; // Error
|
||||
}
|
||||
|
||||
// Reset error count from previous file
|
||||
unrecoverable = 0;
|
||||
|
||||
output->SetBitsPerSample(16); // Constant for MP3 decoder
|
||||
output->SetChannels(2);
|
||||
|
||||
@@ -243,18 +300,36 @@ bool AudioGeneratorMP3::begin(AudioFileSource *source, AudioOutput *output)
|
||||
lastBuffLen = 0;
|
||||
|
||||
// Allocate all large memory chunks
|
||||
if (preallocateSpace) {
|
||||
if (preallocateStreamSize + preallocateFrameSize + preallocateSynthSize) {
|
||||
if (preallocateSize >= preAllocBuffSize() &&
|
||||
preallocateStreamSize >= preAllocStreamSize() &&
|
||||
preallocateFrameSize >= preAllocFrameSize() &&
|
||||
preallocateSynthSize >= preAllocSynthSize()) {
|
||||
buff = reinterpret_cast<unsigned char *>(preallocateSpace);
|
||||
stream = reinterpret_cast<struct mad_stream *>(preallocateStreamSpace);
|
||||
frame = reinterpret_cast<struct mad_frame *>(preallocateFrameSpace);
|
||||
synth = reinterpret_cast<struct mad_synth *>(preallocateSynthSpace);
|
||||
}
|
||||
else {
|
||||
output->stop();
|
||||
audioLogger->printf_P("OOM error in MP3: Want %d/%d/%d/%d bytes, have %d/%d/%d/%d bytes preallocated.\n",
|
||||
preAllocBuffSize(), preAllocStreamSize(), preAllocFrameSize(), preAllocSynthSize(),
|
||||
preallocateSize, preallocateStreamSize, preallocateFrameSize, preallocateSynthSize);
|
||||
return false;
|
||||
}
|
||||
} else if (preallocateSpace) {
|
||||
uint8_t *p = reinterpret_cast<uint8_t *>(preallocateSpace);
|
||||
buff = reinterpret_cast<unsigned char *>(p);
|
||||
p += (buffLen+7) & ~7;
|
||||
p += preAllocBuffSize();
|
||||
stream = reinterpret_cast<struct mad_stream *>(p);
|
||||
p += (sizeof(struct mad_stream)+7) & ~7;
|
||||
p += preAllocStreamSize();
|
||||
frame = reinterpret_cast<struct mad_frame *>(p);
|
||||
p += (sizeof(struct mad_frame)+7) & ~7;
|
||||
p += preAllocFrameSize();
|
||||
synth = reinterpret_cast<struct mad_synth *>(p);
|
||||
p += (sizeof(struct mad_synth)+7) & ~7;
|
||||
p += preAllocSynthSize();
|
||||
int neededBytes = p - reinterpret_cast<uint8_t *>(preallocateSpace);
|
||||
if (neededBytes > preallocateSize) {
|
||||
output->stop();
|
||||
audioLogger->printf_P("OOM error in MP3: Want %d bytes, have %d bytes preallocated.\n", neededBytes, preallocateSize);
|
||||
return false;
|
||||
}
|
||||
@@ -272,17 +347,20 @@ bool AudioGeneratorMP3::begin(AudioFileSource *source, AudioOutput *output)
|
||||
stream = NULL;
|
||||
frame = NULL;
|
||||
synth = NULL;
|
||||
|
||||
output->stop();
|
||||
audioLogger->printf_P("OOM error in MP3\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mad_stream_init(stream);
|
||||
mad_frame_init(frame);
|
||||
mad_synth_init(synth);
|
||||
synth->pcm.length = 0;
|
||||
mad_stream_options(stream, 0); // TODO - add options support
|
||||
madInitted = true;
|
||||
|
||||
|
||||
running = true;
|
||||
return true;
|
||||
}
|
||||
@@ -302,7 +380,7 @@ extern "C" {
|
||||
{
|
||||
return 8192;
|
||||
}
|
||||
#elif defined(ESP8266)
|
||||
#elif defined(ESP8266) && !defined(CORE_MOCK)
|
||||
#include <cont.h>
|
||||
extern cont_t g_cont;
|
||||
|
||||
@@ -349,4 +427,3 @@ extern "C" {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
+21
-5
@@ -30,17 +30,31 @@ class AudioGeneratorMP3 : public AudioGenerator
|
||||
public:
|
||||
AudioGeneratorMP3();
|
||||
AudioGeneratorMP3(void *preallocateSpace, int preallocateSize);
|
||||
AudioGeneratorMP3(void *buff, int buffSize, void *stream, int streamSize, void *frame, int frameSize, void *synth, int synthSize);
|
||||
virtual ~AudioGeneratorMP3() override;
|
||||
virtual bool begin(AudioFileSource *source, AudioOutput *output) override;
|
||||
virtual bool loop() override;
|
||||
virtual bool stop() override;
|
||||
virtual bool isRunning() override;
|
||||
|
||||
protected:
|
||||
void *preallocateSpace;
|
||||
int preallocateSize;
|
||||
virtual void desync () override;
|
||||
|
||||
const int buffLen = 0x600; // Slightly larger than largest MP3 frame
|
||||
static constexpr int preAllocSize () { return preAllocBuffSize() + preAllocStreamSize() + preAllocFrameSize() + preAllocSynthSize(); }
|
||||
static constexpr int preAllocBuffSize () { return ((buffLen + 7) & ~7); }
|
||||
static constexpr int preAllocStreamSize () { return ((sizeof(struct mad_stream) + 7) & ~7); }
|
||||
static constexpr int preAllocFrameSize () { return (sizeof(struct mad_frame) + 7) & ~7; }
|
||||
static constexpr int preAllocSynthSize () { return (sizeof(struct mad_synth) + 7) & ~7; }
|
||||
|
||||
protected:
|
||||
void *preallocateSpace = nullptr;
|
||||
int preallocateSize = 0;
|
||||
void *preallocateStreamSpace = nullptr;
|
||||
int preallocateStreamSize = 0;
|
||||
void *preallocateFrameSpace = nullptr;
|
||||
int preallocateFrameSize = 0;
|
||||
void *preallocateSynthSpace = nullptr;
|
||||
int preallocateSynthSize = 0;
|
||||
|
||||
static constexpr int buffLen = 0x600; // Slightly larger than largest MP3 frame
|
||||
unsigned char *buff;
|
||||
int lastReadPos;
|
||||
int lastBuffLen;
|
||||
@@ -62,6 +76,8 @@ class AudioGeneratorMP3 : public AudioGenerator
|
||||
bool DecodeNextFrame();
|
||||
bool GetOneSample(int16_t sample[2]);
|
||||
|
||||
private:
|
||||
int unrecoverable = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
AudioGeneratorOpus
|
||||
Audio output generator that plays Opus audio files
|
||||
|
||||
Copyright (C) 2020 Earle F. Philhower, III
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <AudioGeneratorOpus.h>
|
||||
|
||||
AudioGeneratorOpus::AudioGeneratorOpus()
|
||||
{
|
||||
of = nullptr;
|
||||
buff = nullptr;
|
||||
buffPtr = 0;
|
||||
buffLen = 0;
|
||||
running = false;
|
||||
}
|
||||
|
||||
AudioGeneratorOpus::~AudioGeneratorOpus()
|
||||
{
|
||||
if (of) op_free(of);
|
||||
of = nullptr;
|
||||
free(buff);
|
||||
buff = nullptr;
|
||||
}
|
||||
|
||||
#define OPUS_BUFF 1024
|
||||
|
||||
bool AudioGeneratorOpus::begin(AudioFileSource *source, AudioOutput *output)
|
||||
{
|
||||
buff = (int16_t*)malloc(OPUS_BUFF * sizeof(int16_t));
|
||||
if (!buff) return false;
|
||||
|
||||
if (!source) return false;
|
||||
file = source;
|
||||
if (!output) return false;
|
||||
this->output = output;
|
||||
if (!file->isOpen()) return false; // Error
|
||||
|
||||
of = op_open_callbacks((void*)this, &cb, nullptr, 0, nullptr);
|
||||
if (!of) return false;
|
||||
|
||||
prev_li = -1;
|
||||
lastSample[0] = 0;
|
||||
lastSample[1] = 0;
|
||||
|
||||
buffPtr = 0;
|
||||
buffLen = 0;
|
||||
|
||||
output->begin();
|
||||
|
||||
// These are fixed by Opus
|
||||
output->SetRate(48000);
|
||||
output->SetBitsPerSample(16);
|
||||
output->SetChannels(2);
|
||||
|
||||
running = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AudioGeneratorOpus::loop()
|
||||
{
|
||||
|
||||
if (!running) goto done;
|
||||
|
||||
if (!output->ConsumeSample(lastSample)) goto done; // Try and send last buffered sample
|
||||
|
||||
do {
|
||||
if (buffPtr == buffLen) {
|
||||
int ret = op_read_stereo(of, (opus_int16 *)buff, OPUS_BUFF);
|
||||
if (ret == OP_HOLE) {
|
||||
// fprintf(stderr,"\nHole detected! Corrupt file segment?\n");
|
||||
continue;
|
||||
} else if (ret <= 0) {
|
||||
running = false;
|
||||
goto done;
|
||||
}
|
||||
buffPtr = 0;
|
||||
buffLen = ret * 2;
|
||||
}
|
||||
|
||||
lastSample[AudioOutput::LEFTCHANNEL] = buff[buffPtr] & 0xffff;
|
||||
lastSample[AudioOutput::RIGHTCHANNEL] = buff[buffPtr+1] & 0xffff;
|
||||
buffPtr += 2;
|
||||
} while (running && output->ConsumeSample(lastSample));
|
||||
|
||||
done:
|
||||
file->loop();
|
||||
output->loop();
|
||||
|
||||
return running;
|
||||
}
|
||||
|
||||
bool AudioGeneratorOpus::stop()
|
||||
{
|
||||
if (of) op_free(of);
|
||||
of = nullptr;
|
||||
free(buff);
|
||||
buff = nullptr;
|
||||
running = false;
|
||||
output->stop();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AudioGeneratorOpus::isRunning()
|
||||
{
|
||||
return running;
|
||||
}
|
||||
|
||||
int AudioGeneratorOpus::read_cb(unsigned char *_ptr, int _nbytes) {
|
||||
if (_nbytes == 0) return 0;
|
||||
_nbytes = file->read(_ptr, _nbytes);
|
||||
if (_nbytes == 0) return -1;
|
||||
return _nbytes;
|
||||
}
|
||||
|
||||
int AudioGeneratorOpus::seek_cb(opus_int64 _offset, int _whence) {
|
||||
if (!file->seek((int32_t)_offset, _whence)) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
opus_int64 AudioGeneratorOpus::tell_cb() {
|
||||
return file->getPos();
|
||||
}
|
||||
|
||||
int AudioGeneratorOpus::close_cb() {
|
||||
// NO OP, we close in main loop
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
AudioGeneratorOpus
|
||||
Audio output generator that plays Opus audio files
|
||||
|
||||
Copyright (C) 2020 Earle F. Philhower, III
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _AUDIOGENERATOROPUS_H
|
||||
#define _AUDIOGENERATOROPUS_H
|
||||
|
||||
#include <AudioGenerator.h>
|
||||
//#include "libopus/opus.h"
|
||||
#include "opusfile/opusfile.h"
|
||||
|
||||
class AudioGeneratorOpus : public AudioGenerator
|
||||
{
|
||||
public:
|
||||
AudioGeneratorOpus();
|
||||
virtual ~AudioGeneratorOpus() override;
|
||||
virtual bool begin(AudioFileSource *source, AudioOutput *output) override;
|
||||
virtual bool loop() override;
|
||||
virtual bool stop() override;
|
||||
virtual bool isRunning() override;
|
||||
|
||||
protected:
|
||||
// Opus callbacks, need static functions to bounce into C++ from C
|
||||
static int OPUS_read(void *_stream, unsigned char *_ptr, int _nbytes) {
|
||||
return static_cast<AudioGeneratorOpus*>(_stream)->read_cb(_ptr, _nbytes);
|
||||
}
|
||||
static int OPUS_seek(void *_stream, opus_int64 _offset, int _whence) {
|
||||
return static_cast<AudioGeneratorOpus*>(_stream)->seek_cb(_offset, _whence);
|
||||
}
|
||||
static opus_int64 OPUS_tell(void *_stream) {
|
||||
return static_cast<AudioGeneratorOpus*>(_stream)->tell_cb();
|
||||
}
|
||||
static int OPUS_close(void *_stream) {
|
||||
return static_cast<AudioGeneratorOpus*>(_stream)->close_cb();
|
||||
}
|
||||
|
||||
// Actual Opus callbacks
|
||||
int read_cb(unsigned char *_ptr, int _nbytes);
|
||||
int seek_cb(opus_int64 _offset, int _whence);
|
||||
opus_int64 tell_cb();
|
||||
int close_cb();
|
||||
|
||||
private:
|
||||
OpusFileCallbacks cb = {OPUS_read, OPUS_seek, OPUS_tell, OPUS_close};
|
||||
OggOpusFile *of;
|
||||
int prev_li; // To detect changes in streams
|
||||
|
||||
int16_t *buff;
|
||||
uint32_t buffPtr;
|
||||
uint32_t buffLen;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -41,7 +41,10 @@ AudioGeneratorRTTTL::~AudioGeneratorRTTTL()
|
||||
|
||||
bool AudioGeneratorRTTTL::stop()
|
||||
{
|
||||
if (!running) return true;
|
||||
if (!file || !output)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
running = false;
|
||||
output->stop();
|
||||
return file->close();
|
||||
@@ -233,13 +236,13 @@ bool AudioGeneratorRTTTL::GetNextNote()
|
||||
ptr++;
|
||||
note++;
|
||||
}
|
||||
if (!ReadInt(&scale)) {
|
||||
scale = defaultOctave;
|
||||
}
|
||||
if ((ptr < len) && (buff[ptr] == '.')) {
|
||||
ptr++;
|
||||
dur += dur / 2;
|
||||
}
|
||||
if (!ReadInt(&scale)) {
|
||||
scale = defaultOctave;
|
||||
}
|
||||
// Eat any trailing whitespace and comma
|
||||
SkipWhitespace();
|
||||
if ((ptr < len) && (buff[ptr]==',')) {
|
||||
|
||||
@@ -127,7 +127,7 @@ bool AudioGeneratorWAV::ReadWAVInfo()
|
||||
return false;
|
||||
};
|
||||
if (u32 != 0x46464952) {
|
||||
Serial.printf_P(PSTR("AudioGeneratorWAV::ReadWAVInfo: cannot read WAV, invalid RIFF header, got: %08X \n"), (uint32_t) u32);
|
||||
Serial.printf_P(PSTR("AudioGeneratorWAV::ReadWAVInfo: cannot read WAV, invalid RIFF header\n"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ bool AudioGeneratorWAV::ReadWAVInfo()
|
||||
return false;
|
||||
};
|
||||
if (u32 != 0x45564157) {
|
||||
Serial.printf_P(PSTR("AudioGeneratorWAV::ReadWAVInfo: cannot read WAV, invalid WAVE header, got: %08X \n"), (uint32_t) u32);
|
||||
Serial.printf_P(PSTR("AudioGeneratorWAV::ReadWAVInfo: cannot read WAV, invalid WAVE header\n"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,245 @@
|
||||
/*
|
||||
AudioOutputFilterBiquad
|
||||
Implements a Biquad filter
|
||||
|
||||
Copyright (C) 2012 Nigel Redmon
|
||||
Copyright (C) 2021 William Bérubé
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "AudioOutputFilterBiquad.h"
|
||||
|
||||
AudioOutputFilterBiquad::AudioOutputFilterBiquad(AudioOutput *sink)
|
||||
{
|
||||
this->sink = sink;
|
||||
|
||||
type = bq_type_lowpass;
|
||||
a0 = 1.0;
|
||||
a1 = a2 = b1 = b2 = 0.0;
|
||||
Fc = 0.50;
|
||||
Q = 0.707;
|
||||
peakGain = 0.0;
|
||||
z1 = z2 = 0.0;
|
||||
}
|
||||
|
||||
AudioOutputFilterBiquad::AudioOutputFilterBiquad(int type, float Fc, float Q, float peakGain, AudioOutput *sink)
|
||||
{
|
||||
this->sink = sink;
|
||||
|
||||
SetBiquad(type, Fc, Q, peakGain);
|
||||
z1 = z2 = 0.0;
|
||||
}
|
||||
|
||||
AudioOutputFilterBiquad::~AudioOutputFilterBiquad() {}
|
||||
|
||||
bool AudioOutputFilterBiquad::SetRate(int hz)
|
||||
{
|
||||
return sink->SetRate(hz);
|
||||
}
|
||||
|
||||
bool AudioOutputFilterBiquad::SetBitsPerSample(int bits)
|
||||
{
|
||||
return sink->SetBitsPerSample(bits);
|
||||
}
|
||||
|
||||
bool AudioOutputFilterBiquad::SetChannels(int channels)
|
||||
{
|
||||
return sink->SetChannels(channels);
|
||||
}
|
||||
|
||||
bool AudioOutputFilterBiquad::SetGain(float gain)
|
||||
{
|
||||
return sink->SetGain(gain);
|
||||
}
|
||||
|
||||
void AudioOutputFilterBiquad::SetType(int type)
|
||||
{
|
||||
this->type = type;
|
||||
CalcBiquad();
|
||||
}
|
||||
|
||||
void AudioOutputFilterBiquad::SetFc(float Fc)
|
||||
{
|
||||
this->Fc = Fc;
|
||||
CalcBiquad();
|
||||
}
|
||||
|
||||
void AudioOutputFilterBiquad::SetQ(float Q)
|
||||
{
|
||||
this->Q = Q;
|
||||
CalcBiquad();
|
||||
}
|
||||
|
||||
void AudioOutputFilterBiquad::SetPeakGain(float peakGain)
|
||||
{
|
||||
this->peakGain = peakGain;
|
||||
CalcBiquad();
|
||||
}
|
||||
|
||||
void AudioOutputFilterBiquad::SetBiquad(int type, float Fc, float Q, float peakGain)
|
||||
{
|
||||
this->type = type;
|
||||
this->Fc = Fc;
|
||||
this->Q = Q;
|
||||
this->peakGain = peakGain;
|
||||
CalcBiquad();
|
||||
}
|
||||
|
||||
void AudioOutputFilterBiquad::CalcBiquad()
|
||||
{
|
||||
float norm;
|
||||
float V = pow(10, fabs(peakGain) / 20.0);
|
||||
float K = tan(M_PI * Fc);
|
||||
|
||||
switch (this->type) {
|
||||
case bq_type_lowpass:
|
||||
norm = 1 / (1 + K / Q + K * K);
|
||||
a0 = K * K * norm;
|
||||
a1 = 2 * a0;
|
||||
a2 = a0;
|
||||
b1 = 2 * (K * K - 1) * norm;
|
||||
b2 = (1 - K / Q + K * K) * norm;
|
||||
break;
|
||||
|
||||
case bq_type_highpass:
|
||||
norm = 1 / (1 + K / Q + K * K);
|
||||
a0 = 1 * norm;
|
||||
a1 = -2 * a0;
|
||||
a2 = a0;
|
||||
b1 = 2 * (K * K - 1) * norm;
|
||||
b2 = (1 - K / Q + K * K) * norm;
|
||||
break;
|
||||
|
||||
case bq_type_bandpass:
|
||||
norm = 1 / (1 + K / Q + K * K);
|
||||
a0 = K / Q * norm;
|
||||
a1 = 0;
|
||||
a2 = -a0;
|
||||
b1 = 2 * (K * K - 1) * norm;
|
||||
b2 = (1 - K / Q + K * K) * norm;
|
||||
break;
|
||||
|
||||
case bq_type_notch:
|
||||
norm = 1 / (1 + K / Q + K * K);
|
||||
a0 = (1 + K * K) * norm;
|
||||
a1 = 2 * (K * K - 1) * norm;
|
||||
a2 = a0;
|
||||
b1 = a1;
|
||||
b2 = (1 - K / Q + K * K) * norm;
|
||||
break;
|
||||
|
||||
case bq_type_peak:
|
||||
if (peakGain >= 0) { // boost
|
||||
norm = 1 / (1 + 1/Q * K + K * K);
|
||||
a0 = (1 + V/Q * K + K * K) * norm;
|
||||
a1 = 2 * (K * K - 1) * norm;
|
||||
a2 = (1 - V/Q * K + K * K) * norm;
|
||||
b1 = a1;
|
||||
b2 = (1 - 1/Q * K + K * K) * norm;
|
||||
} else { // cut
|
||||
norm = 1 / (1 + V/Q * K + K * K);
|
||||
a0 = (1 + 1/Q * K + K * K) * norm;
|
||||
a1 = 2 * (K * K - 1) * norm;
|
||||
a2 = (1 - 1/Q * K + K * K) * norm;
|
||||
b1 = a1;
|
||||
b2 = (1 - V/Q * K + K * K) * norm;
|
||||
}
|
||||
break;
|
||||
|
||||
case bq_type_lowshelf:
|
||||
if (peakGain >= 0) { // boost
|
||||
norm = 1 / (1 + sqrt(2) * K + K * K);
|
||||
a0 = (1 + sqrt(2*V) * K + V * K * K) * norm;
|
||||
a1 = 2 * (V * K * K - 1) * norm;
|
||||
a2 = (1 - sqrt(2*V) * K + V * K * K) * norm;
|
||||
b1 = 2 * (K * K - 1) * norm;
|
||||
b2 = (1 - sqrt(2) * K + K * K) * norm;
|
||||
}
|
||||
else { // cut
|
||||
norm = 1 / (1 + sqrt(2*V) * K + V * K * K);
|
||||
a0 = (1 + sqrt(2) * K + K * K) * norm;
|
||||
a1 = 2 * (K * K - 1) * norm;
|
||||
a2 = (1 - sqrt(2) * K + K * K) * norm;
|
||||
b1 = 2 * (V * K * K - 1) * norm;
|
||||
b2 = (1 - sqrt(2*V) * K + V * K * K) * norm;
|
||||
}
|
||||
break;
|
||||
|
||||
case bq_type_highshelf:
|
||||
if (peakGain >= 0) { // boost
|
||||
norm = 1 / (1 + sqrt(2) * K + K * K);
|
||||
a0 = (V + sqrt(2*V) * K + K * K) * norm;
|
||||
a1 = 2 * (K * K - V) * norm;
|
||||
a2 = (V - sqrt(2*V) * K + K * K) * norm;
|
||||
b1 = 2 * (K * K - 1) * norm;
|
||||
b2 = (1 - sqrt(2) * K + K * K) * norm;
|
||||
}
|
||||
else { // cut
|
||||
norm = 1 / (V + sqrt(2*V) * K + K * K);
|
||||
a0 = (1 + sqrt(2) * K + K * K) * norm;
|
||||
a1 = 2 * (K * K - 1) * norm;
|
||||
a2 = (1 - sqrt(2) * K + K * K) * norm;
|
||||
b1 = 2 * (K * K - V) * norm;
|
||||
b2 = (V - sqrt(2*V) * K + K * K) * norm;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
i_a0 = a0 * BQ_DECAL;
|
||||
i_a1 = a1 * BQ_DECAL;
|
||||
i_a2 = a2 * BQ_DECAL;
|
||||
|
||||
i_b1 = b1 * BQ_DECAL;
|
||||
i_b2 = b2 * BQ_DECAL;
|
||||
|
||||
i_lz1 = i_rz1 = z1 * BQ_DECAL;
|
||||
i_lz2 = i_rz2 = z2 * BQ_DECAL;
|
||||
|
||||
i_Fc = Fc * BQ_DECAL;
|
||||
i_Q = Q * BQ_DECAL;
|
||||
i_peakGain = peakGain * BQ_DECAL;
|
||||
}
|
||||
|
||||
bool AudioOutputFilterBiquad::begin()
|
||||
{
|
||||
return sink->begin();
|
||||
}
|
||||
|
||||
bool AudioOutputFilterBiquad::ConsumeSample(int16_t sample[2])
|
||||
{
|
||||
|
||||
int32_t leftSample = (sample[LEFTCHANNEL] << BQ_SHIFT) / 2;
|
||||
int32_t rightSample = (sample[RIGHTCHANNEL] << BQ_SHIFT) / 2;
|
||||
|
||||
int64_t leftOutput = ((leftSample * i_a0) >> BQ_SHIFT) + i_lz1;
|
||||
i_lz1 = ((leftSample * i_a1) >> BQ_SHIFT) + i_lz2 - ((i_b1 * leftOutput) >> BQ_SHIFT);
|
||||
i_lz2 = ((leftSample * i_a2) >> BQ_SHIFT) - ((i_b2 * leftOutput) >> BQ_SHIFT);
|
||||
|
||||
int64_t rightOutput = ((rightSample * i_a0) >> BQ_SHIFT) + i_rz1;
|
||||
i_rz1 = ((rightSample * i_a1) >> BQ_SHIFT) + i_rz2 - ((i_b1 * rightOutput) >> BQ_SHIFT);
|
||||
i_rz2 = ((rightSample * i_a2) >> BQ_SHIFT) - ((i_b2 * rightOutput) >> BQ_SHIFT);
|
||||
|
||||
int16_t out[2];
|
||||
out[LEFTCHANNEL] = (int16_t)(leftOutput >> BQ_SHIFT);
|
||||
out[RIGHTCHANNEL] = (int16_t)(rightOutput >> BQ_SHIFT);
|
||||
|
||||
return sink->ConsumeSample(out);
|
||||
}
|
||||
|
||||
bool AudioOutputFilterBiquad::stop()
|
||||
{
|
||||
return sink->stop();
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
AudioOutputFilterBiquad
|
||||
Implements a Biquad filter
|
||||
|
||||
Copyright (C) 2012 Nigel Redmon
|
||||
Copyright (C) 2021 William Bérubé
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _AudioOutputFilterBiquad_H
|
||||
#define _AudioOutputFilterBiquad_H
|
||||
|
||||
#include "AudioOutput.h"
|
||||
|
||||
#define BQ_SHIFT 16
|
||||
#define BQ_DECAL 65536
|
||||
|
||||
enum {
|
||||
bq_type_lowpass = 0,
|
||||
bq_type_highpass,
|
||||
bq_type_bandpass,
|
||||
bq_type_notch,
|
||||
bq_type_peak,
|
||||
bq_type_lowshelf,
|
||||
bq_type_highshelf
|
||||
};
|
||||
|
||||
class AudioOutputFilterBiquad : public AudioOutput
|
||||
{
|
||||
public:
|
||||
AudioOutputFilterBiquad(AudioOutput *sink);
|
||||
AudioOutputFilterBiquad(int type, float Fc, float Q, float peakGain, AudioOutput *sink);
|
||||
virtual ~AudioOutputFilterBiquad() override;
|
||||
virtual bool SetRate(int hz) override;
|
||||
virtual bool SetBitsPerSample(int bits) override;
|
||||
virtual bool SetChannels(int chan) override;
|
||||
virtual bool SetGain(float f) override;
|
||||
virtual bool begin() override;
|
||||
virtual bool ConsumeSample(int16_t sample[2]) override;
|
||||
virtual bool stop() override;
|
||||
|
||||
private:
|
||||
void SetType(int type);
|
||||
void SetFc(float Fc);
|
||||
void SetQ(float Q);
|
||||
void SetPeakGain(float peakGain);
|
||||
void SetBiquad(int type, float Fc, float Q, float peakGain);
|
||||
|
||||
protected:
|
||||
AudioOutput *sink;
|
||||
int buffSize;
|
||||
int16_t *leftSample;
|
||||
int16_t *rightSample;
|
||||
int writePtr;
|
||||
int readPtr;
|
||||
bool filled;
|
||||
int type;
|
||||
void CalcBiquad();
|
||||
int64_t i_a0, i_a1, i_a2, i_b1, i_b2;
|
||||
int64_t i_Fc, i_Q, i_peakGain;
|
||||
int64_t i_lz1, i_lz2, i_rz1, i_rz2;
|
||||
float a0, a1, a2, b1, b2;
|
||||
float Fc, Q, peakGain;
|
||||
float z1, z2;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+304
-116
@@ -21,11 +21,14 @@
|
||||
#include <Arduino.h>
|
||||
#ifdef ESP32
|
||||
#include "driver/i2s.h"
|
||||
#else
|
||||
#elif defined(ARDUINO_ARCH_RP2040) || ARDUINO_ESP8266_MAJOR >= 3
|
||||
#include <I2S.h>
|
||||
#elif ARDUINO_ESP8266_MAJOR < 3
|
||||
#include <i2s.h>
|
||||
#endif
|
||||
#include "AudioOutputI2S.h"
|
||||
|
||||
#if defined(ESP32) || defined(ESP8266)
|
||||
AudioOutputI2S::AudioOutputI2S(int port, int output_mode, int dma_buf_count, int use_apll)
|
||||
{
|
||||
this->portNo = port;
|
||||
@@ -35,113 +38,108 @@ AudioOutputI2S::AudioOutputI2S(int port, int output_mode, int dma_buf_count, int
|
||||
output_mode = EXTERNAL_I2S;
|
||||
}
|
||||
this->output_mode = output_mode;
|
||||
#ifdef ESP32
|
||||
if (!i2sOn) {
|
||||
if (use_apll == APLL_AUTO) {
|
||||
// don't use audio pll on buggy rev0 chips
|
||||
use_apll = APLL_DISABLE;
|
||||
esp_chip_info_t out_info;
|
||||
esp_chip_info(&out_info);
|
||||
if(out_info.revision > 0) {
|
||||
use_apll = APLL_ENABLE;
|
||||
}
|
||||
}
|
||||
this->use_apll = use_apll;
|
||||
|
||||
i2s_mode_t mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_TX);
|
||||
if (output_mode == INTERNAL_DAC) {
|
||||
mode = (i2s_mode_t)(mode | I2S_MODE_DAC_BUILT_IN);
|
||||
} else if (output_mode == INTERNAL_PDM) {
|
||||
mode = (i2s_mode_t)(mode | I2S_MODE_PDM);
|
||||
}
|
||||
|
||||
i2s_comm_format_t comm_fmt = (i2s_comm_format_t)(I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB);
|
||||
if (output_mode == INTERNAL_DAC) {
|
||||
comm_fmt = (i2s_comm_format_t)I2S_COMM_FORMAT_I2S_MSB;
|
||||
}
|
||||
|
||||
i2s_config_t i2s_config_dac = {
|
||||
.mode = mode,
|
||||
.sample_rate = 44100,
|
||||
.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
|
||||
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
|
||||
.communication_format = comm_fmt,
|
||||
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1, // lowest interrupt priority
|
||||
.dma_buf_count = dma_buf_count,
|
||||
.dma_buf_len = 64,
|
||||
.use_apll = use_apll // Use audio PLL
|
||||
};
|
||||
audioLogger->printf("+%d %p\n", portNo, &i2s_config_dac);
|
||||
if (i2s_driver_install((i2s_port_t)portNo, &i2s_config_dac, 0, NULL) != ESP_OK) {
|
||||
audioLogger->println("ERROR: Unable to install I2S drives\n");
|
||||
}
|
||||
if (output_mode == INTERNAL_DAC || output_mode == INTERNAL_PDM) {
|
||||
i2s_set_pin((i2s_port_t)portNo, NULL);
|
||||
i2s_set_dac_mode(I2S_DAC_CHANNEL_BOTH_EN);
|
||||
} else {
|
||||
SetPinout(26, 25, 22);
|
||||
}
|
||||
i2s_zero_dma_buffer((i2s_port_t)portNo);
|
||||
}
|
||||
#else
|
||||
(void) dma_buf_count;
|
||||
(void) use_apll;
|
||||
if (!i2sOn) {
|
||||
orig_bck = READ_PERI_REG(PERIPHS_IO_MUX_MTDO_U);
|
||||
orig_ws = READ_PERI_REG(PERIPHS_IO_MUX_GPIO2_U);
|
||||
i2s_begin();
|
||||
}
|
||||
#endif
|
||||
i2sOn = true;
|
||||
//set defaults
|
||||
mono = false;
|
||||
lsb_justified = false;
|
||||
bps = 16;
|
||||
channels = 2;
|
||||
hertz = 44100;
|
||||
bclkPin = 26;
|
||||
wclkPin = 25;
|
||||
doutPin = 22;
|
||||
mclkPin = 0;
|
||||
SetGain(1.0);
|
||||
SetRate(44100); // Default
|
||||
}
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RP2040)
|
||||
AudioOutputI2S::AudioOutputI2S(long sampleRate, pin_size_t sck, pin_size_t data) {
|
||||
i2sOn = false;
|
||||
mono = false;
|
||||
bps = 16;
|
||||
channels = 2;
|
||||
hertz = sampleRate;
|
||||
bclkPin = sck;
|
||||
doutPin = data;
|
||||
mclkPin = 0;
|
||||
use_mclk = false;
|
||||
swap_clocks = false;
|
||||
SetGain(1.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
AudioOutputI2S::~AudioOutputI2S()
|
||||
{
|
||||
#ifdef ESP32
|
||||
if (i2sOn) {
|
||||
audioLogger->printf("UNINSTALL I2S\n");
|
||||
i2s_driver_uninstall((i2s_port_t)portNo); //stop & destroy i2s driver
|
||||
}
|
||||
#else
|
||||
if (i2sOn) i2s_end();
|
||||
stop();
|
||||
}
|
||||
|
||||
bool AudioOutputI2S::SetPinout()
|
||||
{
|
||||
#ifdef ESP32
|
||||
if (output_mode == INTERNAL_DAC || output_mode == INTERNAL_PDM)
|
||||
return false; // Not allowed
|
||||
|
||||
i2s_pin_config_t pins = {
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 4, 0)
|
||||
.mck_io_num = mclkPin,
|
||||
#endif
|
||||
i2sOn = false;
|
||||
.bck_io_num = bclkPin,
|
||||
.ws_io_num = wclkPin,
|
||||
.data_out_num = doutPin,
|
||||
.data_in_num = I2S_PIN_NO_CHANGE};
|
||||
i2s_set_pin((i2s_port_t)portNo, &pins);
|
||||
return true;
|
||||
#else
|
||||
(void)bclkPin;
|
||||
(void)wclkPin;
|
||||
(void)doutPin;
|
||||
(void)mclkPin;
|
||||
(void)use_mclk;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool AudioOutputI2S::SetPinout(int bclk, int wclk, int dout)
|
||||
{
|
||||
#ifdef ESP32
|
||||
if (output_mode == INTERNAL_DAC || output_mode == INTERNAL_PDM) return false; // Not allowed
|
||||
bclkPin = bclk;
|
||||
wclkPin = wclk;
|
||||
doutPin = dout;
|
||||
if (i2sOn)
|
||||
return SetPinout();
|
||||
|
||||
i2s_pin_config_t pins = {
|
||||
.bck_io_num = bclk,
|
||||
.ws_io_num = wclk,
|
||||
.data_out_num = dout,
|
||||
.data_in_num = I2S_PIN_NO_CHANGE
|
||||
};
|
||||
i2s_set_pin((i2s_port_t)portNo, &pins);
|
||||
return true;
|
||||
#else
|
||||
(void) bclk;
|
||||
(void) wclk;
|
||||
(void) dout;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool AudioOutputI2S::SetPinout(int bclk, int wclk, int dout, int mclk)
|
||||
{
|
||||
bclkPin = bclk;
|
||||
wclkPin = wclk;
|
||||
doutPin = dout;
|
||||
#if defined(ESP32) || defined(ARDUINO_ARCH_RP2040)
|
||||
mclkPin = mclk;
|
||||
if (i2sOn)
|
||||
return SetPinout();
|
||||
#else
|
||||
(void)mclk;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AudioOutputI2S::SetRate(int hz)
|
||||
{
|
||||
// TODO - have a list of allowable rates from constructor, check them
|
||||
this->hertz = hz;
|
||||
#ifdef ESP32
|
||||
i2s_set_sample_rates((i2s_port_t)portNo, AdjustI2SRate(hz));
|
||||
#else
|
||||
i2s_set_rate(AdjustI2SRate(hz));
|
||||
#endif
|
||||
if (i2sOn)
|
||||
{
|
||||
#ifdef ESP32
|
||||
i2s_set_sample_rates((i2s_port_t)portNo, AdjustI2SRate(hz));
|
||||
#elif defined(ESP8266)
|
||||
i2s_set_rate(AdjustI2SRate(hz));
|
||||
#elif defined(ARDUINO_ARCH_RP2040)
|
||||
i2s.setFrequency(hz);
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -165,13 +163,179 @@ bool AudioOutputI2S::SetOutputModeMono(bool mono)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AudioOutputI2S::begin()
|
||||
bool AudioOutputI2S::SetLsbJustified(bool lsbJustified)
|
||||
{
|
||||
this->lsb_justified = lsbJustified;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AudioOutputI2S::SwapClocks(bool swap_clocks)
|
||||
{
|
||||
if (i2sOn) {
|
||||
return false; // Not allowed
|
||||
}
|
||||
this->swap_clocks = swap_clocks;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AudioOutputI2S::SetMclk(bool enabled){
|
||||
(void)enabled;
|
||||
#ifdef ESP32
|
||||
if (output_mode == INTERNAL_DAC || output_mode == INTERNAL_PDM)
|
||||
return false; // Not allowed
|
||||
|
||||
use_mclk = enabled;
|
||||
#elif defined(ARDUINO_ARCH_RP2040)
|
||||
use_mclk = enabled;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AudioOutputI2S::begin(bool txDAC)
|
||||
{
|
||||
#ifdef ESP32
|
||||
if (!i2sOn)
|
||||
{
|
||||
if (use_apll == APLL_AUTO)
|
||||
{
|
||||
// don't use audio pll on buggy rev0 chips
|
||||
use_apll = APLL_DISABLE;
|
||||
//esp_chip_info_t out_info;
|
||||
//esp_chip_info(&out_info);
|
||||
//if (out_info.revision > 0)
|
||||
{
|
||||
use_apll = APLL_ENABLE;
|
||||
}
|
||||
}
|
||||
|
||||
i2s_mode_t mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_TX);
|
||||
if (output_mode == INTERNAL_DAC)
|
||||
{
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
mode = (i2s_mode_t)(mode | I2S_MODE_DAC_BUILT_IN);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
else if (output_mode == INTERNAL_PDM)
|
||||
{
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
mode = (i2s_mode_t)(mode | I2S_MODE_PDM);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
i2s_comm_format_t comm_fmt;
|
||||
if (output_mode == INTERNAL_DAC)
|
||||
{
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 2, 0)
|
||||
comm_fmt = (i2s_comm_format_t) I2S_COMM_FORMAT_STAND_MSB;
|
||||
#else
|
||||
comm_fmt = (i2s_comm_format_t) I2S_COMM_FORMAT_I2S_MSB;
|
||||
#endif
|
||||
}
|
||||
else if (lsb_justified)
|
||||
{
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 2, 0)
|
||||
comm_fmt = (i2s_comm_format_t) I2S_COMM_FORMAT_STAND_MSB;
|
||||
#else
|
||||
comm_fmt = (i2s_comm_format_t) (I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_LSB);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 2, 0)
|
||||
comm_fmt = (i2s_comm_format_t) (I2S_COMM_FORMAT_STAND_I2S);
|
||||
#else
|
||||
comm_fmt = (i2s_comm_format_t) (I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB);
|
||||
#endif
|
||||
}
|
||||
|
||||
i2s_config_t i2s_config_dac = {
|
||||
.mode = mode,
|
||||
.sample_rate = 44100,
|
||||
.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
|
||||
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
|
||||
.communication_format = comm_fmt,
|
||||
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1, // lowest interrupt priority
|
||||
.dma_buf_count = dma_buf_count,
|
||||
.dma_buf_len = 128,
|
||||
.use_apll = use_apll, // Use audio PLL
|
||||
.tx_desc_auto_clear = true, // Silence on underflow
|
||||
.fixed_mclk = use_mclk, // Unused
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 4, 0)
|
||||
.mclk_multiple = I2S_MCLK_MULTIPLE_256, // Unused
|
||||
.bits_per_chan = I2S_BITS_PER_CHAN_DEFAULT // Use bits per sample
|
||||
#endif
|
||||
};
|
||||
audioLogger->printf("+%d %p\n", portNo, &i2s_config_dac);
|
||||
if (i2s_driver_install((i2s_port_t)portNo, &i2s_config_dac, 0, NULL) != ESP_OK)
|
||||
{
|
||||
audioLogger->println("ERROR: Unable to install I2S drives\n");
|
||||
}
|
||||
if (output_mode == INTERNAL_DAC || output_mode == INTERNAL_PDM)
|
||||
{
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
i2s_set_pin((i2s_port_t)portNo, NULL);
|
||||
i2s_set_dac_mode(I2S_DAC_CHANNEL_BOTH_EN);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
SetPinout();
|
||||
}
|
||||
i2s_zero_dma_buffer((i2s_port_t)portNo);
|
||||
}
|
||||
#elif defined(ESP8266)
|
||||
(void)dma_buf_count;
|
||||
(void)use_apll;
|
||||
if (!i2sOn)
|
||||
{
|
||||
orig_bck = READ_PERI_REG(PERIPHS_IO_MUX_MTDO_U);
|
||||
orig_ws = READ_PERI_REG(PERIPHS_IO_MUX_GPIO2_U);
|
||||
#ifdef I2S_HAS_BEGIN_RXTX_DRIVE_CLOCKS
|
||||
if (!i2s_rxtxdrive_begin(false, true, false, txDAC)) {
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
if (!i2s_rxtx_begin(false, true)) {
|
||||
return false;
|
||||
}
|
||||
if (!txDAC) {
|
||||
audioLogger->printf_P(PSTR("I2SNoDAC: esp8266 arduino core should be upgraded to avoid conflicts with SPI\n"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#elif defined(ARDUINO_ARCH_RP2040)
|
||||
(void)txDAC;
|
||||
if (!i2sOn) {
|
||||
i2s.setSysClk(hertz);
|
||||
i2s.setBCLK(bclkPin);
|
||||
i2s.setDATA(doutPin);
|
||||
i2s.setMCLK(mclkPin);
|
||||
i2s.setMCLKmult(256);
|
||||
if (swap_clocks) {
|
||||
i2s.swapClocks();
|
||||
}
|
||||
i2s.setBitsPerSample(bps);
|
||||
i2s.begin(hertz);
|
||||
}
|
||||
#endif
|
||||
i2sOn = true;
|
||||
SetRate(hertz); // Default
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AudioOutputI2S::ConsumeSample(int16_t sample[2])
|
||||
{
|
||||
|
||||
//return if we haven't called ::begin yet
|
||||
if (!i2sOn)
|
||||
return false;
|
||||
|
||||
int16_t ms[2];
|
||||
|
||||
ms[0] = sample[0];
|
||||
@@ -183,41 +347,65 @@ bool AudioOutputI2S::ConsumeSample(int16_t sample[2])
|
||||
int32_t ttl = ms[LEFTCHANNEL] + ms[RIGHTCHANNEL];
|
||||
ms[LEFTCHANNEL] = ms[RIGHTCHANNEL] = (ttl>>1) & 0xffff;
|
||||
}
|
||||
#ifdef ESP32
|
||||
uint32_t s32;
|
||||
if (output_mode == INTERNAL_DAC) {
|
||||
int16_t l = Amplify(ms[LEFTCHANNEL]) + 0x8000;
|
||||
int16_t r = Amplify(ms[RIGHTCHANNEL]) + 0x8000;
|
||||
s32 = (r<<16) | (l&0xffff);
|
||||
} else {
|
||||
s32 = ((Amplify(ms[RIGHTCHANNEL]))<<16) | (Amplify(ms[LEFTCHANNEL]) & 0xffff);
|
||||
}
|
||||
return i2s_write_bytes((i2s_port_t)portNo, (const char*)&s32, sizeof(uint32_t), 0);
|
||||
#else
|
||||
uint32_t s32 = ((Amplify(ms[RIGHTCHANNEL]))<<16) | (Amplify(ms[LEFTCHANNEL]) & 0xffff);
|
||||
return i2s_write_sample_nb(s32); // If we can't store it, return false. OTW true
|
||||
#endif
|
||||
#ifdef ESP32
|
||||
uint32_t s32;
|
||||
if (output_mode == INTERNAL_DAC)
|
||||
{
|
||||
int16_t l = Amplify(ms[LEFTCHANNEL]) + 0x8000;
|
||||
int16_t r = Amplify(ms[RIGHTCHANNEL]) + 0x8000;
|
||||
s32 = ((r & 0xffff) << 16) | (l & 0xffff);
|
||||
}
|
||||
else
|
||||
{
|
||||
s32 = ((Amplify(ms[RIGHTCHANNEL])) << 16) | (Amplify(ms[LEFTCHANNEL]) & 0xffff);
|
||||
}
|
||||
//"i2s_write_bytes" has been removed in the ESP32 Arduino 2.0.0, use "i2s_write" instead.
|
||||
// return i2s_write_bytes((i2s_port_t)portNo, (const char *)&s32, sizeof(uint32_t), 0);
|
||||
|
||||
size_t i2s_bytes_written;
|
||||
i2s_write((i2s_port_t)portNo, (const char*)&s32, sizeof(uint32_t), &i2s_bytes_written, 0);
|
||||
return i2s_bytes_written;
|
||||
#elif defined(ESP8266)
|
||||
uint32_t s32 = ((Amplify(ms[RIGHTCHANNEL])) << 16) | (Amplify(ms[LEFTCHANNEL]) & 0xffff);
|
||||
return i2s_write_sample_nb(s32); // If we can't store it, return false. OTW true
|
||||
#elif defined(ARDUINO_ARCH_RP2040)
|
||||
uint32_t s32 = ((Amplify(ms[RIGHTCHANNEL])) << 16) | (Amplify(ms[LEFTCHANNEL]) & 0xffff);
|
||||
return !!i2s.write((int32_t)s32, false);
|
||||
#endif
|
||||
}
|
||||
|
||||
void AudioOutputI2S::flush() {
|
||||
#ifdef ESP32
|
||||
// makes sure that all stored DMA samples are consumed / played
|
||||
int buffersize = 64 * this->dma_buf_count;
|
||||
int16_t samples[2] = {0x0,0x0};
|
||||
for (int i=0;i<buffersize; i++) {
|
||||
while (!ConsumeSample(samples)) {
|
||||
delay(10);
|
||||
void AudioOutputI2S::flush()
|
||||
{
|
||||
#ifdef ESP32
|
||||
// makes sure that all stored DMA samples are consumed / played
|
||||
int buffersize = 128 * this->dma_buf_count;
|
||||
int16_t samples[2] = {0x0, 0x0};
|
||||
for (int i = 0; i < buffersize; i++)
|
||||
{
|
||||
while (!ConsumeSample(samples))
|
||||
{
|
||||
delay(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#elif defined(ARDUINO_ARCH_RP2040)
|
||||
i2s.flush();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool AudioOutputI2S::stop()
|
||||
{
|
||||
#ifdef ESP32
|
||||
i2s_zero_dma_buffer((i2s_port_t)portNo);
|
||||
#endif
|
||||
if (!i2sOn)
|
||||
return false;
|
||||
|
||||
#ifdef ESP32
|
||||
i2s_zero_dma_buffer((i2s_port_t)portNo);
|
||||
audioLogger->printf("UNINSTALL I2S\n");
|
||||
i2s_driver_uninstall((i2s_port_t)portNo); //stop & destroy i2s driver
|
||||
#elif defined(ESP8266)
|
||||
i2s_end();
|
||||
#elif defined(ARDUINO_ARCH_RP2040)
|
||||
i2s.end();
|
||||
#endif
|
||||
i2sOn = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+32
-9
@@ -18,41 +18,64 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _AUDIOOUTPUTI2S_H
|
||||
#define _AUDIOOUTPUTI2S_H
|
||||
#pragma once
|
||||
|
||||
#include "AudioOutput.h"
|
||||
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
#include <Arduino.h>
|
||||
#include <I2S.h>
|
||||
#endif
|
||||
|
||||
class AudioOutputI2S : public AudioOutput
|
||||
{
|
||||
public:
|
||||
#if defined(ESP32) || defined(ESP8266)
|
||||
AudioOutputI2S(int port=0, int output_mode=EXTERNAL_I2S, int dma_buf_count = 8, int use_apll=APLL_DISABLE);
|
||||
virtual ~AudioOutputI2S() override;
|
||||
enum : int { APLL_AUTO = -1, APLL_ENABLE = 1, APLL_DISABLE = 0 };
|
||||
enum : int { EXTERNAL_I2S = 0, INTERNAL_DAC = 1, INTERNAL_PDM = 2 };
|
||||
#elif defined(ARDUINO_ARCH_RP2040)
|
||||
AudioOutputI2S(long sampleRate = 44100, pin_size_t sck = 26, pin_size_t data = 28);
|
||||
#endif
|
||||
bool SetPinout(int bclkPin, int wclkPin, int doutPin);
|
||||
bool SetPinout(int bclkPin, int wclkPin, int doutPin, int mclkPin);
|
||||
virtual ~AudioOutputI2S() override;
|
||||
virtual bool SetRate(int hz) override;
|
||||
virtual bool SetBitsPerSample(int bits) override;
|
||||
virtual bool SetChannels(int channels) override;
|
||||
virtual bool begin() override;
|
||||
virtual bool begin() override { return begin(true); }
|
||||
virtual bool ConsumeSample(int16_t sample[2]) override;
|
||||
virtual void flush() override;
|
||||
virtual bool stop() override;
|
||||
|
||||
bool begin(bool txDAC);
|
||||
bool SetOutputModeMono(bool mono); // Force mono output no matter the input
|
||||
|
||||
enum : int { APLL_AUTO = -1, APLL_ENABLE = 1, APLL_DISABLE = 0 };
|
||||
enum : int { EXTERNAL_I2S = 0, INTERNAL_DAC = 1, INTERNAL_PDM = 2 };
|
||||
bool SetLsbJustified(bool lsbJustified); // Allow supporting non-I2S chips, e.g. PT8211
|
||||
bool SetMclk(bool enabled); // Enable MCLK output (if supported)
|
||||
bool SwapClocks(bool swap_clocks); // Swap BCLK and WCLK
|
||||
|
||||
protected:
|
||||
bool SetPinout();
|
||||
virtual int AdjustI2SRate(int hz) { return hz; }
|
||||
uint8_t portNo;
|
||||
int output_mode;
|
||||
bool mono;
|
||||
int lsb_justified;
|
||||
bool i2sOn;
|
||||
int dma_buf_count;
|
||||
int use_apll;
|
||||
bool use_mclk;
|
||||
bool swap_clocks;
|
||||
// We can restore the old values and free up these pins when in NoDAC mode
|
||||
uint32_t orig_bck;
|
||||
uint32_t orig_ws;
|
||||
};
|
||||
|
||||
uint8_t bclkPin;
|
||||
uint8_t wclkPin;
|
||||
uint8_t doutPin;
|
||||
uint8_t mclkPin;
|
||||
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
I2S i2s;
|
||||
#endif
|
||||
|
||||
};
|
||||
@@ -21,22 +21,46 @@
|
||||
#include <Arduino.h>
|
||||
#ifdef ESP32
|
||||
#include "driver/i2s.h"
|
||||
#else
|
||||
#elif defined(ARDUINO_ARCH_RP2040) || ARDUINO_ESP8266_MAJOR >= 3
|
||||
#include <I2S.h>
|
||||
#elif ARDUINO_ESP8266_MAJOR < 3
|
||||
#include <i2s.h>
|
||||
#endif
|
||||
#include "AudioOutputI2SNoDAC.h"
|
||||
|
||||
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
//
|
||||
// Create an alternate constructor for the RP2040. The AudioOutputI2S has an alternate
|
||||
// constructor for the RP2040, so the code was passing port to the sampleRate and false to sck.
|
||||
//
|
||||
// AudioOutputI2S(long sampleRate = 44100, pin_size_t sck = 26, pin_size_t data = 28);
|
||||
//
|
||||
// So this new constructor adds the ability to pass both port and sck to the underlying class, but
|
||||
// uses the same defaults in the AudioOutputI2S constructor.
|
||||
//
|
||||
AudioOutputI2SNoDAC::AudioOutputI2SNoDAC(int port, int sck) : AudioOutputI2S(44100, sck, port)
|
||||
{
|
||||
SetOversampling(32);
|
||||
lastSamp = 0;
|
||||
cumErr = 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
AudioOutputI2SNoDAC::AudioOutputI2SNoDAC(int port) : AudioOutputI2S(port, false)
|
||||
{
|
||||
SetOversampling(32);
|
||||
lastSamp = 0;
|
||||
cumErr = 0;
|
||||
#ifndef ESP32
|
||||
#ifdef ESP8266
|
||||
WRITE_PERI_REG(PERIPHS_IO_MUX_MTDO_U, orig_bck);
|
||||
WRITE_PERI_REG(PERIPHS_IO_MUX_GPIO2_U, orig_ws);
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
AudioOutputI2SNoDAC::~AudioOutputI2SNoDAC()
|
||||
{
|
||||
@@ -95,14 +119,21 @@ bool AudioOutputI2SNoDAC::ConsumeSample(int16_t sample[2])
|
||||
|
||||
// Either send complete pulse stream or nothing
|
||||
#ifdef ESP32
|
||||
if (!i2s_write_bytes((i2s_port_t)portNo, (const char *)dsBuff, sizeof(uint32_t) * (oversample/32), 0))
|
||||
size_t i2s_bytes_written;
|
||||
i2s_write((i2s_port_t)portNo, (const char *)dsBuff, sizeof(uint32_t) * (oversample/32), &i2s_bytes_written, 0);
|
||||
if (!i2s_bytes_written){
|
||||
return false;
|
||||
#else
|
||||
}
|
||||
#elif defined(ESP8266)
|
||||
if (!i2s_write_sample_nb(dsBuff[0])) return false; // No room at the inn
|
||||
// At this point we've sent in first of possibly 8 32-bits, need to send
|
||||
// remaining ones even if they block.
|
||||
for (int i = 32; i < oversample; i+=32)
|
||||
i2s_write_sample( dsBuff[i / 32]);
|
||||
#elif defined(ARDUINO_ARCH_RP2040)
|
||||
for (int i = 0; i < oversample / 32; i++) {
|
||||
i2s.write((int32_t)dsBuff[i], true);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
@@ -18,29 +18,35 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _AUDIOOUTPUTI2SNODAC_H
|
||||
#define _AUDIOOUTPUTI2SNODAC_H
|
||||
#pragma once
|
||||
|
||||
#include "AudioOutputI2S.h"
|
||||
|
||||
class AudioOutputI2SNoDAC : public AudioOutputI2S
|
||||
{
|
||||
public:
|
||||
//
|
||||
// Define a different constructor for the RP2040, as this class calls the constructor
|
||||
// of the AudioOutputI2S which has an alternate constructor for the RP2040
|
||||
//
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
AudioOutputI2SNoDAC(int port = 28,int sck = 26);
|
||||
#else
|
||||
AudioOutputI2SNoDAC(int port = 0);
|
||||
#endif
|
||||
|
||||
virtual ~AudioOutputI2SNoDAC() override;
|
||||
virtual bool begin() override { return AudioOutputI2S::begin(false); }
|
||||
virtual bool ConsumeSample(int16_t sample[2]) override;
|
||||
|
||||
bool SetOversampling(int os);
|
||||
|
||||
protected:
|
||||
virtual int AdjustI2SRate(int hz) override { return hz * oversample/32; }
|
||||
uint8_t oversample;
|
||||
int oversample;
|
||||
void DeltaSigma(int16_t sample[2], uint32_t dsBuff[4]);
|
||||
typedef int32_t fixed24p8_t;
|
||||
enum {fixedPosValue=0x007fff00}; /* 24.8 of max-signed-int */
|
||||
fixed24p8_t lastSamp; // Last sample value
|
||||
fixed24p8_t cumErr; // Running cumulative error since time began
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -71,8 +71,8 @@ bool AudioOutputMixerStub::stop()
|
||||
AudioOutputMixer::AudioOutputMixer(int buffSizeSamples, AudioOutput *dest) : AudioOutput()
|
||||
{
|
||||
buffSize = buffSizeSamples;
|
||||
leftAccum = (int32_t*)calloc(sizeof(int32_t), buffSize);
|
||||
rightAccum = (int32_t*)calloc(sizeof(int32_t), buffSize);
|
||||
leftAccum = (int32_t*)calloc(buffSize, sizeof(int32_t));
|
||||
rightAccum = (int32_t*)calloc(buffSize, sizeof(int32_t));
|
||||
for (int i=0; i<maxStubs; i++) {
|
||||
stubAllocated[i] = false;
|
||||
stubRunning[i] = false;
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
AudioOutputPWM
|
||||
Base class for the RP2040 PWM audio
|
||||
|
||||
Copyright (C) 2023 Earle F. Philhower, III
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
#include <Arduino.h>
|
||||
#include "AudioOutputPWM.h"
|
||||
|
||||
AudioOutputPWM::AudioOutputPWM(long sampleRate, pin_size_t data) {
|
||||
pwmOn = false;
|
||||
mono = false;
|
||||
bps = 16;
|
||||
channels = 2;
|
||||
hertz = sampleRate;
|
||||
doutPin = data;
|
||||
SetGain(1.0);
|
||||
pwm.setStereo(true);
|
||||
}
|
||||
|
||||
AudioOutputPWM::~AudioOutputPWM() {
|
||||
stop();
|
||||
}
|
||||
|
||||
bool AudioOutputPWM::SetRate(int hz) {
|
||||
this->hertz = hz;
|
||||
if (pwmOn) {
|
||||
pwm.setFrequency(hz);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AudioOutputPWM::SetBitsPerSample(int bits) {
|
||||
if ( (bits != 16) && (bits != 8) ) return false;
|
||||
this->bps = bits;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AudioOutputPWM::SetChannels(int channels) {
|
||||
if ( (channels < 1) || (channels > 2) ) return false;
|
||||
this->channels = channels;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AudioOutputPWM::SetOutputModeMono(bool mono) {
|
||||
this->mono = mono;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AudioOutputPWM::begin() {
|
||||
if (!pwmOn) {
|
||||
pwm.setPin(doutPin);
|
||||
pwm.begin(hertz);
|
||||
}
|
||||
pwmOn = true;
|
||||
SetRate(hertz); // Default
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AudioOutputPWM::ConsumeSample(int16_t sample[2]) {
|
||||
|
||||
if (!pwmOn)
|
||||
return false;
|
||||
|
||||
int16_t ms[2];
|
||||
|
||||
ms[0] = sample[0];
|
||||
ms[1] = sample[1];
|
||||
MakeSampleStereo16( ms );
|
||||
|
||||
if (this->mono) {
|
||||
// Average the two samples and overwrite
|
||||
int32_t ttl = ms[LEFTCHANNEL] + ms[RIGHTCHANNEL];
|
||||
ms[LEFTCHANNEL] = ms[RIGHTCHANNEL] = (ttl>>1) & 0xffff;
|
||||
}
|
||||
|
||||
ms[LEFTCHANNEL] = Amplify(ms[LEFTCHANNEL]);
|
||||
ms[RIGHTCHANNEL] = Amplify(ms[RIGHTCHANNEL]);
|
||||
|
||||
if (pwm.available()) {
|
||||
pwm.write((int16_t) ms[0]);
|
||||
pwm.write((int16_t) ms[1]);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void AudioOutputPWM::flush() {
|
||||
pwm.flush();
|
||||
}
|
||||
|
||||
bool AudioOutputPWM::stop() {
|
||||
if (!pwmOn)
|
||||
return false;
|
||||
|
||||
pwm.end();
|
||||
pwmOn = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
AudioOutputPWM
|
||||
Base class for the RP2040 PWM audio output
|
||||
|
||||
Copyright (C) 2023 Earle F. Philhower, III
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "AudioOutput.h"
|
||||
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
#include <Arduino.h>
|
||||
#include <PWMAudio.h>
|
||||
|
||||
class AudioOutputPWM : public AudioOutput
|
||||
{
|
||||
public:
|
||||
AudioOutputPWM(long sampleRate = 44100, pin_size_t data = 0);
|
||||
virtual ~AudioOutputPWM() override;
|
||||
virtual bool SetRate(int hz) override;
|
||||
virtual bool SetBitsPerSample(int bits) override;
|
||||
virtual bool SetChannels(int channels) override;
|
||||
virtual bool begin() override;
|
||||
virtual bool ConsumeSample(int16_t sample[2]) override;
|
||||
virtual void flush() override;
|
||||
virtual bool stop() override;
|
||||
|
||||
bool SetOutputModeMono(bool mono); // Force mono output no matter the input
|
||||
|
||||
protected:
|
||||
bool SetPinout();
|
||||
virtual int AdjustI2SRate(int hz) { return hz; }
|
||||
uint8_t portNo;
|
||||
int output_mode;
|
||||
bool mono;
|
||||
bool pwmOn;
|
||||
|
||||
uint8_t doutPin;
|
||||
|
||||
PWMAudio pwm;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -3,11 +3,11 @@
|
||||
|
||||
S/PDIF output via I2S
|
||||
|
||||
Needs transciever from CMOS level to either optical or coaxial interface
|
||||
Needs transceiver from CMOS level to either optical or coaxial interface
|
||||
See: https://www.epanorama.net/documents/audio/spdif.html
|
||||
|
||||
Original idea and sources:
|
||||
Forum thread dicussing implementation
|
||||
Forum thread discussing implementation
|
||||
https://forum.pjrc.com/threads/28639-S-pdif
|
||||
Teensy Audio Library
|
||||
https://github.com/PaulStoffregen/Audio/blob/master/output_spdif2.cpp
|
||||
@@ -37,6 +37,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#if defined(ESP32) || defined(ESP8266)
|
||||
|
||||
#include <Arduino.h>
|
||||
#if defined(ESP32)
|
||||
@@ -93,11 +94,24 @@ AudioOutputSPDIF::AudioOutputSPDIF(int dout_pin, int port, int dma_buf_count)
|
||||
.sample_rate = 88200, // 2 x sampling_rate
|
||||
.bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT, // 32bit words
|
||||
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT, // Right than left
|
||||
.communication_format = (i2s_comm_format_t)(I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB),
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 2, 0)
|
||||
.communication_format = (i2s_comm_format_t)(I2S_COMM_FORMAT_STAND_I2S),
|
||||
#else
|
||||
.communication_format = (i2s_comm_format_t)(I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB),
|
||||
#endif
|
||||
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1, // lowest interrupt priority
|
||||
.dma_buf_count = dma_buf_count,
|
||||
.dma_buf_len = DMA_BUF_SIZE_DEFAULT, // bigger buffers, reduces interrupts
|
||||
.use_apll = true // Audio PLL is needed for low clock jitter
|
||||
.use_apll = true, // Audio PLL is needed for low clock jitter
|
||||
.tx_desc_auto_clear = true, // Silence on underflow
|
||||
.fixed_mclk = 0, // Unused
|
||||
#if defined(ESP_ARDUINO_VERSION_MAJOR) && ESP_ARDUINO_VERSION_MAJOR >= 3
|
||||
.mclk_multiple = I2S_MCLK_MULTIPLE_512, // Unused
|
||||
.bits_per_chan = I2S_BITS_PER_CHAN_DEFAULT // Use bits per sample
|
||||
#elif ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 4, 0)
|
||||
.mclk_multiple = I2S_MCLK_MULTIPLE_DEFAULT, // Unused
|
||||
.bits_per_chan = I2S_BITS_PER_CHAN_DEFAULT // Use bits per sample
|
||||
#endif
|
||||
};
|
||||
if (i2s_driver_install((i2s_port_t)portNo, &i2s_config_spdif, 0, NULL) != ESP_OK) {
|
||||
audioLogger->println(F("ERROR: Unable to install I2S drivers"));
|
||||
@@ -142,6 +156,9 @@ bool AudioOutputSPDIF::SetPinout(int bclk, int wclk, int dout)
|
||||
{
|
||||
#if defined(ESP32)
|
||||
i2s_pin_config_t pins = {
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 4, 0)
|
||||
.mck_io_num = 0, // unused
|
||||
#endif
|
||||
.bck_io_num = bclk,
|
||||
.ws_io_num = wclk,
|
||||
.data_out_num = dout,
|
||||
@@ -169,12 +186,14 @@ bool AudioOutputSPDIF::SetRate(int hz)
|
||||
int adjustedHz = AdjustI2SRate(hz);
|
||||
#if defined(ESP32)
|
||||
if (i2s_set_sample_rates((i2s_port_t)portNo, adjustedHz) == ESP_OK) {
|
||||
#if defined(ESP_ARDUINO_VERSION_MAJOR) && (ESP_ARDUINO_VERSION_MAJOR < 3)
|
||||
if (adjustedHz == 88200) {
|
||||
// Manually fix the APLL rate for 44100.
|
||||
// See: https://github.com/espressif/esp-idf/issues/2634
|
||||
// sdm0 = 28, sdm1 = 8, sdm2 = 5, odir = 0 -> 88199.977
|
||||
rtc_clk_apll_enable(1, 28, 8, 5, 0);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
audioLogger->println("ERROR changing S/PDIF sample rate");
|
||||
}
|
||||
@@ -264,7 +283,7 @@ bool AudioOutputSPDIF::ConsumeSample(int16_t sample[2])
|
||||
|
||||
#if defined(ESP32)
|
||||
// Assume DMA buffers are multiples of 16 bytes. Either we write all bytes or none.
|
||||
uint32_t bytes_written;
|
||||
size_t bytes_written;
|
||||
esp_err_t ret = i2s_write((i2s_port_t)portNo, (const char*)&buf, 8 * channels, &bytes_written, 0);
|
||||
// If we didn't write all bytes, return false early and do not increment frame_num
|
||||
if ((ret != ESP_OK) || (bytes_written != (8 * channels))) return false;
|
||||
@@ -286,3 +305,5 @@ bool AudioOutputSPDIF::stop()
|
||||
frame_num = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -3,11 +3,11 @@
|
||||
|
||||
S/PDIF output via I2S
|
||||
|
||||
Needs transciever from CMOS level to either optical or coaxial interface
|
||||
Needs transceiver from CMOS level to either optical or coaxial interface
|
||||
See: https://www.epanorama.net/documents/audio/spdif.html
|
||||
|
||||
Original idea and sources:
|
||||
Forum thread dicussing implementation
|
||||
Forum thread discussing implementation
|
||||
https://forum.pjrc.com/threads/28639-S-pdif
|
||||
Teensy Audio Library
|
||||
https://github.com/PaulStoffregen/Audio/blob/master/output_spdif2.cpp
|
||||
@@ -30,8 +30,8 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _AUDIOOUTPUTSPDIF_H
|
||||
#define _AUDIOOUTPUTSPDIF_H
|
||||
#if defined(ESP32) || defined(ESP8266)
|
||||
#pragma once
|
||||
|
||||
#include "AudioOutput.h"
|
||||
|
||||
|
||||
@@ -18,12 +18,18 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if !defined(ARDUINO_ARCH_RP2040)
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <FS.h>
|
||||
#ifdef ESP32
|
||||
#include "SPIFFS.h"
|
||||
#endif
|
||||
|
||||
// Yes, I know SPIFFS is deprecated
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
|
||||
|
||||
#include "AudioOutputSPIFFSWAV.h"
|
||||
|
||||
static const uint8_t wavHeaderTemplate[] PROGMEM = { // Hardcoded simple WAV header with 0xffffffff lengths all around
|
||||
@@ -110,4 +116,6 @@ bool AudioOutputSPIFFSWAV::stop()
|
||||
f.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -21,6 +21,8 @@
|
||||
#ifndef _AUDIOOUTPUTSPIFFSWAV_H
|
||||
#define _AUDIOOUTPUTSPIFFSWAV_H
|
||||
|
||||
#if !defined(ARDUINO_ARCH_RP2040)
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <FS.h>
|
||||
|
||||
@@ -43,3 +45,4 @@ class AudioOutputSPIFFSWAV : public AudioOutput
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -54,6 +54,11 @@ bool AudioOutputSTDIO::begin()
|
||||
|
||||
bool AudioOutputSTDIO::ConsumeSample(int16_t sample[2])
|
||||
{
|
||||
static int avail = 100;
|
||||
if (!(--avail)) {
|
||||
avail = 100;
|
||||
return false;
|
||||
}
|
||||
for (int i=0; i<channels; i++) {
|
||||
if (bps == 8) {
|
||||
uint8_t l = sample[i] & 0xff;
|
||||
|
||||
@@ -0,0 +1,262 @@
|
||||
/*
|
||||
AudioOutputULP
|
||||
Outputs to ESP32 DAC through the ULP, freeing I2S for other uses
|
||||
|
||||
Copyright (C) 2020 Martin Laclaustra, based on bitluni's code
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
|
||||
#include "AudioOutputULP.h"
|
||||
#include <esp32/ulp.h>
|
||||
#include <driver/rtc_io.h>
|
||||
#include <driver/dac.h>
|
||||
#include <soc/rtc.h>
|
||||
#include <math.h>
|
||||
|
||||
uint32_t create_I_WR_REG(uint32_t reg, uint32_t low_bit, uint32_t high_bit, uint32_t val){
|
||||
typedef union {ulp_insn_t ulp_ins; uint32_t ulp_bin;} ulp_union;
|
||||
const ulp_insn_t singleinstruction[] = {I_WR_REG(reg, low_bit, high_bit, val)};
|
||||
ulp_union recover_ins;
|
||||
recover_ins.ulp_ins=singleinstruction[0];
|
||||
return (uint32_t)(recover_ins.ulp_bin);
|
||||
}
|
||||
|
||||
uint32_t create_I_BXI(uint32_t imm_pc){
|
||||
typedef union {ulp_insn_t ulp_ins; uint32_t ulp_bin;} ulp_union;
|
||||
const ulp_insn_t singleinstruction[] = {I_BXI(imm_pc)};
|
||||
ulp_union recover_ins;
|
||||
recover_ins.ulp_ins=singleinstruction[0];
|
||||
return (uint32_t)(recover_ins.ulp_bin);
|
||||
}
|
||||
|
||||
bool AudioOutputULP::begin()
|
||||
{
|
||||
if(!stereoOutput){
|
||||
waitingOddSample = false;
|
||||
//totalSampleWords += 512;
|
||||
//dacTableStart2 = dacTableStart1;
|
||||
}
|
||||
|
||||
//calculate the actual ULP clock
|
||||
unsigned long rtc_8md256_period = rtc_clk_cal(RTC_CAL_8MD256, 1000);
|
||||
unsigned long rtc_fast_freq_hz = 1000000ULL * (1 << RTC_CLK_CAL_FRACT) * 256 / rtc_8md256_period;
|
||||
|
||||
//initialize DACs
|
||||
if(activeDACs & 1){
|
||||
dac_output_enable(DAC_CHANNEL_1);
|
||||
dac_output_voltage(DAC_CHANNEL_1, 128);
|
||||
}
|
||||
if(activeDACs & 2){
|
||||
dac_output_enable(DAC_CHANNEL_2);
|
||||
dac_output_voltage(DAC_CHANNEL_2, 128);
|
||||
}
|
||||
|
||||
int retAddress1 = 9;
|
||||
int retAddress2 = 14;
|
||||
|
||||
int loopCycles = 134;
|
||||
int loopHalfCycles1 = 90;
|
||||
int loopHalfCycles2 = 44;
|
||||
|
||||
Serial.print("Real RTC clock: ");
|
||||
Serial.println(rtc_fast_freq_hz);
|
||||
|
||||
uint32_t dt = (rtc_fast_freq_hz / hertz) - loopCycles;
|
||||
uint32_t dt2 = 0;
|
||||
if(!stereoOutput){
|
||||
dt = (rtc_fast_freq_hz / hertz) - loopHalfCycles1;
|
||||
dt2 = (rtc_fast_freq_hz / hertz) - loopHalfCycles2;
|
||||
}
|
||||
|
||||
Serial.print("dt: ");
|
||||
Serial.println(dt);
|
||||
|
||||
Serial.print("dt2: ");
|
||||
Serial.println(dt2);
|
||||
|
||||
const ulp_insn_t stereo[] = {
|
||||
//reset offset register
|
||||
I_MOVI(R3, 0),
|
||||
//delay to get the right sampling rate
|
||||
I_DELAY(dt), // 6 + dt
|
||||
//reset sample index
|
||||
I_MOVI(R0, 0), // 6
|
||||
//write the index back to memory for the main cpu
|
||||
I_ST(R0, R3, indexAddress), // 8
|
||||
//load the samples
|
||||
I_LD(R1, R0, bufferStart), // 8
|
||||
//mask the lower 8 bits
|
||||
I_ANDI(R2, R1, 0x00ff), // 6
|
||||
//multiply by 2
|
||||
I_LSHI(R2, R2, 1), // 6
|
||||
//add start position
|
||||
I_ADDI(R2, R2, dacTableStart1),// 6
|
||||
//jump to the dac opcode
|
||||
I_BXR(R2), // 4
|
||||
//back from first dac
|
||||
//delay between the two samples in mono rendering
|
||||
I_DELAY(dt2), // 6 + dt2
|
||||
//mask the upper 8 bits
|
||||
I_ANDI(R2, R1, 0xff00), // 6
|
||||
//shift the upper bits to right and multiply by 2
|
||||
I_RSHI(R2, R2, 8 - 1), // 6
|
||||
//add start position of second dac table
|
||||
I_ADDI(R2, R2, dacTableStart2),// 6
|
||||
//jump to the dac opcode
|
||||
I_BXR(R2), // 4
|
||||
//here we get back from writing the second sample
|
||||
//load 0x8080 as sample
|
||||
I_MOVI(R1, 0x8080), // 6
|
||||
//write 0x8080 in the sample buffer
|
||||
I_ST(R1, R0, indexAddress), // 8
|
||||
//increment the sample index
|
||||
I_ADDI(R0, R0, 1), // 6
|
||||
//if reached end of the buffer, jump relative to index reset
|
||||
I_BGE(-16, totalSampleWords), // 4
|
||||
//wait to get the right sample rate (2 cycles more to compensate the index reset)
|
||||
I_DELAY((unsigned int)dt + 2), // 8 + dt
|
||||
//if not, jump absolute to where index is written to memory
|
||||
I_BXI(3) // 4
|
||||
};
|
||||
// write io and jump back another 12 + 4 + 12 + 4
|
||||
|
||||
size_t load_addr = 0;
|
||||
size_t size = sizeof(stereo)/sizeof(ulp_insn_t);
|
||||
ulp_process_macros_and_load(load_addr, stereo, &size);
|
||||
// this is how to get the opcodes
|
||||
// for(int i = 0; i < size; i++)
|
||||
// Serial.println(RTC_SLOW_MEM[i], HEX);
|
||||
|
||||
//create DAC opcode tables
|
||||
switch(activeDACs){
|
||||
case 1:
|
||||
for(int i = 0; i < 256; i++)
|
||||
{
|
||||
RTC_SLOW_MEM[dacTableStart1 + i * 2] = create_I_WR_REG(RTC_IO_PAD_DAC1_REG,19,26,i); //dac1: 0x1D4C0121 | (i << 10)
|
||||
RTC_SLOW_MEM[dacTableStart1 + 1 + i * 2] = create_I_BXI(retAddress1); // 0x80000000 + retAddress1 * 4
|
||||
RTC_SLOW_MEM[dacTableStart2 + i * 2] = create_I_WR_REG(RTC_IO_PAD_DAC1_REG,19,26,i); //dac2: 0x1D4C0122 | (i << 10)
|
||||
RTC_SLOW_MEM[dacTableStart2 + 1 + i * 2] = create_I_BXI(retAddress2); // 0x80000000 + retAddress2 * 4
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
for(int i = 0; i < 256; i++)
|
||||
{
|
||||
RTC_SLOW_MEM[dacTableStart1 + i * 2] = create_I_WR_REG(RTC_IO_PAD_DAC2_REG,19,26,i); //dac1: 0x1D4C0121 | (i << 10)
|
||||
RTC_SLOW_MEM[dacTableStart1 + 1 + i * 2] = create_I_BXI(retAddress1); // 0x80000000 + retAddress1 * 4
|
||||
RTC_SLOW_MEM[dacTableStart2 + i * 2] = create_I_WR_REG(RTC_IO_PAD_DAC2_REG,19,26,i); //dac2: 0x1D4C0122 | (i << 10)
|
||||
RTC_SLOW_MEM[dacTableStart2 + 1 + i * 2] = create_I_BXI(retAddress2); // 0x80000000 + retAddress2 * 4
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
for(int i = 0; i < 256; i++)
|
||||
{
|
||||
RTC_SLOW_MEM[dacTableStart1 + i * 2] = create_I_WR_REG(RTC_IO_PAD_DAC1_REG,19,26,i); //dac1: 0x1D4C0121 | (i << 10)
|
||||
RTC_SLOW_MEM[dacTableStart1 + 1 + i * 2] = create_I_BXI(retAddress1); // 0x80000000 + retAddress1 * 4
|
||||
RTC_SLOW_MEM[dacTableStart2 + i * 2] = create_I_WR_REG(RTC_IO_PAD_DAC1_REG,19,26,i); //dac2: 0x1D4C0122 | (i << 10)
|
||||
RTC_SLOW_MEM[dacTableStart2 + 1 + i * 2] = create_I_BXI(retAddress2); // 0x80000000 + retAddress2 * 4
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//set all samples to 128 (silence)
|
||||
for(int i = 0; i < totalSampleWords; i++)
|
||||
RTC_SLOW_MEM[bufferStart + i] = 0x8080;
|
||||
|
||||
//start
|
||||
RTC_SLOW_MEM[indexAddress] = 0;
|
||||
ulp_run(0);
|
||||
|
||||
//wait until ULP starts using samples and the index of output sample advances
|
||||
while(RTC_SLOW_MEM[indexAddress] == 0)
|
||||
delay(1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AudioOutputULP::ConsumeSample(int16_t sample[2])
|
||||
{
|
||||
int16_t ms[2];
|
||||
ms[0] = sample[0];
|
||||
ms[1] = sample[1];
|
||||
MakeSampleStereo16( ms );
|
||||
|
||||
// TODO: needs improvement (counting is different here with respect to ULP code)
|
||||
int currentSample = RTC_SLOW_MEM[indexAddress] & 0xffff;
|
||||
int currentWord = currentSample >> 1;
|
||||
|
||||
for (int i=0; i<2; i++) {
|
||||
ms[i] = ((ms[i] >> 8) + 128) & 0xff;
|
||||
}
|
||||
if(!stereoOutput) // mix both channels
|
||||
ms[0] = (uint16_t)(( (uint32_t)((int32_t)(ms[0]) + (int32_t)(ms[1])) >> 1 ) & 0xff);
|
||||
|
||||
if(waitingOddSample){ // always true for stereo because samples are consumed in pairs
|
||||
if(lastFilledWord != currentWord) // accept sample if writing index lastFilledWord has not reached index of output sample
|
||||
{
|
||||
unsigned int w;
|
||||
if(stereoOutput){
|
||||
w = ms[0];
|
||||
w |= ms[1] << 8;
|
||||
} else {
|
||||
w = bufferedOddSample;
|
||||
w |= ms[0] << 8;
|
||||
bufferedOddSample = 128;
|
||||
waitingOddSample = false;
|
||||
}
|
||||
RTC_SLOW_MEM[bufferStart + lastFilledWord] = w;
|
||||
lastFilledWord++;
|
||||
if(lastFilledWord == totalSampleWords)
|
||||
lastFilledWord = 0;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
bufferedOddSample = ms[0];
|
||||
waitingOddSample = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool AudioOutputULP::stop()
|
||||
{
|
||||
audioLogger->printf_P(PSTR("\n\n\nstop\n\n\n"));
|
||||
const ulp_insn_t stopulp[] = {
|
||||
//stop the timer
|
||||
I_END(),
|
||||
//end the program
|
||||
I_HALT()};
|
||||
|
||||
size_t load_addr = 0;
|
||||
size_t size = sizeof(stopulp)/sizeof(ulp_insn_t);
|
||||
ulp_process_macros_and_load(load_addr, stopulp, &size);
|
||||
|
||||
//start
|
||||
ulp_run(0);
|
||||
|
||||
if(activeDACs & 1){
|
||||
dac_output_voltage(DAC_CHANNEL_1, 128);
|
||||
}
|
||||
if(activeDACs & 2){
|
||||
dac_output_voltage(DAC_CHANNEL_2, 128);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
AudioOutputULP
|
||||
Outputs to ESP32 DAC through the ULP, freeing I2S for other uses
|
||||
|
||||
Copyright (C) 2020 Martin Laclaustra, based on bitluni's code
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Instructions:
|
||||
// AudioOutputULP out = new AudioOutputULP(); // stereo
|
||||
// Connect left channel on pin 25
|
||||
// Connect right channel on pin 26
|
||||
// OR
|
||||
// Connect mono channel on either of them (stereo samples are downmixed)
|
||||
// AudioOutputULP out = new AudioOutputULP(1); // mono, only DAC 1
|
||||
// OR
|
||||
// AudioOutputULP out = new AudioOutputULP(2); // mono, only DAC 2
|
||||
|
||||
|
||||
#ifndef _AUDIOOUTPUTULP_H
|
||||
#define _AUDIOOUTPUTULP_H
|
||||
|
||||
#include "AudioOutput.h"
|
||||
|
||||
#ifdef ESP32
|
||||
|
||||
class AudioOutputULP : public AudioOutput
|
||||
{
|
||||
public:
|
||||
AudioOutputULP(int argActiveDACs=3) {if(argActiveDACs<1||argActiveDACs>2)argActiveDACs=3;activeDACs=argActiveDACs;stereoOutput=activeDACs==3;};
|
||||
~AudioOutputULP() {};
|
||||
virtual bool begin() override;
|
||||
virtual bool ConsumeSample(int16_t sample[2]) override;
|
||||
virtual bool stop() override;
|
||||
enum : int { DAC1 = 1, DAC2 = 2 };
|
||||
private:
|
||||
int lastFilledWord = 0;
|
||||
uint8_t bufferedOddSample = 128;
|
||||
bool waitingOddSample = true; // must be set to false for mono output
|
||||
int activeDACs = 3; // 1:DAC1; 2:DAC2; 3:both;
|
||||
bool stereoOutput = true;
|
||||
const int opcodeCount = 20;
|
||||
const uint32_t dacTableStart1 = 2048 - 512;
|
||||
const uint32_t dacTableStart2 = dacTableStart1 - 512;
|
||||
uint32_t totalSampleWords = 2048 - 512 - 512 - (opcodeCount + 1); // add 512 for mono
|
||||
const int totalSamples = totalSampleWords * 2;
|
||||
const uint32_t indexAddress = opcodeCount;
|
||||
const uint32_t bufferStart = indexAddress + 1;
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
#error Only the ESP32 supports ULP audio output
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,51 @@
|
||||
// Lazy "include all the things" header for simplicity.
|
||||
// In general a user should only include the specific headers they need
|
||||
// to miniimize build times.
|
||||
|
||||
// Input stage
|
||||
#include "AudioFileSourceBuffer.h"
|
||||
#include "AudioFileSourceFATFS.h"
|
||||
#include "AudioFileSourceFS.h"
|
||||
#include "AudioFileSource.h"
|
||||
#include "AudioFileSourceHTTPStream.h"
|
||||
#include "AudioFileSourceICYStream.h"
|
||||
#include "AudioFileSourceID3.h"
|
||||
#include "AudioFileSourceLittleFS.h"
|
||||
#include "AudioFileSourcePROGMEM.h"
|
||||
#include "AudioFileSourceSD.h"
|
||||
#include "AudioFileSourceSPIFFS.h"
|
||||
#include "AudioFileSourceSPIRAMBuffer.h"
|
||||
#include "AudioFileSourceSTDIO.h"
|
||||
|
||||
// Misc. plumbing
|
||||
#include "AudioFileStream.h"
|
||||
#include "AudioLogger.h"
|
||||
#include "AudioStatus.h"
|
||||
|
||||
// Actual decode/audio generation logic
|
||||
#include "AudioGeneratorAAC.h"
|
||||
#include "AudioGeneratorFLAC.h"
|
||||
#include "AudioGenerator.h"
|
||||
#include "AudioGeneratorMIDI.h"
|
||||
#include "AudioGeneratorMOD.h"
|
||||
#include "AudioGeneratorMP3a.h"
|
||||
#include "AudioGeneratorMP3.h"
|
||||
#include "AudioGeneratorOpus.h"
|
||||
#include "AudioGeneratorRTTTL.h"
|
||||
#include "AudioGeneratorTalkie.h"
|
||||
#include "AudioGeneratorWAV.h"
|
||||
|
||||
// Render(output) sounds
|
||||
#include "AudioOutputBuffer.h"
|
||||
#include "AudioOutputFilterDecimate.h"
|
||||
#include "AudioOutput.h"
|
||||
#include "AudioOutputI2S.h"
|
||||
#include "AudioOutputI2SNoDAC.h"
|
||||
#include "AudioOutputPWM.h"
|
||||
#include "AudioOutputMixer.h"
|
||||
#include "AudioOutputNull.h"
|
||||
#include "AudioOutputSerialWAV.h"
|
||||
#include "AudioOutputSPDIF.h"
|
||||
#include "AudioOutputSPIFFSWAV.h"
|
||||
#include "AudioOutputSTDIO.h"
|
||||
#include "AudioOutputULP.h"
|
||||
@@ -3,7 +3,7 @@
|
||||
ESP8266Audio I2S Minimal driver
|
||||
|
||||
Most of this code is taken and reworked from ESP8266 Arduino core,
|
||||
which itsef is reworked from Espessif's I2S examples.
|
||||
which itself is reworked from Espessif's I2S examples.
|
||||
Original code is licensed under LGPL 2.1 or above
|
||||
|
||||
Reasons for rewrite:
|
||||
@@ -196,7 +196,7 @@ void SinglePinI2SDriver::setDividers(uint8_t div1, uint8_t div2)
|
||||
// Ensure dividers fit in bit fields
|
||||
div1 &= I2SBDM;
|
||||
div2 &= I2SCDM;
|
||||
// trans master(active low), recv master(active_low), !bits mod(==16 bits/chanel), clear clock dividers
|
||||
// trans master(active low), recv master(active_low), !bits mod(==16 bits/channel), clear clock dividers
|
||||
I2SC &= ~(I2STSM | I2SRSM | (I2SBMM << I2SBM) | (I2SBDM << I2SBD) | (I2SCDM << I2SCD));
|
||||
// I2SRF = Send/recv right channel first
|
||||
// I2SMR = MSB recv/xmit first
|
||||
@@ -249,7 +249,7 @@ void SinglePinI2SDriver::startI2S()
|
||||
I2SFC |= I2SDE; // Enable DMA
|
||||
// I2STXCMM, I2SRXCMM=0 => Dual channel mode, RX/TX CHAN_MOD=0
|
||||
I2SCC &= ~((I2STXCMM << I2STXCM) | (I2SRXCMM << I2SRXCM));
|
||||
// Set dividers to something resonable
|
||||
// Set dividers to something reasonable
|
||||
currentRate = 0;
|
||||
setRate(44100);
|
||||
// Start I2S peripheral
|
||||
@@ -280,4 +280,4 @@ int SinglePinI2SDriver::getUnderflowCount()
|
||||
// Global instance
|
||||
SinglePinI2SDriver I2SDriver;
|
||||
|
||||
#endif // defined(ESP8266)
|
||||
#endif // defined(ESP8266)
|
||||
@@ -121,6 +121,8 @@ struct FLAC__BitReader {
|
||||
void *client_data;
|
||||
};
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||
static inline void crc16_update_word_(FLAC__BitReader *br, brword word)
|
||||
{
|
||||
unsigned crc = br->read_crc16;
|
||||
@@ -149,6 +151,7 @@ static inline void crc16_update_word_(FLAC__BitReader *br, brword word)
|
||||
#endif
|
||||
br->crc16_align = 0;
|
||||
}
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
static FLAC__bool bitreader_read_from_client_(FLAC__BitReader *br)
|
||||
{
|
||||
@@ -338,6 +341,8 @@ void FLAC__bitreader_reset_read_crc16(FLAC__BitReader *br, FLAC__uint16 seed)
|
||||
br->crc16_align = br->consumed_bits;
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||
FLAC__uint16 FLAC__bitreader_get_read_crc16(FLAC__BitReader *br)
|
||||
{
|
||||
FLAC__ASSERT(0 != br);
|
||||
@@ -353,6 +358,7 @@ FLAC__uint16 FLAC__bitreader_get_read_crc16(FLAC__BitReader *br)
|
||||
}
|
||||
return br->read_crc16;
|
||||
}
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
inline FLAC__bool FLAC__bitreader_is_consumed_byte_aligned(const FLAC__BitReader *br)
|
||||
{
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
//#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
# include "config.h"
|
||||
//#endif
|
||||
|
||||
#include "private/cpu.h"
|
||||
|
||||
+3
-1
@@ -136,7 +136,8 @@ FLAC__uint8 FLAC__crc8(const FLAC__byte *data, unsigned len)
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||
unsigned FLAC__crc16(const FLAC__byte *data, unsigned len)
|
||||
{
|
||||
unsigned crc = 0;
|
||||
@@ -146,3 +147,4 @@ unsigned FLAC__crc16(const FLAC__byte *data, unsigned len)
|
||||
|
||||
return crc;
|
||||
}
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -35,7 +35,7 @@
|
||||
* print an error message if it fails (ie returns a value < 0).
|
||||
*
|
||||
* Ideally, a library should not print anything, but this macro is only used
|
||||
* for things that extremely unlikely to fail, like `chown` to a previoulsy
|
||||
* for things that extremely unlikely to fail, like `chown` to a previously
|
||||
* saved `uid`.
|
||||
*/
|
||||
|
||||
|
||||
@@ -2021,6 +2021,8 @@ FLAC__bool frame_sync_(FLAC__StreamDecoder *decoder)
|
||||
return true;
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||
FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FLAC__bool do_full_decode)
|
||||
{
|
||||
uint32_t channel;
|
||||
@@ -2167,6 +2169,7 @@ FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FL
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
|
||||
return true;
|
||||
}
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
FLAC__bool read_frame_header_(FLAC__StreamDecoder *decoder)
|
||||
{
|
||||
@@ -2196,14 +2199,14 @@ FLAC__bool read_frame_header_(FLAC__StreamDecoder *decoder)
|
||||
* Three kinds of things can go wrong when reading the frame header:
|
||||
* 1) We may have sync'ed incorrectly and not landed on a frame header.
|
||||
* If we don't find a sync code, it can end up looking like we read
|
||||
* a valid but unparseable header, until getting to the frame header
|
||||
* a valid but unparsable header, until getting to the frame header
|
||||
* CRC. Even then we could get a false positive on the CRC.
|
||||
* 2) We may have sync'ed correctly but on an unparseable frame (from a
|
||||
* 2) We may have sync'ed correctly but on an unparsable frame (from a
|
||||
* future encoder).
|
||||
* 3) We may be on a damaged frame which appears valid but unparseable.
|
||||
* 3) We may be on a damaged frame which appears valid but unparsable.
|
||||
*
|
||||
* For all these reasons, we try and read a complete frame header as
|
||||
* long as it seems valid, even if unparseable, up until the frame
|
||||
* long as it seems valid, even if unparsable, up until the frame
|
||||
* header CRC.
|
||||
*/
|
||||
|
||||
@@ -2780,7 +2783,7 @@ FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, uint32_
|
||||
if(rice_parameter < pesc) {
|
||||
partitioned_rice_contents->raw_bits[partition] = 0;
|
||||
u = (partition_order == 0 || partition > 0)? partition_samples : partition_samples - predictor_order;
|
||||
if(!FLAC__bitreader_read_rice_signed_block(decoder->private_->input, residual + sample, u, rice_parameter))
|
||||
if(!FLAC__bitreader_read_rice_signed_block(decoder->private_->input, (int *)(residual + sample), u, rice_parameter))
|
||||
return false; /* read_callback_ sets the state for us */
|
||||
sample += u;
|
||||
}
|
||||
@@ -2789,7 +2792,7 @@ FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, uint32_
|
||||
return false; /* read_callback_ sets the state for us */
|
||||
partitioned_rice_contents->raw_bits[partition] = rice_parameter;
|
||||
for(u = (partition_order == 0 || partition > 0)? 0 : predictor_order; u < partition_samples; u++, sample++) {
|
||||
if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i, rice_parameter))
|
||||
if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, (FLAC__int32 *)&i, rice_parameter))
|
||||
return false; /* read_callback_ sets the state for us */
|
||||
residual[sample] = i;
|
||||
}
|
||||
@@ -2836,7 +2839,7 @@ FLAC__bool read_callback_(FLAC__byte buffer[], size_t *bytes, void *client_data)
|
||||
* FLAC__STREAM_DECODER_UNPARSEABLE_STREAM and increment its
|
||||
* unparseable_frame_count. But there is a remote possibility
|
||||
* that it is properly synced at such a "future-codec frame",
|
||||
* so to make sure, we wait to see many "unparseable" errors in
|
||||
* so to make sure, we wait to see many "unparsable" errors in
|
||||
* a row before bailing out.
|
||||
*/
|
||||
if(decoder->private_->is_seeking && decoder->private_->unparseable_frame_count > 20) {
|
||||
@@ -3143,7 +3146,7 @@ FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 s
|
||||
return false;
|
||||
}
|
||||
/* Now we need to get a frame. First we need to reset our
|
||||
* unparseable_frame_count; if we get too many unparseable
|
||||
* unparseable_frame_count; if we get too many unparsable
|
||||
* frames in a row, the read callback will return
|
||||
* FLAC__STREAM_DECODER_READ_STATUS_ABORT, causing
|
||||
* FLAC__stream_decoder_process_single() to return false.
|
||||
|
||||
@@ -223,7 +223,7 @@ Word64 MADD64(Word64 sum64, int x, int y);
|
||||
/* toolchain: ARM ADS or RealView
|
||||
* target architecture: ARM v.4 and above (requires 'M' type processor for 32x32->64 multiplier)
|
||||
*/
|
||||
#elif defined (__arm) && defined (__ARMCC_VERSION)
|
||||
#elif defined (XXX__arm) && defined (__ARMCC_VERSION)
|
||||
|
||||
static __inline int MULSHIFT32(int x, int y)
|
||||
{
|
||||
@@ -336,7 +336,7 @@ static __inline Word64 MADD64(Word64 sum64, int x, int y)
|
||||
/* toolchain: ARM gcc
|
||||
* target architecture: ARM v.4 and above (requires 'M' type processor for 32x32->64 multiplier)
|
||||
*/
|
||||
#elif defined(__GNUC__) && defined(__arm__)
|
||||
#elif defined(__GNUC__) && defined(XXXX__arm__)
|
||||
|
||||
static inline int MULSHIFT32(int x, int y)
|
||||
{
|
||||
@@ -558,14 +558,8 @@ static __inline int CLZ(int x)
|
||||
typedef union _U64 {
|
||||
Word64 w64;
|
||||
struct {
|
||||
#ifdef __XTENSA__
|
||||
unsigned int lo32;
|
||||
signed int hi32;
|
||||
#else
|
||||
/* PowerPC = big endian */
|
||||
signed int hi32;
|
||||
unsigned int lo32;
|
||||
#endif
|
||||
} r;
|
||||
} U64;
|
||||
|
||||
|
||||
@@ -258,10 +258,10 @@ int DecodeProgramConfigElement(ProgConfigElement *pce, BitStreamInfo *bsi)
|
||||
pce->bce[i] |= GetBits(bsi, 4); /* tag select */
|
||||
}
|
||||
|
||||
for (i = 0; i < pce->numLCE; i++)
|
||||
for (i = 0; i < pce->numLCE && i < MAX_NUM_LCE; i++)
|
||||
pce->lce[i] = GetBits(bsi, 4); /* tag select */
|
||||
|
||||
for (i = 0; i < pce->numADE; i++)
|
||||
for (i = 0; i < pce->numADE && i < MAX_NUM_ADE; i++)
|
||||
pce->ade[i] = GetBits(bsi, 4); /* tag select */
|
||||
|
||||
for (i = 0; i < pce->numCCE; i++) {
|
||||
|
||||
@@ -253,7 +253,7 @@ static int DecodeOneScaleFactor(BitStreamInfo *bsi)
|
||||
|
||||
pi->numPulse = GetBits(bsi, 2) + 1; /* add 1 here */
|
||||
pi->startSFB = GetBits(bsi, 6);
|
||||
for (i = 0; i < pi->numPulse; i++) {
|
||||
for (i = 0; i < pi->numPulse && i < MAX_PULSES; i++) {
|
||||
pi->offset[i] = GetBits(bsi, 5);
|
||||
pi->amp[i] = GetBits(bsi, 4);
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
**************************************************************************************/
|
||||
|
||||
#if defined(USE_DEFAULT_STDLIB) || defined(ARDUINO)
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
#include "hlxclib/stdlib.h"
|
||||
|
||||
@@ -76,7 +76,7 @@ static const int newBWTab[4][4] PROGMEM = {
|
||||
* Notes: this is carefully written to be efficient on ARM
|
||||
* use the assembly code version in sbrcov.s when building for ARM!
|
||||
**************************************************************************************/
|
||||
#if (defined (__arm) && defined (__ARMCC_VERSION)) || (defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM)) || (defined(__GNUC__) && defined(__arm__))
|
||||
#if (defined (XXXX__arm) && defined (__ARMCC_VERSION)) || (defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM)) || (defined(__GNUC__) && defined(XXXX__arm__))
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
@@ -237,7 +237,7 @@ static int CalcCovariance1(int *XBuf, int *p01reN, int *p01imN, int *p12reN, int
|
||||
* Notes: this is carefully written to be efficient on ARM
|
||||
* use the assembly code version in sbrcov.s when building for ARM!
|
||||
**************************************************************************************/
|
||||
#if (defined (__arm) && defined (__ARMCC_VERSION)) || (defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM)) || (defined(__GNUC__) && defined(__arm__))
|
||||
#if (defined (XXXX__arm) && defined (__ARMCC_VERSION)) || (defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM)) || (defined(__GNUC__) && defined(XXXX__arm__))
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
|
||||
@@ -222,7 +222,8 @@ static void PostMultiply64(int *fft1, int nSampsOut)
|
||||
* Notes: this is carefully written to be efficient on ARM
|
||||
* use the assembly code version in sbrqmfak.s when building for ARM!
|
||||
**************************************************************************************/
|
||||
#if (defined (__arm) && defined (__ARMCC_VERSION)) || (defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM)) || (defined(__GNUC__) && defined(__arm__))
|
||||
//TODO - ADD IN .S SOURCES SOMEHOW
|
||||
#if 0 //(defined (__arm) && defined (__ARMCC_VERSION)) || (defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM)) || (defined(__GNUC__) && defined(__arm__))
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
@@ -395,7 +396,7 @@ int QMFAnalysis(int *inbuf, int *delay, int *XBuf, int fBitsIn, int *delayIdx, i
|
||||
* Notes: this is carefully written to be efficient on ARM
|
||||
* use the assembly code version in sbrqmfsk.s when building for ARM!
|
||||
**************************************************************************************/
|
||||
#if (defined (__arm) && defined (__ARMCC_VERSION)) || (defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM)) || (defined(__GNUC__) && defined(__arm__))
|
||||
#if 0 //(defined (__arm) && defined (__ARMCC_VERSION)) || (defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM)) || (defined(__GNUC__) && defined(__arm__))
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
|
||||
@@ -195,7 +195,7 @@ static void UnpackSBRGrid(BitStreamInfo *bsi, SBRHeader *sbrHdr, SBRGrid *sbrGri
|
||||
absBorder = GetBits(bsi, 2) + NUM_TIME_SLOTS;
|
||||
numRelBorder = GetBits(bsi, 2);
|
||||
sbrGrid->numEnv = numRelBorder + 1;
|
||||
for (rel = 0; rel < numRelBorder; rel++)
|
||||
for (rel = 0; rel < numRelBorder && rel < 3; rel++)
|
||||
relBorder[rel] = 2*GetBits(bsi, 2) + 2;
|
||||
|
||||
pBits = cLog2[sbrGrid->numEnv + 1];
|
||||
@@ -221,13 +221,13 @@ static void UnpackSBRGrid(BitStreamInfo *bsi, SBRHeader *sbrHdr, SBRGrid *sbrGri
|
||||
absBorder = GetBits(bsi, 2);
|
||||
numRelBorder = GetBits(bsi, 2);
|
||||
sbrGrid->numEnv = numRelBorder + 1;
|
||||
for (rel = 0; rel < numRelBorder; rel++)
|
||||
for (rel = 0; rel < numRelBorder && rel < 3; rel++)
|
||||
relBorder[rel] = 2*GetBits(bsi, 2) + 2;
|
||||
|
||||
pBits = cLog2[sbrGrid->numEnv + 1];
|
||||
sbrGrid->pointer = GetBits(bsi, pBits);
|
||||
|
||||
for (env = 0; env < sbrGrid->numEnv; env++)
|
||||
for (env = 0; env < sbrGrid->numEnv && env < MAX_NUM_ENV; env++)
|
||||
sbrGrid->freqRes[env] = GetBits(bsi, 1);
|
||||
|
||||
absBordLead = absBorder;
|
||||
@@ -253,16 +253,16 @@ static void UnpackSBRGrid(BitStreamInfo *bsi, SBRHeader *sbrHdr, SBRGrid *sbrGri
|
||||
sbrGrid->numEnv = numRelBorder0 + numRelBorder1 + 1;
|
||||
ASSERT(sbrGrid->numEnv <= 5);
|
||||
|
||||
for (rel = 0; rel < numRelBorder0; rel++)
|
||||
for (rel = 0; rel < numRelBorder0 && rel < 3; rel++)
|
||||
relBorder0[rel] = 2*GetBits(bsi, 2) + 2;
|
||||
|
||||
for (rel = 0; rel < numRelBorder1; rel++)
|
||||
for (rel = 0; rel < numRelBorder1 && rel < 3; rel++)
|
||||
relBorder1[rel] = 2*GetBits(bsi, 2) + 2;
|
||||
|
||||
pBits = cLog2[numRelBorder0 + numRelBorder1 + 2];
|
||||
sbrGrid->pointer = GetBits(bsi, pBits);
|
||||
|
||||
for (env = 0; env < sbrGrid->numEnv; env++)
|
||||
for (env = 0; env < sbrGrid->numEnv && env < MAX_NUM_ENV; env++)
|
||||
sbrGrid->freqRes[env] = GetBits(bsi, 1);
|
||||
|
||||
numRelLead = numRelBorder0;
|
||||
|
||||
@@ -801,7 +801,7 @@ REQUIRED IN ALL CASES
|
||||
Notice to be included in header file of all Error Corrections and Shared
|
||||
Modifications:
|
||||
|
||||
Portions Copyright 1994-2003 © RealNetworks, Inc. All rights reserved.
|
||||
Portions Copyright 1994-2003 (c) RealNetworks, Inc. All rights reserved.
|
||||
|
||||
The contents of this file, and the files included with this file, are
|
||||
subject to the current version of RealNetworks Community Source License
|
||||
|
||||
@@ -201,7 +201,7 @@ and 3, above.
|
||||
4.2 Compatible Source Licenses. Software modules that have been independently
|
||||
developed without any use of Covered Code and which contain no portion of the
|
||||
Covered Code, Modifications or other Derivative Works, but are used or combined
|
||||
in any way wtih the Covered Code or any Derivative Work to form a larger
|
||||
in any way with the Covered Code or any Derivative Work to form a larger
|
||||
Derivative Work, are exempt from the conditions described in Section 4.1 but
|
||||
only to the extent that: the software module, including any software that is
|
||||
linked to, integrated with, or part of the same applications as, the software
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
*
|
||||
* assembly.h - assembly language functions and prototypes for supported platforms
|
||||
*
|
||||
* - inline rountines with access to 64-bit multiply results
|
||||
* - inline routines with access to 64-bit multiply results
|
||||
* - x86 (_WIN32) and ARM (ARM_ADS, _WIN32_WCE) versions included
|
||||
* - some inline functions are mix of asm and C for speed
|
||||
* - some functions are in native asm files, so only the prototype is given here
|
||||
@@ -217,7 +217,7 @@ static __inline int CLZ(int x)
|
||||
return numZeros;
|
||||
}
|
||||
|
||||
#elif defined ARM_ADS
|
||||
#elif defined XXXARM_ADS
|
||||
|
||||
static __inline int MULSHIFT32(int x, int y)
|
||||
{
|
||||
@@ -241,7 +241,7 @@ static __inline int MULSHIFT32(int x, int y)
|
||||
|
||||
static __inline int FASTABS(int x)
|
||||
{
|
||||
int t=0; /*Really is not necessary to initialiaze only to avoid warning*/
|
||||
int t=0; /*Really is not necessary to initialize only to avoid warning*/
|
||||
|
||||
__asm {
|
||||
eor t, x, x, asr #31
|
||||
@@ -267,7 +267,7 @@ static __inline int CLZ(int x)
|
||||
return numZeros;
|
||||
}
|
||||
|
||||
#elif defined(__GNUC__) && defined(__thumb__)
|
||||
#elif defined(__GNUC__) && defined(XXXX__thumb__)
|
||||
|
||||
|
||||
static __inline int MULSHIFT32(int x, int y)
|
||||
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
// return.
|
||||
// pPCM pointer to a buffer to decode into
|
||||
// pulPCMSize size of the PCM buffer. It will contain the
|
||||
// number of PCM bytes prodced upon return.
|
||||
// number of PCM bytes produced upon return.
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
void DecodeFrame_v(unsigned char *pSource,
|
||||
unsigned long *pulSize,
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
* (see comment on Dequantize() for more info)
|
||||
*/
|
||||
#define DEF_NFRACBITS (DQ_FRACBITS_OUT - 2 - 2 - 15)
|
||||
#define CSHIFT 12 /* coefficients have 12 leading sign bits for early-terminating mulitplies */
|
||||
#define CSHIFT 12 /* coefficients have 12 leading sign bits for early-terminating multiplies */
|
||||
|
||||
static __inline short ClipToShort(int x, int fracBits)
|
||||
{
|
||||
|
||||
@@ -74,7 +74,7 @@ static const char SFLenTab[16][2] = {
|
||||
* Return: none
|
||||
*
|
||||
* Notes: set order of short blocks to s[band][window] instead of s[window][band]
|
||||
* so that we index through consectutive memory locations when unpacking
|
||||
* so that we index through consecutive memory locations when unpacking
|
||||
* (make sure dequantizer follows same convention)
|
||||
* Illegal Intensity Position = 7 (always) for MPEG1 scale factors
|
||||
**************************************************************************************/
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
# endif
|
||||
|
||||
# if !defined(HAVE_ASSERT_H)
|
||||
# undef assert
|
||||
# if defined(NDEBUG)
|
||||
# define assert(x) /* nothing */
|
||||
# else
|
||||
|
||||
+75
-71
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#pragma GCC optimize ("O3")
|
||||
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||
|
||||
#include <pgmspace.h>
|
||||
# include "config.h"
|
||||
@@ -351,19 +352,19 @@ struct fixedfloat {
|
||||
|
||||
root_table[3 + x] = 2^(x/4)
|
||||
*/
|
||||
static mad_fixed_t const root_table_val[7] PROGMEM = {
|
||||
MAD_F(0x09837f05) /* 2^(-3/4) == 0.59460355750136 */,
|
||||
MAD_F(0x0b504f33) /* 2^(-2/4) == 0.70710678118655 */,
|
||||
MAD_F(0x0d744fcd) /* 2^(-1/4) == 0.84089641525371 */,
|
||||
MAD_F(0x10000000) /* 2^( 0/4) == 1.00000000000000 */,
|
||||
MAD_F(0x1306fe0a) /* 2^(+1/4) == 1.18920711500272 */,
|
||||
MAD_F(0x16a09e66) /* 2^(+2/4) == 1.41421356237310 */,
|
||||
MAD_F(0x1ae89f99) /* 2^(+3/4) == 1.68179283050743 */
|
||||
};
|
||||
static inline mad_fixed_t root_table(int i)
|
||||
{
|
||||
static mad_fixed_t const root_table_val[7] PROGMEM = {
|
||||
MAD_F(0x09837f05) /* 2^(-3/4) == 0.59460355750136 */,
|
||||
MAD_F(0x0b504f33) /* 2^(-2/4) == 0.70710678118655 */,
|
||||
MAD_F(0x0d744fcd) /* 2^(-1/4) == 0.84089641525371 */,
|
||||
MAD_F(0x10000000) /* 2^( 0/4) == 1.00000000000000 */,
|
||||
MAD_F(0x1306fe0a) /* 2^(+1/4) == 1.18920711500272 */,
|
||||
MAD_F(0x16a09e66) /* 2^(+2/4) == 1.41421356237310 */,
|
||||
MAD_F(0x1ae89f99) /* 2^(+3/4) == 1.68179283050743 */
|
||||
};
|
||||
volatile uint32_t a = *(uint32_t*)&root_table_val[i];
|
||||
return *(mad_fixed_t*)&a;
|
||||
volatile mad_fixed_t a = root_table_val[i];
|
||||
return a;
|
||||
}
|
||||
/*
|
||||
coefficients for aliasing reduction
|
||||
@@ -373,28 +374,28 @@ static inline mad_fixed_t root_table(int i)
|
||||
cs[i] = 1 / sqrt(1 + c[i]^2)
|
||||
ca[i] = c[i] / sqrt(1 + c[i]^2)
|
||||
*/
|
||||
static mad_fixed_t const cs_val[8] PROGMEM = {
|
||||
+MAD_F(0x0db84a81) /* +0.857492926 */, +MAD_F(0x0e1b9d7f) /* +0.881741997 */,
|
||||
+MAD_F(0x0f31adcf) /* +0.949628649 */, +MAD_F(0x0fbba815) /* +0.983314592 */,
|
||||
+MAD_F(0x0feda417) /* +0.995517816 */, +MAD_F(0x0ffc8fc8) /* +0.999160558 */,
|
||||
+MAD_F(0x0fff964c) /* +0.999899195 */, +MAD_F(0x0ffff8d3) /* +0.999993155 */
|
||||
};
|
||||
static inline mad_fixed_t cs(int i)
|
||||
{
|
||||
static mad_fixed_t const cs_val[8] PROGMEM = {
|
||||
+MAD_F(0x0db84a81) /* +0.857492926 */, +MAD_F(0x0e1b9d7f) /* +0.881741997 */,
|
||||
+MAD_F(0x0f31adcf) /* +0.949628649 */, +MAD_F(0x0fbba815) /* +0.983314592 */,
|
||||
+MAD_F(0x0feda417) /* +0.995517816 */, +MAD_F(0x0ffc8fc8) /* +0.999160558 */,
|
||||
+MAD_F(0x0fff964c) /* +0.999899195 */, +MAD_F(0x0ffff8d3) /* +0.999993155 */
|
||||
};
|
||||
volatile uint32_t a = *(uint32_t*)&cs_val[i];
|
||||
return *(mad_fixed_t*)&a;
|
||||
volatile mad_fixed_t a = cs_val[i];
|
||||
return a;
|
||||
}
|
||||
|
||||
static mad_fixed_t const ca_val[8] PROGMEM = {
|
||||
-MAD_F(0x083b5fe7) /* -0.514495755 */, -MAD_F(0x078c36d2) /* -0.471731969 */,
|
||||
-MAD_F(0x05039814) /* -0.313377454 */, -MAD_F(0x02e91dd1) /* -0.181913200 */,
|
||||
-MAD_F(0x0183603a) /* -0.094574193 */, -MAD_F(0x00a7cb87) /* -0.040965583 */,
|
||||
-MAD_F(0x003a2847) /* -0.014198569 */, -MAD_F(0x000f27b4) /* -0.003699975 */
|
||||
};
|
||||
static inline mad_fixed_t ca(int i)
|
||||
{
|
||||
static mad_fixed_t const ca_val[8] PROGMEM = {
|
||||
-MAD_F(0x083b5fe7) /* -0.514495755 */, -MAD_F(0x078c36d2) /* -0.471731969 */,
|
||||
-MAD_F(0x05039814) /* -0.313377454 */, -MAD_F(0x02e91dd1) /* -0.181913200 */,
|
||||
-MAD_F(0x0183603a) /* -0.094574193 */, -MAD_F(0x00a7cb87) /* -0.040965583 */,
|
||||
-MAD_F(0x003a2847) /* -0.014198569 */, -MAD_F(0x000f27b4) /* -0.003699975 */
|
||||
};
|
||||
volatile uint32_t a = *(uint32_t*)&ca_val[i];
|
||||
return *(mad_fixed_t*)&a;
|
||||
volatile mad_fixed_t a = ca_val[i];
|
||||
return a;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -416,31 +417,31 @@ mad_fixed_t const imdct_s[6][6] PROGMEM = {
|
||||
|
||||
window_l[i] = sin((PI / 36) * (i + 1/2))
|
||||
*/
|
||||
static mad_fixed_t const window_l_val[36] PROGMEM = {
|
||||
MAD_F(0x00b2aa3e) /* 0.043619387 */, MAD_F(0x0216a2a2) /* 0.130526192 */,
|
||||
MAD_F(0x03768962) /* 0.216439614 */, MAD_F(0x04cfb0e2) /* 0.300705800 */,
|
||||
MAD_F(0x061f78aa) /* 0.382683432 */, MAD_F(0x07635284) /* 0.461748613 */,
|
||||
MAD_F(0x0898c779) /* 0.537299608 */, MAD_F(0x09bd7ca0) /* 0.608761429 */,
|
||||
MAD_F(0x0acf37ad) /* 0.675590208 */, MAD_F(0x0bcbe352) /* 0.737277337 */,
|
||||
MAD_F(0x0cb19346) /* 0.793353340 */, MAD_F(0x0d7e8807) /* 0.843391446 */,
|
||||
|
||||
MAD_F(0x0e313245) /* 0.887010833 */, MAD_F(0x0ec835e8) /* 0.923879533 */,
|
||||
MAD_F(0x0f426cb5) /* 0.953716951 */, MAD_F(0x0f9ee890) /* 0.976296007 */,
|
||||
MAD_F(0x0fdcf549) /* 0.991444861 */, MAD_F(0x0ffc19fd) /* 0.999048222 */,
|
||||
MAD_F(0x0ffc19fd) /* 0.999048222 */, MAD_F(0x0fdcf549) /* 0.991444861 */,
|
||||
MAD_F(0x0f9ee890) /* 0.976296007 */, MAD_F(0x0f426cb5) /* 0.953716951 */,
|
||||
MAD_F(0x0ec835e8) /* 0.923879533 */, MAD_F(0x0e313245) /* 0.887010833 */,
|
||||
|
||||
MAD_F(0x0d7e8807) /* 0.843391446 */, MAD_F(0x0cb19346) /* 0.793353340 */,
|
||||
MAD_F(0x0bcbe352) /* 0.737277337 */, MAD_F(0x0acf37ad) /* 0.675590208 */,
|
||||
MAD_F(0x09bd7ca0) /* 0.608761429 */, MAD_F(0x0898c779) /* 0.537299608 */,
|
||||
MAD_F(0x07635284) /* 0.461748613 */, MAD_F(0x061f78aa) /* 0.382683432 */,
|
||||
MAD_F(0x04cfb0e2) /* 0.300705800 */, MAD_F(0x03768962) /* 0.216439614 */,
|
||||
MAD_F(0x0216a2a2) /* 0.130526192 */, MAD_F(0x00b2aa3e) /* 0.043619387 */,
|
||||
};
|
||||
static inline mad_fixed_t window_l(int i)
|
||||
{
|
||||
static mad_fixed_t const window_l_val[36] PROGMEM = {
|
||||
MAD_F(0x00b2aa3e) /* 0.043619387 */, MAD_F(0x0216a2a2) /* 0.130526192 */,
|
||||
MAD_F(0x03768962) /* 0.216439614 */, MAD_F(0x04cfb0e2) /* 0.300705800 */,
|
||||
MAD_F(0x061f78aa) /* 0.382683432 */, MAD_F(0x07635284) /* 0.461748613 */,
|
||||
MAD_F(0x0898c779) /* 0.537299608 */, MAD_F(0x09bd7ca0) /* 0.608761429 */,
|
||||
MAD_F(0x0acf37ad) /* 0.675590208 */, MAD_F(0x0bcbe352) /* 0.737277337 */,
|
||||
MAD_F(0x0cb19346) /* 0.793353340 */, MAD_F(0x0d7e8807) /* 0.843391446 */,
|
||||
|
||||
MAD_F(0x0e313245) /* 0.887010833 */, MAD_F(0x0ec835e8) /* 0.923879533 */,
|
||||
MAD_F(0x0f426cb5) /* 0.953716951 */, MAD_F(0x0f9ee890) /* 0.976296007 */,
|
||||
MAD_F(0x0fdcf549) /* 0.991444861 */, MAD_F(0x0ffc19fd) /* 0.999048222 */,
|
||||
MAD_F(0x0ffc19fd) /* 0.999048222 */, MAD_F(0x0fdcf549) /* 0.991444861 */,
|
||||
MAD_F(0x0f9ee890) /* 0.976296007 */, MAD_F(0x0f426cb5) /* 0.953716951 */,
|
||||
MAD_F(0x0ec835e8) /* 0.923879533 */, MAD_F(0x0e313245) /* 0.887010833 */,
|
||||
|
||||
MAD_F(0x0d7e8807) /* 0.843391446 */, MAD_F(0x0cb19346) /* 0.793353340 */,
|
||||
MAD_F(0x0bcbe352) /* 0.737277337 */, MAD_F(0x0acf37ad) /* 0.675590208 */,
|
||||
MAD_F(0x09bd7ca0) /* 0.608761429 */, MAD_F(0x0898c779) /* 0.537299608 */,
|
||||
MAD_F(0x07635284) /* 0.461748613 */, MAD_F(0x061f78aa) /* 0.382683432 */,
|
||||
MAD_F(0x04cfb0e2) /* 0.300705800 */, MAD_F(0x03768962) /* 0.216439614 */,
|
||||
MAD_F(0x0216a2a2) /* 0.130526192 */, MAD_F(0x00b2aa3e) /* 0.043619387 */,
|
||||
};
|
||||
volatile uint32_t a = *(uint32_t*)&window_l_val[i];
|
||||
volatile mad_fixed_t a = window_l_val[i];
|
||||
return *(mad_fixed_t*)&a;
|
||||
}
|
||||
# endif /* ASO_IMDCT */
|
||||
@@ -451,18 +452,18 @@ static inline mad_fixed_t window_l(int i)
|
||||
|
||||
window_s[i] = sin((PI / 12) * (i + 1/2))
|
||||
*/
|
||||
static mad_fixed_t const window_s_val[12] PROGMEM = {
|
||||
MAD_F(0x0216a2a2) /* 0.130526192 */, MAD_F(0x061f78aa) /* 0.382683432 */,
|
||||
MAD_F(0x09bd7ca0) /* 0.608761429 */, MAD_F(0x0cb19346) /* 0.793353340 */,
|
||||
MAD_F(0x0ec835e8) /* 0.923879533 */, MAD_F(0x0fdcf549) /* 0.991444861 */,
|
||||
MAD_F(0x0fdcf549) /* 0.991444861 */, MAD_F(0x0ec835e8) /* 0.923879533 */,
|
||||
MAD_F(0x0cb19346) /* 0.793353340 */, MAD_F(0x09bd7ca0) /* 0.608761429 */,
|
||||
MAD_F(0x061f78aa) /* 0.382683432 */, MAD_F(0x0216a2a2) /* 0.130526192 */,
|
||||
};
|
||||
static inline mad_fixed_t window_s(int i)
|
||||
{
|
||||
static mad_fixed_t const window_s_val[12] PROGMEM = {
|
||||
MAD_F(0x0216a2a2) /* 0.130526192 */, MAD_F(0x061f78aa) /* 0.382683432 */,
|
||||
MAD_F(0x09bd7ca0) /* 0.608761429 */, MAD_F(0x0cb19346) /* 0.793353340 */,
|
||||
MAD_F(0x0ec835e8) /* 0.923879533 */, MAD_F(0x0fdcf549) /* 0.991444861 */,
|
||||
MAD_F(0x0fdcf549) /* 0.991444861 */, MAD_F(0x0ec835e8) /* 0.923879533 */,
|
||||
MAD_F(0x0cb19346) /* 0.793353340 */, MAD_F(0x09bd7ca0) /* 0.608761429 */,
|
||||
MAD_F(0x061f78aa) /* 0.382683432 */, MAD_F(0x0216a2a2) /* 0.130526192 */,
|
||||
};
|
||||
volatile uint32_t a = *(uint32_t*)&window_s_val[i];
|
||||
return *(mad_fixed_t*)&a;
|
||||
volatile mad_fixed_t a = window_s_val[i];
|
||||
return a;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -472,19 +473,19 @@ static inline mad_fixed_t window_s(int i)
|
||||
is_ratio[i] = tan(i * (PI / 12))
|
||||
is_table[i] = is_ratio[i] / (1 + is_ratio[i])
|
||||
*/
|
||||
static mad_fixed_t const is_table_val[7] PROGMEM = {
|
||||
MAD_F(0x00000000) /* 0.000000000 */,
|
||||
MAD_F(0x0361962f) /* 0.211324865 */,
|
||||
MAD_F(0x05db3d74) /* 0.366025404 */,
|
||||
MAD_F(0x08000000) /* 0.500000000 */,
|
||||
MAD_F(0x0a24c28c) /* 0.633974596 */,
|
||||
MAD_F(0x0c9e69d1) /* 0.788675135 */,
|
||||
MAD_F(0x10000000) /* 1.000000000 */
|
||||
};
|
||||
static inline mad_fixed_t is_table(int i)
|
||||
{
|
||||
static mad_fixed_t const is_table_val[7] PROGMEM = {
|
||||
MAD_F(0x00000000) /* 0.000000000 */,
|
||||
MAD_F(0x0361962f) /* 0.211324865 */,
|
||||
MAD_F(0x05db3d74) /* 0.366025404 */,
|
||||
MAD_F(0x08000000) /* 0.500000000 */,
|
||||
MAD_F(0x0a24c28c) /* 0.633974596 */,
|
||||
MAD_F(0x0c9e69d1) /* 0.788675135 */,
|
||||
MAD_F(0x10000000) /* 1.000000000 */
|
||||
};
|
||||
volatile uint32_t a = *(uint32_t*)&is_table_val[i];
|
||||
return *(mad_fixed_t*)&a;
|
||||
volatile mad_fixed_t a = is_table_val[i];
|
||||
return a;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1738,7 +1739,10 @@ void sdctII(mad_fixed_t const x[18], mad_fixed_t X[18])
|
||||
s = *(volatile mad_fixed_t*)(volatile uint32_t*)&scale[i + 2]; tmp[i + 2] = mad_f_mul(x[i + 2] - x[18 - (i + 2) - 1], s); //scale[i + 2]);
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wstringop-overflow"
|
||||
fastsdct(tmp, &X[1]);
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
/* output accumulation */
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
Monty <monty@xiph.org>
|
||||
Greg Maxwell <greg@xiph.org>
|
||||
Ralph Giles <giles@xiph.org>
|
||||
Cristian Adam <cristian.adam@gmail.com>
|
||||
Tim Terriberry <tterribe@xiph.org>
|
||||
|
||||
and the rest of the Xiph.Org Foundation.
|
||||
@@ -0,0 +1,104 @@
|
||||
Version 1.3.4 (2019 August 30)
|
||||
|
||||
* Faster slice-by-8 CRC32 implementation.
|
||||
see https://lwn.net/Articles/453931/ for motivation.
|
||||
* Add CMake build.
|
||||
* Deprecate Visual Studio project files in favor of CMake.
|
||||
* configure --disable-crc option for fuzzing.
|
||||
* Various build fixes.
|
||||
* Documentation and example code fixes.
|
||||
|
||||
Version 1.3.3 (2017 November 7)
|
||||
|
||||
* Fix an issue with corrupt continued packet handling.
|
||||
* Update Windows projects and build settings.
|
||||
* Remove Mac OS 9 build support.
|
||||
|
||||
Version 1.3.2 (2014 May 27)
|
||||
|
||||
* Fix an bug in oggpack_writecopy().
|
||||
|
||||
Version 1.3.1 (2013 May 12)
|
||||
|
||||
* Guard against very large packets.
|
||||
* Respect the configure --docdir override.
|
||||
* Documentation fixes.
|
||||
* More Windows build fixes.
|
||||
|
||||
Version 1.3.0 (2011 August 4)
|
||||
|
||||
* Add ogg_stream_flush_fill() call
|
||||
This produces longer packets on flush, similar to
|
||||
what ogg_stream_pageout_fill() does for single pages.
|
||||
* Windows build fixes
|
||||
|
||||
Version 1.2.2 (2010 December 07)
|
||||
|
||||
* Build fix (types correction) for Mac OS X
|
||||
* Update win32 project files to Visual Studio 2008
|
||||
* ogg_stream_pageout_fill documentation fix
|
||||
|
||||
Version 1.2.1 (2010 November 01)
|
||||
|
||||
* Various build updates (see SVN)
|
||||
* Add ogg_stream_pageout_fill() to API to allow applications
|
||||
greater explicit flexibility in page sizing.
|
||||
* Documentation updates including multiplexing description,
|
||||
terminology and API (incl. ogg_packet_clear(),
|
||||
ogg_stream_pageout_fill())
|
||||
* Correct possible buffer overwrite in stream encoding on 32 bit
|
||||
when a single packet exceed 250MB.
|
||||
* Correct read-buffer overrun [without side effects] under
|
||||
similar circumstances.
|
||||
* Update unit testing to work properly with new page spill
|
||||
heuristic.
|
||||
|
||||
Version 1.2.0 (2010 March 25)
|
||||
|
||||
* Alter default flushing behavior to span less often and use larger page
|
||||
sizes when packet sizes are large.
|
||||
* Build fixes for additional compilers
|
||||
* Documentation updates
|
||||
|
||||
Version 1.1.4 (2009 June 24)
|
||||
|
||||
* New async error reporting mechanism. Calls made after a fatal error are
|
||||
now safely handled in the event an error code is ignored
|
||||
* Added allocation checks useful to some embedded applications
|
||||
* fix possible read past end of buffer when reading 0 bits
|
||||
* Updates to API documentation
|
||||
* Build fixes
|
||||
|
||||
Version 1.1.3 (2005 November 27)
|
||||
|
||||
* Correct a bug in the granulepos field of pages where no packet ends
|
||||
* New VS2003 and XCode builds, minor fixes to other builds
|
||||
* documentation fixes and cleanup
|
||||
|
||||
Version 1.1.2 (2004 September 23)
|
||||
|
||||
* fix a bug with multipage packet assembly after seek
|
||||
|
||||
Version 1.1.1 (2004 September 12)
|
||||
|
||||
* various bugfixes
|
||||
* important bugfix for 64-bit platforms
|
||||
* various portability fixes
|
||||
* autotools cleanup from Thomas Vander Stichele
|
||||
* Symbian OS build support from Colin Ward at CSIRO
|
||||
* new multiplexed Ogg stream documentation
|
||||
|
||||
Version 1.1 (2003 November 17)
|
||||
|
||||
* big-endian bitpacker routines for Theora
|
||||
* various portability fixes
|
||||
* improved API documentation
|
||||
* RFC 3533 documentation of the format by Silvia Pfeiffer at CSIRO
|
||||
* RFC 3534 documentation of the application/ogg mime-type by Linus Walleij
|
||||
|
||||
Version 1.0 (2002 July 19)
|
||||
|
||||
* First stable release
|
||||
* little-endian bitpacker routines for Vorbis
|
||||
* basic Ogg bitstream sync and coding support
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
Copyright (c) 2002, Xiph.org Foundation
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION
|
||||
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -0,0 +1,3 @@
|
||||
This is libogg from Xiph, modified to build under Arduino by <earlephilhower@yahoo.com>.
|
||||
|
||||
OGG license/etc. unchanged.
|
||||
@@ -0,0 +1,133 @@
|
||||
# Ogg
|
||||
|
||||
[](https://travis-ci.org/xiph/ogg)
|
||||
[](https://mf4.xiph.org/jenkins/job/libogg/)
|
||||
[](https://ci.appveyor.com/project/rillian/ogg)
|
||||
|
||||
Ogg project codecs use the Ogg bitstream format to arrange the raw,
|
||||
compressed bitstream into a more robust, useful form. For example,
|
||||
the Ogg bitstream makes seeking, time stamping and error recovery
|
||||
possible, as well as mixing several separate, concurrent media
|
||||
streams into a single physical bitstream.
|
||||
|
||||
## What's here ##
|
||||
This source distribution includes libogg and nothing else. Other modules
|
||||
(eg, the modules libvorbis, vorbis-tools for the Vorbis music codec,
|
||||
libtheora for the Theora video codec) contain the codec libraries for
|
||||
use with Ogg bitstreams.
|
||||
|
||||
Directory:
|
||||
|
||||
- `src` The source for libogg, a BSD-license implementation of the public domain Ogg bitstream format
|
||||
|
||||
- `include` Library API headers
|
||||
|
||||
- `doc` Ogg specification and libogg API documents
|
||||
|
||||
- `win32` Win32 projects and build automation
|
||||
|
||||
- `macosx` Mac OS X project and build files
|
||||
|
||||
## Contact ##
|
||||
|
||||
The Ogg homepage is located at https://www.xiph.org/ogg/ .
|
||||
Up to date technical documents, contact information, source code and
|
||||
pre-built utilities may be found there.
|
||||
|
||||
## Building ##
|
||||
|
||||
#### Building from tarball distributions ####
|
||||
|
||||
./configure
|
||||
make
|
||||
|
||||
and optionally (as root):
|
||||
|
||||
make install
|
||||
|
||||
This will install the Ogg libraries (static and shared) into
|
||||
/usr/local/lib, includes into /usr/local/include and API
|
||||
documentation into /usr/local/share/doc.
|
||||
|
||||
#### Building from repository source ####
|
||||
|
||||
A standard svn build should consist of nothing more than:
|
||||
|
||||
./autogen.sh
|
||||
./configure
|
||||
make
|
||||
|
||||
and as root if desired :
|
||||
|
||||
make install
|
||||
|
||||
#### Building on Windows ####
|
||||
|
||||
Use the project file in the win32 directory. It should compile out of the box.
|
||||
|
||||
#### Cross-compiling from Linux to Windows ####
|
||||
|
||||
It is also possible to cross compile from Linux to windows using the MinGW
|
||||
cross tools and even to run the test suite under Wine, the Linux/*nix
|
||||
windows emulator.
|
||||
|
||||
On Debian and Ubuntu systems, these cross compiler tools can be installed
|
||||
by doing:
|
||||
|
||||
sudo apt-get mingw32 mingw32-binutils mingw32-runtime wine
|
||||
|
||||
Once these tools are installed its possible to compile and test by
|
||||
executing the following commands, or something similar depending on
|
||||
your system:
|
||||
|
||||
./configure --host=i586-mingw32msvc --target=i586-mingw32msvc --build=i586-linux
|
||||
make
|
||||
make check
|
||||
|
||||
(Build instructions for Ogg codecs such as vorbis are similar and may
|
||||
be found in those source modules' README files)
|
||||
|
||||
## Building with CMake ##
|
||||
|
||||
Ogg supports building using [CMake](http://www.cmake.org/). CMake is a meta build system that generates native projects for each platform.
|
||||
To generate projects just run cmake replacing `YOUR-PROJECT-GENERATOR` with a proper generator from a list [here](http://www.cmake.org/cmake/help/v3.2/manual/cmake-generators.7.html):
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -G YOUR-PROJECT-GENERATOR ..
|
||||
|
||||
Note that by default cmake generates projects that will build static libraries.
|
||||
To generate projects that will build dynamic library use `BUILD_SHARED_LIBS` option like this:
|
||||
|
||||
cmake -G YOUR-PROJECT-GENERATOR -DBUILD_SHARED_LIBS=1 ..
|
||||
|
||||
After projects are generated use them as usual
|
||||
|
||||
#### Building on Windows ####
|
||||
|
||||
Use proper generator for your Visual Studio version like:
|
||||
|
||||
cmake -G "Visual Studio 12 2013" ..
|
||||
|
||||
#### Building on Mac OS X ####
|
||||
|
||||
Use Xcode generator. To build framework run:
|
||||
|
||||
cmake -G Xcode -DBUILD_FRAMEWORK=1 ..
|
||||
|
||||
#### Building on Linux ####
|
||||
|
||||
Use Makefile generator which is default one.
|
||||
|
||||
cmake ..
|
||||
make
|
||||
|
||||
## License ##
|
||||
|
||||
THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.
|
||||
USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS
|
||||
GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE
|
||||
IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.
|
||||
|
||||
THE OggVorbis SOURCE CODE IS COPYRIGHT (C) 1994-2019
|
||||
by the Xiph.Org Foundation https://www.xiph.org/
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,104 @@
|
||||
/* config.h. Generated from config.h.in by configure. */
|
||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Do not build with CRC */
|
||||
/* #undef DISABLE_CRC */
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#define HAVE_DLFCN_H 0
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 0
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 0
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 0
|
||||
|
||||
/* Define to the sub-directory where libtool stores uninstalled libraries. */
|
||||
#define LT_OBJDIR ".libs/"
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "libogg"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "ogg-dev@xiph.org"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "libogg"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "libogg 1.3.4"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "libogg"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL ""
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "1.3.4"
|
||||
|
||||
/* The size of `int', as computed by sizeof. */
|
||||
#define SIZEOF_INT 4
|
||||
|
||||
/* The size of `int16_t', as computed by sizeof. */
|
||||
#define SIZEOF_INT16_T 2
|
||||
|
||||
/* The size of `int32_t', as computed by sizeof. */
|
||||
#define SIZEOF_INT32_T 4
|
||||
|
||||
/* The size of `int64_t', as computed by sizeof. */
|
||||
#define SIZEOF_INT64_T 8
|
||||
|
||||
/* The size of `long', as computed by sizeof. */
|
||||
#define SIZEOF_LONG 4
|
||||
|
||||
/* The size of `long long', as computed by sizeof. */
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
|
||||
/* The size of `short', as computed by sizeof. */
|
||||
#define SIZEOF_SHORT 2
|
||||
|
||||
/* The size of `uint16_t', as computed by sizeof. */
|
||||
#define SIZEOF_UINT16_T 2
|
||||
|
||||
/* The size of `uint32_t', as computed by sizeof. */
|
||||
#define SIZEOF_UINT32_T 4
|
||||
|
||||
/* The size of `uint64_t', as computed by sizeof. */
|
||||
#define SIZEOF_UINT64_T 8
|
||||
|
||||
/* The size of `u_int16_t', as computed by sizeof. */
|
||||
#define SIZEOF_U_INT16_T 2
|
||||
|
||||
/* The size of `u_int32_t', as computed by sizeof. */
|
||||
#define SIZEOF_U_INT32_T 4
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "1.3.4"
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
/* #undef const */
|
||||
@@ -0,0 +1,279 @@
|
||||
/********************************************************************
|
||||
* *
|
||||
* THIS FILE IS PART OF THE Ogg CONTAINER SOURCE CODE. *
|
||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
|
||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
|
||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
|
||||
* *
|
||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2018 *
|
||||
* by the Xiph.Org Foundation http://www.xiph.org/ *
|
||||
* *
|
||||
********************************************************************/
|
||||
|
||||
#include "ogg/os_types.h"
|
||||
#include <pgmspace.h>
|
||||
|
||||
static const ogg_uint32_t crc_lookup[8][256] PROGMEM ={
|
||||
{0x00000000,0x04c11db7,0x09823b6e,0x0d4326d9,0x130476dc,0x17c56b6b,0x1a864db2,0x1e475005,
|
||||
0x2608edb8,0x22c9f00f,0x2f8ad6d6,0x2b4bcb61,0x350c9b64,0x31cd86d3,0x3c8ea00a,0x384fbdbd,
|
||||
0x4c11db70,0x48d0c6c7,0x4593e01e,0x4152fda9,0x5f15adac,0x5bd4b01b,0x569796c2,0x52568b75,
|
||||
0x6a1936c8,0x6ed82b7f,0x639b0da6,0x675a1011,0x791d4014,0x7ddc5da3,0x709f7b7a,0x745e66cd,
|
||||
0x9823b6e0,0x9ce2ab57,0x91a18d8e,0x95609039,0x8b27c03c,0x8fe6dd8b,0x82a5fb52,0x8664e6e5,
|
||||
0xbe2b5b58,0xbaea46ef,0xb7a96036,0xb3687d81,0xad2f2d84,0xa9ee3033,0xa4ad16ea,0xa06c0b5d,
|
||||
0xd4326d90,0xd0f37027,0xddb056fe,0xd9714b49,0xc7361b4c,0xc3f706fb,0xceb42022,0xca753d95,
|
||||
0xf23a8028,0xf6fb9d9f,0xfbb8bb46,0xff79a6f1,0xe13ef6f4,0xe5ffeb43,0xe8bccd9a,0xec7dd02d,
|
||||
0x34867077,0x30476dc0,0x3d044b19,0x39c556ae,0x278206ab,0x23431b1c,0x2e003dc5,0x2ac12072,
|
||||
0x128e9dcf,0x164f8078,0x1b0ca6a1,0x1fcdbb16,0x018aeb13,0x054bf6a4,0x0808d07d,0x0cc9cdca,
|
||||
0x7897ab07,0x7c56b6b0,0x71159069,0x75d48dde,0x6b93dddb,0x6f52c06c,0x6211e6b5,0x66d0fb02,
|
||||
0x5e9f46bf,0x5a5e5b08,0x571d7dd1,0x53dc6066,0x4d9b3063,0x495a2dd4,0x44190b0d,0x40d816ba,
|
||||
0xaca5c697,0xa864db20,0xa527fdf9,0xa1e6e04e,0xbfa1b04b,0xbb60adfc,0xb6238b25,0xb2e29692,
|
||||
0x8aad2b2f,0x8e6c3698,0x832f1041,0x87ee0df6,0x99a95df3,0x9d684044,0x902b669d,0x94ea7b2a,
|
||||
0xe0b41de7,0xe4750050,0xe9362689,0xedf73b3e,0xf3b06b3b,0xf771768c,0xfa325055,0xfef34de2,
|
||||
0xc6bcf05f,0xc27dede8,0xcf3ecb31,0xcbffd686,0xd5b88683,0xd1799b34,0xdc3abded,0xd8fba05a,
|
||||
0x690ce0ee,0x6dcdfd59,0x608edb80,0x644fc637,0x7a089632,0x7ec98b85,0x738aad5c,0x774bb0eb,
|
||||
0x4f040d56,0x4bc510e1,0x46863638,0x42472b8f,0x5c007b8a,0x58c1663d,0x558240e4,0x51435d53,
|
||||
0x251d3b9e,0x21dc2629,0x2c9f00f0,0x285e1d47,0x36194d42,0x32d850f5,0x3f9b762c,0x3b5a6b9b,
|
||||
0x0315d626,0x07d4cb91,0x0a97ed48,0x0e56f0ff,0x1011a0fa,0x14d0bd4d,0x19939b94,0x1d528623,
|
||||
0xf12f560e,0xf5ee4bb9,0xf8ad6d60,0xfc6c70d7,0xe22b20d2,0xe6ea3d65,0xeba91bbc,0xef68060b,
|
||||
0xd727bbb6,0xd3e6a601,0xdea580d8,0xda649d6f,0xc423cd6a,0xc0e2d0dd,0xcda1f604,0xc960ebb3,
|
||||
0xbd3e8d7e,0xb9ff90c9,0xb4bcb610,0xb07daba7,0xae3afba2,0xaafbe615,0xa7b8c0cc,0xa379dd7b,
|
||||
0x9b3660c6,0x9ff77d71,0x92b45ba8,0x9675461f,0x8832161a,0x8cf30bad,0x81b02d74,0x857130c3,
|
||||
0x5d8a9099,0x594b8d2e,0x5408abf7,0x50c9b640,0x4e8ee645,0x4a4ffbf2,0x470cdd2b,0x43cdc09c,
|
||||
0x7b827d21,0x7f436096,0x7200464f,0x76c15bf8,0x68860bfd,0x6c47164a,0x61043093,0x65c52d24,
|
||||
0x119b4be9,0x155a565e,0x18197087,0x1cd86d30,0x029f3d35,0x065e2082,0x0b1d065b,0x0fdc1bec,
|
||||
0x3793a651,0x3352bbe6,0x3e119d3f,0x3ad08088,0x2497d08d,0x2056cd3a,0x2d15ebe3,0x29d4f654,
|
||||
0xc5a92679,0xc1683bce,0xcc2b1d17,0xc8ea00a0,0xd6ad50a5,0xd26c4d12,0xdf2f6bcb,0xdbee767c,
|
||||
0xe3a1cbc1,0xe760d676,0xea23f0af,0xeee2ed18,0xf0a5bd1d,0xf464a0aa,0xf9278673,0xfde69bc4,
|
||||
0x89b8fd09,0x8d79e0be,0x803ac667,0x84fbdbd0,0x9abc8bd5,0x9e7d9662,0x933eb0bb,0x97ffad0c,
|
||||
0xafb010b1,0xab710d06,0xa6322bdf,0xa2f33668,0xbcb4666d,0xb8757bda,0xb5365d03,0xb1f740b4},
|
||||
|
||||
{0x00000000,0xd219c1dc,0xa0f29e0f,0x72eb5fd3,0x452421a9,0x973de075,0xe5d6bfa6,0x37cf7e7a,
|
||||
0x8a484352,0x5851828e,0x2abadd5d,0xf8a31c81,0xcf6c62fb,0x1d75a327,0x6f9efcf4,0xbd873d28,
|
||||
0x10519b13,0xc2485acf,0xb0a3051c,0x62bac4c0,0x5575baba,0x876c7b66,0xf58724b5,0x279ee569,
|
||||
0x9a19d841,0x4800199d,0x3aeb464e,0xe8f28792,0xdf3df9e8,0x0d243834,0x7fcf67e7,0xadd6a63b,
|
||||
0x20a33626,0xf2baf7fa,0x8051a829,0x524869f5,0x6587178f,0xb79ed653,0xc5758980,0x176c485c,
|
||||
0xaaeb7574,0x78f2b4a8,0x0a19eb7b,0xd8002aa7,0xefcf54dd,0x3dd69501,0x4f3dcad2,0x9d240b0e,
|
||||
0x30f2ad35,0xe2eb6ce9,0x9000333a,0x4219f2e6,0x75d68c9c,0xa7cf4d40,0xd5241293,0x073dd34f,
|
||||
0xbabaee67,0x68a32fbb,0x1a487068,0xc851b1b4,0xff9ecfce,0x2d870e12,0x5f6c51c1,0x8d75901d,
|
||||
0x41466c4c,0x935fad90,0xe1b4f243,0x33ad339f,0x04624de5,0xd67b8c39,0xa490d3ea,0x76891236,
|
||||
0xcb0e2f1e,0x1917eec2,0x6bfcb111,0xb9e570cd,0x8e2a0eb7,0x5c33cf6b,0x2ed890b8,0xfcc15164,
|
||||
0x5117f75f,0x830e3683,0xf1e56950,0x23fca88c,0x1433d6f6,0xc62a172a,0xb4c148f9,0x66d88925,
|
||||
0xdb5fb40d,0x094675d1,0x7bad2a02,0xa9b4ebde,0x9e7b95a4,0x4c625478,0x3e890bab,0xec90ca77,
|
||||
0x61e55a6a,0xb3fc9bb6,0xc117c465,0x130e05b9,0x24c17bc3,0xf6d8ba1f,0x8433e5cc,0x562a2410,
|
||||
0xebad1938,0x39b4d8e4,0x4b5f8737,0x994646eb,0xae893891,0x7c90f94d,0x0e7ba69e,0xdc626742,
|
||||
0x71b4c179,0xa3ad00a5,0xd1465f76,0x035f9eaa,0x3490e0d0,0xe689210c,0x94627edf,0x467bbf03,
|
||||
0xfbfc822b,0x29e543f7,0x5b0e1c24,0x8917ddf8,0xbed8a382,0x6cc1625e,0x1e2a3d8d,0xcc33fc51,
|
||||
0x828cd898,0x50951944,0x227e4697,0xf067874b,0xc7a8f931,0x15b138ed,0x675a673e,0xb543a6e2,
|
||||
0x08c49bca,0xdadd5a16,0xa83605c5,0x7a2fc419,0x4de0ba63,0x9ff97bbf,0xed12246c,0x3f0be5b0,
|
||||
0x92dd438b,0x40c48257,0x322fdd84,0xe0361c58,0xd7f96222,0x05e0a3fe,0x770bfc2d,0xa5123df1,
|
||||
0x189500d9,0xca8cc105,0xb8679ed6,0x6a7e5f0a,0x5db12170,0x8fa8e0ac,0xfd43bf7f,0x2f5a7ea3,
|
||||
0xa22feebe,0x70362f62,0x02dd70b1,0xd0c4b16d,0xe70bcf17,0x35120ecb,0x47f95118,0x95e090c4,
|
||||
0x2867adec,0xfa7e6c30,0x889533e3,0x5a8cf23f,0x6d438c45,0xbf5a4d99,0xcdb1124a,0x1fa8d396,
|
||||
0xb27e75ad,0x6067b471,0x128ceba2,0xc0952a7e,0xf75a5404,0x254395d8,0x57a8ca0b,0x85b10bd7,
|
||||
0x383636ff,0xea2ff723,0x98c4a8f0,0x4add692c,0x7d121756,0xaf0bd68a,0xdde08959,0x0ff94885,
|
||||
0xc3cab4d4,0x11d37508,0x63382adb,0xb121eb07,0x86ee957d,0x54f754a1,0x261c0b72,0xf405caae,
|
||||
0x4982f786,0x9b9b365a,0xe9706989,0x3b69a855,0x0ca6d62f,0xdebf17f3,0xac544820,0x7e4d89fc,
|
||||
0xd39b2fc7,0x0182ee1b,0x7369b1c8,0xa1707014,0x96bf0e6e,0x44a6cfb2,0x364d9061,0xe45451bd,
|
||||
0x59d36c95,0x8bcaad49,0xf921f29a,0x2b383346,0x1cf74d3c,0xceee8ce0,0xbc05d333,0x6e1c12ef,
|
||||
0xe36982f2,0x3170432e,0x439b1cfd,0x9182dd21,0xa64da35b,0x74546287,0x06bf3d54,0xd4a6fc88,
|
||||
0x6921c1a0,0xbb38007c,0xc9d35faf,0x1bca9e73,0x2c05e009,0xfe1c21d5,0x8cf77e06,0x5eeebfda,
|
||||
0xf33819e1,0x2121d83d,0x53ca87ee,0x81d34632,0xb61c3848,0x6405f994,0x16eea647,0xc4f7679b,
|
||||
0x79705ab3,0xab699b6f,0xd982c4bc,0x0b9b0560,0x3c547b1a,0xee4dbac6,0x9ca6e515,0x4ebf24c9},
|
||||
|
||||
{0x00000000,0x01d8ac87,0x03b1590e,0x0269f589,0x0762b21c,0x06ba1e9b,0x04d3eb12,0x050b4795,
|
||||
0x0ec56438,0x0f1dc8bf,0x0d743d36,0x0cac91b1,0x09a7d624,0x087f7aa3,0x0a168f2a,0x0bce23ad,
|
||||
0x1d8ac870,0x1c5264f7,0x1e3b917e,0x1fe33df9,0x1ae87a6c,0x1b30d6eb,0x19592362,0x18818fe5,
|
||||
0x134fac48,0x129700cf,0x10fef546,0x112659c1,0x142d1e54,0x15f5b2d3,0x179c475a,0x1644ebdd,
|
||||
0x3b1590e0,0x3acd3c67,0x38a4c9ee,0x397c6569,0x3c7722fc,0x3daf8e7b,0x3fc67bf2,0x3e1ed775,
|
||||
0x35d0f4d8,0x3408585f,0x3661add6,0x37b90151,0x32b246c4,0x336aea43,0x31031fca,0x30dbb34d,
|
||||
0x269f5890,0x2747f417,0x252e019e,0x24f6ad19,0x21fdea8c,0x2025460b,0x224cb382,0x23941f05,
|
||||
0x285a3ca8,0x2982902f,0x2beb65a6,0x2a33c921,0x2f388eb4,0x2ee02233,0x2c89d7ba,0x2d517b3d,
|
||||
0x762b21c0,0x77f38d47,0x759a78ce,0x7442d449,0x714993dc,0x70913f5b,0x72f8cad2,0x73206655,
|
||||
0x78ee45f8,0x7936e97f,0x7b5f1cf6,0x7a87b071,0x7f8cf7e4,0x7e545b63,0x7c3daeea,0x7de5026d,
|
||||
0x6ba1e9b0,0x6a794537,0x6810b0be,0x69c81c39,0x6cc35bac,0x6d1bf72b,0x6f7202a2,0x6eaaae25,
|
||||
0x65648d88,0x64bc210f,0x66d5d486,0x670d7801,0x62063f94,0x63de9313,0x61b7669a,0x606fca1d,
|
||||
0x4d3eb120,0x4ce61da7,0x4e8fe82e,0x4f5744a9,0x4a5c033c,0x4b84afbb,0x49ed5a32,0x4835f6b5,
|
||||
0x43fbd518,0x4223799f,0x404a8c16,0x41922091,0x44996704,0x4541cb83,0x47283e0a,0x46f0928d,
|
||||
0x50b47950,0x516cd5d7,0x5305205e,0x52dd8cd9,0x57d6cb4c,0x560e67cb,0x54679242,0x55bf3ec5,
|
||||
0x5e711d68,0x5fa9b1ef,0x5dc04466,0x5c18e8e1,0x5913af74,0x58cb03f3,0x5aa2f67a,0x5b7a5afd,
|
||||
0xec564380,0xed8eef07,0xefe71a8e,0xee3fb609,0xeb34f19c,0xeaec5d1b,0xe885a892,0xe95d0415,
|
||||
0xe29327b8,0xe34b8b3f,0xe1227eb6,0xe0fad231,0xe5f195a4,0xe4293923,0xe640ccaa,0xe798602d,
|
||||
0xf1dc8bf0,0xf0042777,0xf26dd2fe,0xf3b57e79,0xf6be39ec,0xf766956b,0xf50f60e2,0xf4d7cc65,
|
||||
0xff19efc8,0xfec1434f,0xfca8b6c6,0xfd701a41,0xf87b5dd4,0xf9a3f153,0xfbca04da,0xfa12a85d,
|
||||
0xd743d360,0xd69b7fe7,0xd4f28a6e,0xd52a26e9,0xd021617c,0xd1f9cdfb,0xd3903872,0xd24894f5,
|
||||
0xd986b758,0xd85e1bdf,0xda37ee56,0xdbef42d1,0xdee40544,0xdf3ca9c3,0xdd555c4a,0xdc8df0cd,
|
||||
0xcac91b10,0xcb11b797,0xc978421e,0xc8a0ee99,0xcdaba90c,0xcc73058b,0xce1af002,0xcfc25c85,
|
||||
0xc40c7f28,0xc5d4d3af,0xc7bd2626,0xc6658aa1,0xc36ecd34,0xc2b661b3,0xc0df943a,0xc10738bd,
|
||||
0x9a7d6240,0x9ba5cec7,0x99cc3b4e,0x981497c9,0x9d1fd05c,0x9cc77cdb,0x9eae8952,0x9f7625d5,
|
||||
0x94b80678,0x9560aaff,0x97095f76,0x96d1f3f1,0x93dab464,0x920218e3,0x906bed6a,0x91b341ed,
|
||||
0x87f7aa30,0x862f06b7,0x8446f33e,0x859e5fb9,0x8095182c,0x814db4ab,0x83244122,0x82fceda5,
|
||||
0x8932ce08,0x88ea628f,0x8a839706,0x8b5b3b81,0x8e507c14,0x8f88d093,0x8de1251a,0x8c39899d,
|
||||
0xa168f2a0,0xa0b05e27,0xa2d9abae,0xa3010729,0xa60a40bc,0xa7d2ec3b,0xa5bb19b2,0xa463b535,
|
||||
0xafad9698,0xae753a1f,0xac1ccf96,0xadc46311,0xa8cf2484,0xa9178803,0xab7e7d8a,0xaaa6d10d,
|
||||
0xbce23ad0,0xbd3a9657,0xbf5363de,0xbe8bcf59,0xbb8088cc,0xba58244b,0xb831d1c2,0xb9e97d45,
|
||||
0xb2275ee8,0xb3fff26f,0xb19607e6,0xb04eab61,0xb545ecf4,0xb49d4073,0xb6f4b5fa,0xb72c197d},
|
||||
|
||||
{0x00000000,0xdc6d9ab7,0xbc1a28d9,0x6077b26e,0x7cf54c05,0xa098d6b2,0xc0ef64dc,0x1c82fe6b,
|
||||
0xf9ea980a,0x258702bd,0x45f0b0d3,0x999d2a64,0x851fd40f,0x59724eb8,0x3905fcd6,0xe5686661,
|
||||
0xf7142da3,0x2b79b714,0x4b0e057a,0x97639fcd,0x8be161a6,0x578cfb11,0x37fb497f,0xeb96d3c8,
|
||||
0x0efeb5a9,0xd2932f1e,0xb2e49d70,0x6e8907c7,0x720bf9ac,0xae66631b,0xce11d175,0x127c4bc2,
|
||||
0xeae946f1,0x3684dc46,0x56f36e28,0x8a9ef49f,0x961c0af4,0x4a719043,0x2a06222d,0xf66bb89a,
|
||||
0x1303defb,0xcf6e444c,0xaf19f622,0x73746c95,0x6ff692fe,0xb39b0849,0xd3ecba27,0x0f812090,
|
||||
0x1dfd6b52,0xc190f1e5,0xa1e7438b,0x7d8ad93c,0x61082757,0xbd65bde0,0xdd120f8e,0x017f9539,
|
||||
0xe417f358,0x387a69ef,0x580ddb81,0x84604136,0x98e2bf5d,0x448f25ea,0x24f89784,0xf8950d33,
|
||||
0xd1139055,0x0d7e0ae2,0x6d09b88c,0xb164223b,0xade6dc50,0x718b46e7,0x11fcf489,0xcd916e3e,
|
||||
0x28f9085f,0xf49492e8,0x94e32086,0x488eba31,0x540c445a,0x8861deed,0xe8166c83,0x347bf634,
|
||||
0x2607bdf6,0xfa6a2741,0x9a1d952f,0x46700f98,0x5af2f1f3,0x869f6b44,0xe6e8d92a,0x3a85439d,
|
||||
0xdfed25fc,0x0380bf4b,0x63f70d25,0xbf9a9792,0xa31869f9,0x7f75f34e,0x1f024120,0xc36fdb97,
|
||||
0x3bfad6a4,0xe7974c13,0x87e0fe7d,0x5b8d64ca,0x470f9aa1,0x9b620016,0xfb15b278,0x277828cf,
|
||||
0xc2104eae,0x1e7dd419,0x7e0a6677,0xa267fcc0,0xbee502ab,0x6288981c,0x02ff2a72,0xde92b0c5,
|
||||
0xcceefb07,0x108361b0,0x70f4d3de,0xac994969,0xb01bb702,0x6c762db5,0x0c019fdb,0xd06c056c,
|
||||
0x3504630d,0xe969f9ba,0x891e4bd4,0x5573d163,0x49f12f08,0x959cb5bf,0xf5eb07d1,0x29869d66,
|
||||
0xa6e63d1d,0x7a8ba7aa,0x1afc15c4,0xc6918f73,0xda137118,0x067eebaf,0x660959c1,0xba64c376,
|
||||
0x5f0ca517,0x83613fa0,0xe3168dce,0x3f7b1779,0x23f9e912,0xff9473a5,0x9fe3c1cb,0x438e5b7c,
|
||||
0x51f210be,0x8d9f8a09,0xede83867,0x3185a2d0,0x2d075cbb,0xf16ac60c,0x911d7462,0x4d70eed5,
|
||||
0xa81888b4,0x74751203,0x1402a06d,0xc86f3ada,0xd4edc4b1,0x08805e06,0x68f7ec68,0xb49a76df,
|
||||
0x4c0f7bec,0x9062e15b,0xf0155335,0x2c78c982,0x30fa37e9,0xec97ad5e,0x8ce01f30,0x508d8587,
|
||||
0xb5e5e3e6,0x69887951,0x09ffcb3f,0xd5925188,0xc910afe3,0x157d3554,0x750a873a,0xa9671d8d,
|
||||
0xbb1b564f,0x6776ccf8,0x07017e96,0xdb6ce421,0xc7ee1a4a,0x1b8380fd,0x7bf43293,0xa799a824,
|
||||
0x42f1ce45,0x9e9c54f2,0xfeebe69c,0x22867c2b,0x3e048240,0xe26918f7,0x821eaa99,0x5e73302e,
|
||||
0x77f5ad48,0xab9837ff,0xcbef8591,0x17821f26,0x0b00e14d,0xd76d7bfa,0xb71ac994,0x6b775323,
|
||||
0x8e1f3542,0x5272aff5,0x32051d9b,0xee68872c,0xf2ea7947,0x2e87e3f0,0x4ef0519e,0x929dcb29,
|
||||
0x80e180eb,0x5c8c1a5c,0x3cfba832,0xe0963285,0xfc14ccee,0x20795659,0x400ee437,0x9c637e80,
|
||||
0x790b18e1,0xa5668256,0xc5113038,0x197caa8f,0x05fe54e4,0xd993ce53,0xb9e47c3d,0x6589e68a,
|
||||
0x9d1cebb9,0x4171710e,0x2106c360,0xfd6b59d7,0xe1e9a7bc,0x3d843d0b,0x5df38f65,0x819e15d2,
|
||||
0x64f673b3,0xb89be904,0xd8ec5b6a,0x0481c1dd,0x18033fb6,0xc46ea501,0xa419176f,0x78748dd8,
|
||||
0x6a08c61a,0xb6655cad,0xd612eec3,0x0a7f7474,0x16fd8a1f,0xca9010a8,0xaae7a2c6,0x768a3871,
|
||||
0x93e25e10,0x4f8fc4a7,0x2ff876c9,0xf395ec7e,0xef171215,0x337a88a2,0x530d3acc,0x8f60a07b},
|
||||
|
||||
{0x00000000,0x490d678d,0x921acf1a,0xdb17a897,0x20f48383,0x69f9e40e,0xb2ee4c99,0xfbe32b14,
|
||||
0x41e90706,0x08e4608b,0xd3f3c81c,0x9afeaf91,0x611d8485,0x2810e308,0xf3074b9f,0xba0a2c12,
|
||||
0x83d20e0c,0xcadf6981,0x11c8c116,0x58c5a69b,0xa3268d8f,0xea2bea02,0x313c4295,0x78312518,
|
||||
0xc23b090a,0x8b366e87,0x5021c610,0x192ca19d,0xe2cf8a89,0xabc2ed04,0x70d54593,0x39d8221e,
|
||||
0x036501af,0x4a686622,0x917fceb5,0xd872a938,0x2391822c,0x6a9ce5a1,0xb18b4d36,0xf8862abb,
|
||||
0x428c06a9,0x0b816124,0xd096c9b3,0x999bae3e,0x6278852a,0x2b75e2a7,0xf0624a30,0xb96f2dbd,
|
||||
0x80b70fa3,0xc9ba682e,0x12adc0b9,0x5ba0a734,0xa0438c20,0xe94eebad,0x3259433a,0x7b5424b7,
|
||||
0xc15e08a5,0x88536f28,0x5344c7bf,0x1a49a032,0xe1aa8b26,0xa8a7ecab,0x73b0443c,0x3abd23b1,
|
||||
0x06ca035e,0x4fc764d3,0x94d0cc44,0xddddabc9,0x263e80dd,0x6f33e750,0xb4244fc7,0xfd29284a,
|
||||
0x47230458,0x0e2e63d5,0xd539cb42,0x9c34accf,0x67d787db,0x2edae056,0xf5cd48c1,0xbcc02f4c,
|
||||
0x85180d52,0xcc156adf,0x1702c248,0x5e0fa5c5,0xa5ec8ed1,0xece1e95c,0x37f641cb,0x7efb2646,
|
||||
0xc4f10a54,0x8dfc6dd9,0x56ebc54e,0x1fe6a2c3,0xe40589d7,0xad08ee5a,0x761f46cd,0x3f122140,
|
||||
0x05af02f1,0x4ca2657c,0x97b5cdeb,0xdeb8aa66,0x255b8172,0x6c56e6ff,0xb7414e68,0xfe4c29e5,
|
||||
0x444605f7,0x0d4b627a,0xd65ccaed,0x9f51ad60,0x64b28674,0x2dbfe1f9,0xf6a8496e,0xbfa52ee3,
|
||||
0x867d0cfd,0xcf706b70,0x1467c3e7,0x5d6aa46a,0xa6898f7e,0xef84e8f3,0x34934064,0x7d9e27e9,
|
||||
0xc7940bfb,0x8e996c76,0x558ec4e1,0x1c83a36c,0xe7608878,0xae6deff5,0x757a4762,0x3c7720ef,
|
||||
0x0d9406bc,0x44996131,0x9f8ec9a6,0xd683ae2b,0x2d60853f,0x646de2b2,0xbf7a4a25,0xf6772da8,
|
||||
0x4c7d01ba,0x05706637,0xde67cea0,0x976aa92d,0x6c898239,0x2584e5b4,0xfe934d23,0xb79e2aae,
|
||||
0x8e4608b0,0xc74b6f3d,0x1c5cc7aa,0x5551a027,0xaeb28b33,0xe7bfecbe,0x3ca84429,0x75a523a4,
|
||||
0xcfaf0fb6,0x86a2683b,0x5db5c0ac,0x14b8a721,0xef5b8c35,0xa656ebb8,0x7d41432f,0x344c24a2,
|
||||
0x0ef10713,0x47fc609e,0x9cebc809,0xd5e6af84,0x2e058490,0x6708e31d,0xbc1f4b8a,0xf5122c07,
|
||||
0x4f180015,0x06156798,0xdd02cf0f,0x940fa882,0x6fec8396,0x26e1e41b,0xfdf64c8c,0xb4fb2b01,
|
||||
0x8d23091f,0xc42e6e92,0x1f39c605,0x5634a188,0xadd78a9c,0xe4daed11,0x3fcd4586,0x76c0220b,
|
||||
0xccca0e19,0x85c76994,0x5ed0c103,0x17dda68e,0xec3e8d9a,0xa533ea17,0x7e244280,0x3729250d,
|
||||
0x0b5e05e2,0x4253626f,0x9944caf8,0xd049ad75,0x2baa8661,0x62a7e1ec,0xb9b0497b,0xf0bd2ef6,
|
||||
0x4ab702e4,0x03ba6569,0xd8adcdfe,0x91a0aa73,0x6a438167,0x234ee6ea,0xf8594e7d,0xb15429f0,
|
||||
0x888c0bee,0xc1816c63,0x1a96c4f4,0x539ba379,0xa878886d,0xe175efe0,0x3a624777,0x736f20fa,
|
||||
0xc9650ce8,0x80686b65,0x5b7fc3f2,0x1272a47f,0xe9918f6b,0xa09ce8e6,0x7b8b4071,0x328627fc,
|
||||
0x083b044d,0x413663c0,0x9a21cb57,0xd32cacda,0x28cf87ce,0x61c2e043,0xbad548d4,0xf3d82f59,
|
||||
0x49d2034b,0x00df64c6,0xdbc8cc51,0x92c5abdc,0x692680c8,0x202be745,0xfb3c4fd2,0xb231285f,
|
||||
0x8be90a41,0xc2e46dcc,0x19f3c55b,0x50fea2d6,0xab1d89c2,0xe210ee4f,0x390746d8,0x700a2155,
|
||||
0xca000d47,0x830d6aca,0x581ac25d,0x1117a5d0,0xeaf48ec4,0xa3f9e949,0x78ee41de,0x31e32653},
|
||||
|
||||
{0x00000000,0x1b280d78,0x36501af0,0x2d781788,0x6ca035e0,0x77883898,0x5af02f10,0x41d82268,
|
||||
0xd9406bc0,0xc26866b8,0xef107130,0xf4387c48,0xb5e05e20,0xaec85358,0x83b044d0,0x989849a8,
|
||||
0xb641ca37,0xad69c74f,0x8011d0c7,0x9b39ddbf,0xdae1ffd7,0xc1c9f2af,0xecb1e527,0xf799e85f,
|
||||
0x6f01a1f7,0x7429ac8f,0x5951bb07,0x4279b67f,0x03a19417,0x1889996f,0x35f18ee7,0x2ed9839f,
|
||||
0x684289d9,0x736a84a1,0x5e129329,0x453a9e51,0x04e2bc39,0x1fcab141,0x32b2a6c9,0x299aabb1,
|
||||
0xb102e219,0xaa2aef61,0x8752f8e9,0x9c7af591,0xdda2d7f9,0xc68ada81,0xebf2cd09,0xf0dac071,
|
||||
0xde0343ee,0xc52b4e96,0xe853591e,0xf37b5466,0xb2a3760e,0xa98b7b76,0x84f36cfe,0x9fdb6186,
|
||||
0x0743282e,0x1c6b2556,0x311332de,0x2a3b3fa6,0x6be31dce,0x70cb10b6,0x5db3073e,0x469b0a46,
|
||||
0xd08513b2,0xcbad1eca,0xe6d50942,0xfdfd043a,0xbc252652,0xa70d2b2a,0x8a753ca2,0x915d31da,
|
||||
0x09c57872,0x12ed750a,0x3f956282,0x24bd6ffa,0x65654d92,0x7e4d40ea,0x53355762,0x481d5a1a,
|
||||
0x66c4d985,0x7decd4fd,0x5094c375,0x4bbcce0d,0x0a64ec65,0x114ce11d,0x3c34f695,0x271cfbed,
|
||||
0xbf84b245,0xa4acbf3d,0x89d4a8b5,0x92fca5cd,0xd32487a5,0xc80c8add,0xe5749d55,0xfe5c902d,
|
||||
0xb8c79a6b,0xa3ef9713,0x8e97809b,0x95bf8de3,0xd467af8b,0xcf4fa2f3,0xe237b57b,0xf91fb803,
|
||||
0x6187f1ab,0x7aaffcd3,0x57d7eb5b,0x4cffe623,0x0d27c44b,0x160fc933,0x3b77debb,0x205fd3c3,
|
||||
0x0e86505c,0x15ae5d24,0x38d64aac,0x23fe47d4,0x622665bc,0x790e68c4,0x54767f4c,0x4f5e7234,
|
||||
0xd7c63b9c,0xccee36e4,0xe196216c,0xfabe2c14,0xbb660e7c,0xa04e0304,0x8d36148c,0x961e19f4,
|
||||
0xa5cb3ad3,0xbee337ab,0x939b2023,0x88b32d5b,0xc96b0f33,0xd243024b,0xff3b15c3,0xe41318bb,
|
||||
0x7c8b5113,0x67a35c6b,0x4adb4be3,0x51f3469b,0x102b64f3,0x0b03698b,0x267b7e03,0x3d53737b,
|
||||
0x138af0e4,0x08a2fd9c,0x25daea14,0x3ef2e76c,0x7f2ac504,0x6402c87c,0x497adff4,0x5252d28c,
|
||||
0xcaca9b24,0xd1e2965c,0xfc9a81d4,0xe7b28cac,0xa66aaec4,0xbd42a3bc,0x903ab434,0x8b12b94c,
|
||||
0xcd89b30a,0xd6a1be72,0xfbd9a9fa,0xe0f1a482,0xa12986ea,0xba018b92,0x97799c1a,0x8c519162,
|
||||
0x14c9d8ca,0x0fe1d5b2,0x2299c23a,0x39b1cf42,0x7869ed2a,0x6341e052,0x4e39f7da,0x5511faa2,
|
||||
0x7bc8793d,0x60e07445,0x4d9863cd,0x56b06eb5,0x17684cdd,0x0c4041a5,0x2138562d,0x3a105b55,
|
||||
0xa28812fd,0xb9a01f85,0x94d8080d,0x8ff00575,0xce28271d,0xd5002a65,0xf8783ded,0xe3503095,
|
||||
0x754e2961,0x6e662419,0x431e3391,0x58363ee9,0x19ee1c81,0x02c611f9,0x2fbe0671,0x34960b09,
|
||||
0xac0e42a1,0xb7264fd9,0x9a5e5851,0x81765529,0xc0ae7741,0xdb867a39,0xf6fe6db1,0xedd660c9,
|
||||
0xc30fe356,0xd827ee2e,0xf55ff9a6,0xee77f4de,0xafafd6b6,0xb487dbce,0x99ffcc46,0x82d7c13e,
|
||||
0x1a4f8896,0x016785ee,0x2c1f9266,0x37379f1e,0x76efbd76,0x6dc7b00e,0x40bfa786,0x5b97aafe,
|
||||
0x1d0ca0b8,0x0624adc0,0x2b5cba48,0x3074b730,0x71ac9558,0x6a849820,0x47fc8fa8,0x5cd482d0,
|
||||
0xc44ccb78,0xdf64c600,0xf21cd188,0xe934dcf0,0xa8ecfe98,0xb3c4f3e0,0x9ebce468,0x8594e910,
|
||||
0xab4d6a8f,0xb06567f7,0x9d1d707f,0x86357d07,0xc7ed5f6f,0xdcc55217,0xf1bd459f,0xea9548e7,
|
||||
0x720d014f,0x69250c37,0x445d1bbf,0x5f7516c7,0x1ead34af,0x058539d7,0x28fd2e5f,0x33d52327},
|
||||
|
||||
{0x00000000,0x4f576811,0x9eaed022,0xd1f9b833,0x399cbdf3,0x76cbd5e2,0xa7326dd1,0xe86505c0,
|
||||
0x73397be6,0x3c6e13f7,0xed97abc4,0xa2c0c3d5,0x4aa5c615,0x05f2ae04,0xd40b1637,0x9b5c7e26,
|
||||
0xe672f7cc,0xa9259fdd,0x78dc27ee,0x378b4fff,0xdfee4a3f,0x90b9222e,0x41409a1d,0x0e17f20c,
|
||||
0x954b8c2a,0xda1ce43b,0x0be55c08,0x44b23419,0xacd731d9,0xe38059c8,0x3279e1fb,0x7d2e89ea,
|
||||
0xc824f22f,0x87739a3e,0x568a220d,0x19dd4a1c,0xf1b84fdc,0xbeef27cd,0x6f169ffe,0x2041f7ef,
|
||||
0xbb1d89c9,0xf44ae1d8,0x25b359eb,0x6ae431fa,0x8281343a,0xcdd65c2b,0x1c2fe418,0x53788c09,
|
||||
0x2e5605e3,0x61016df2,0xb0f8d5c1,0xffafbdd0,0x17cab810,0x589dd001,0x89646832,0xc6330023,
|
||||
0x5d6f7e05,0x12381614,0xc3c1ae27,0x8c96c636,0x64f3c3f6,0x2ba4abe7,0xfa5d13d4,0xb50a7bc5,
|
||||
0x9488f9e9,0xdbdf91f8,0x0a2629cb,0x457141da,0xad14441a,0xe2432c0b,0x33ba9438,0x7cedfc29,
|
||||
0xe7b1820f,0xa8e6ea1e,0x791f522d,0x36483a3c,0xde2d3ffc,0x917a57ed,0x4083efde,0x0fd487cf,
|
||||
0x72fa0e25,0x3dad6634,0xec54de07,0xa303b616,0x4b66b3d6,0x0431dbc7,0xd5c863f4,0x9a9f0be5,
|
||||
0x01c375c3,0x4e941dd2,0x9f6da5e1,0xd03acdf0,0x385fc830,0x7708a021,0xa6f11812,0xe9a67003,
|
||||
0x5cac0bc6,0x13fb63d7,0xc202dbe4,0x8d55b3f5,0x6530b635,0x2a67de24,0xfb9e6617,0xb4c90e06,
|
||||
0x2f957020,0x60c21831,0xb13ba002,0xfe6cc813,0x1609cdd3,0x595ea5c2,0x88a71df1,0xc7f075e0,
|
||||
0xbadefc0a,0xf589941b,0x24702c28,0x6b274439,0x834241f9,0xcc1529e8,0x1dec91db,0x52bbf9ca,
|
||||
0xc9e787ec,0x86b0effd,0x574957ce,0x181e3fdf,0xf07b3a1f,0xbf2c520e,0x6ed5ea3d,0x2182822c,
|
||||
0x2dd0ee65,0x62878674,0xb37e3e47,0xfc295656,0x144c5396,0x5b1b3b87,0x8ae283b4,0xc5b5eba5,
|
||||
0x5ee99583,0x11befd92,0xc04745a1,0x8f102db0,0x67752870,0x28224061,0xf9dbf852,0xb68c9043,
|
||||
0xcba219a9,0x84f571b8,0x550cc98b,0x1a5ba19a,0xf23ea45a,0xbd69cc4b,0x6c907478,0x23c71c69,
|
||||
0xb89b624f,0xf7cc0a5e,0x2635b26d,0x6962da7c,0x8107dfbc,0xce50b7ad,0x1fa90f9e,0x50fe678f,
|
||||
0xe5f41c4a,0xaaa3745b,0x7b5acc68,0x340da479,0xdc68a1b9,0x933fc9a8,0x42c6719b,0x0d91198a,
|
||||
0x96cd67ac,0xd99a0fbd,0x0863b78e,0x4734df9f,0xaf51da5f,0xe006b24e,0x31ff0a7d,0x7ea8626c,
|
||||
0x0386eb86,0x4cd18397,0x9d283ba4,0xd27f53b5,0x3a1a5675,0x754d3e64,0xa4b48657,0xebe3ee46,
|
||||
0x70bf9060,0x3fe8f871,0xee114042,0xa1462853,0x49232d93,0x06744582,0xd78dfdb1,0x98da95a0,
|
||||
0xb958178c,0xf60f7f9d,0x27f6c7ae,0x68a1afbf,0x80c4aa7f,0xcf93c26e,0x1e6a7a5d,0x513d124c,
|
||||
0xca616c6a,0x8536047b,0x54cfbc48,0x1b98d459,0xf3fdd199,0xbcaab988,0x6d5301bb,0x220469aa,
|
||||
0x5f2ae040,0x107d8851,0xc1843062,0x8ed35873,0x66b65db3,0x29e135a2,0xf8188d91,0xb74fe580,
|
||||
0x2c139ba6,0x6344f3b7,0xb2bd4b84,0xfdea2395,0x158f2655,0x5ad84e44,0x8b21f677,0xc4769e66,
|
||||
0x717ce5a3,0x3e2b8db2,0xefd23581,0xa0855d90,0x48e05850,0x07b73041,0xd64e8872,0x9919e063,
|
||||
0x02459e45,0x4d12f654,0x9ceb4e67,0xd3bc2676,0x3bd923b6,0x748e4ba7,0xa577f394,0xea209b85,
|
||||
0x970e126f,0xd8597a7e,0x09a0c24d,0x46f7aa5c,0xae92af9c,0xe1c5c78d,0x303c7fbe,0x7f6b17af,
|
||||
0xe4376989,0xab600198,0x7a99b9ab,0x35ced1ba,0xddabd47a,0x92fcbc6b,0x43050458,0x0c526c49},
|
||||
|
||||
{0x00000000,0x5ba1dcca,0xb743b994,0xece2655e,0x6a466e9f,0x31e7b255,0xdd05d70b,0x86a40bc1,
|
||||
0xd48cdd3e,0x8f2d01f4,0x63cf64aa,0x386eb860,0xbecab3a1,0xe56b6f6b,0x09890a35,0x5228d6ff,
|
||||
0xadd8a7cb,0xf6797b01,0x1a9b1e5f,0x413ac295,0xc79ec954,0x9c3f159e,0x70dd70c0,0x2b7cac0a,
|
||||
0x79547af5,0x22f5a63f,0xce17c361,0x95b61fab,0x1312146a,0x48b3c8a0,0xa451adfe,0xfff07134,
|
||||
0x5f705221,0x04d18eeb,0xe833ebb5,0xb392377f,0x35363cbe,0x6e97e074,0x8275852a,0xd9d459e0,
|
||||
0x8bfc8f1f,0xd05d53d5,0x3cbf368b,0x671eea41,0xe1bae180,0xba1b3d4a,0x56f95814,0x0d5884de,
|
||||
0xf2a8f5ea,0xa9092920,0x45eb4c7e,0x1e4a90b4,0x98ee9b75,0xc34f47bf,0x2fad22e1,0x740cfe2b,
|
||||
0x262428d4,0x7d85f41e,0x91679140,0xcac64d8a,0x4c62464b,0x17c39a81,0xfb21ffdf,0xa0802315,
|
||||
0xbee0a442,0xe5417888,0x09a31dd6,0x5202c11c,0xd4a6cadd,0x8f071617,0x63e57349,0x3844af83,
|
||||
0x6a6c797c,0x31cda5b6,0xdd2fc0e8,0x868e1c22,0x002a17e3,0x5b8bcb29,0xb769ae77,0xecc872bd,
|
||||
0x13380389,0x4899df43,0xa47bba1d,0xffda66d7,0x797e6d16,0x22dfb1dc,0xce3dd482,0x959c0848,
|
||||
0xc7b4deb7,0x9c15027d,0x70f76723,0x2b56bbe9,0xadf2b028,0xf6536ce2,0x1ab109bc,0x4110d576,
|
||||
0xe190f663,0xba312aa9,0x56d34ff7,0x0d72933d,0x8bd698fc,0xd0774436,0x3c952168,0x6734fda2,
|
||||
0x351c2b5d,0x6ebdf797,0x825f92c9,0xd9fe4e03,0x5f5a45c2,0x04fb9908,0xe819fc56,0xb3b8209c,
|
||||
0x4c4851a8,0x17e98d62,0xfb0be83c,0xa0aa34f6,0x260e3f37,0x7dafe3fd,0x914d86a3,0xcaec5a69,
|
||||
0x98c48c96,0xc365505c,0x2f873502,0x7426e9c8,0xf282e209,0xa9233ec3,0x45c15b9d,0x1e608757,
|
||||
0x79005533,0x22a189f9,0xce43eca7,0x95e2306d,0x13463bac,0x48e7e766,0xa4058238,0xffa45ef2,
|
||||
0xad8c880d,0xf62d54c7,0x1acf3199,0x416eed53,0xc7cae692,0x9c6b3a58,0x70895f06,0x2b2883cc,
|
||||
0xd4d8f2f8,0x8f792e32,0x639b4b6c,0x383a97a6,0xbe9e9c67,0xe53f40ad,0x09dd25f3,0x527cf939,
|
||||
0x00542fc6,0x5bf5f30c,0xb7179652,0xecb64a98,0x6a124159,0x31b39d93,0xdd51f8cd,0x86f02407,
|
||||
0x26700712,0x7dd1dbd8,0x9133be86,0xca92624c,0x4c36698d,0x1797b547,0xfb75d019,0xa0d40cd3,
|
||||
0xf2fcda2c,0xa95d06e6,0x45bf63b8,0x1e1ebf72,0x98bab4b3,0xc31b6879,0x2ff90d27,0x7458d1ed,
|
||||
0x8ba8a0d9,0xd0097c13,0x3ceb194d,0x674ac587,0xe1eece46,0xba4f128c,0x56ad77d2,0x0d0cab18,
|
||||
0x5f247de7,0x0485a12d,0xe867c473,0xb3c618b9,0x35621378,0x6ec3cfb2,0x8221aaec,0xd9807626,
|
||||
0xc7e0f171,0x9c412dbb,0x70a348e5,0x2b02942f,0xada69fee,0xf6074324,0x1ae5267a,0x4144fab0,
|
||||
0x136c2c4f,0x48cdf085,0xa42f95db,0xff8e4911,0x792a42d0,0x228b9e1a,0xce69fb44,0x95c8278e,
|
||||
0x6a3856ba,0x31998a70,0xdd7bef2e,0x86da33e4,0x007e3825,0x5bdfe4ef,0xb73d81b1,0xec9c5d7b,
|
||||
0xbeb48b84,0xe515574e,0x09f73210,0x5256eeda,0xd4f2e51b,0x8f5339d1,0x63b15c8f,0x38108045,
|
||||
0x9890a350,0xc3317f9a,0x2fd31ac4,0x7472c60e,0xf2d6cdcf,0xa9771105,0x4595745b,0x1e34a891,
|
||||
0x4c1c7e6e,0x17bda2a4,0xfb5fc7fa,0xa0fe1b30,0x265a10f1,0x7dfbcc3b,0x9119a965,0xcab875af,
|
||||
0x3548049b,0x6ee9d851,0x820bbd0f,0xd9aa61c5,0x5f0e6a04,0x04afb6ce,0xe84dd390,0xb3ec0f5a,
|
||||
0xe1c4d9a5,0xba65056f,0x56876031,0x0d26bcfb,0x8b82b73a,0xd0236bf0,0x3cc10eae,0x6760d264}};
|
||||
Loaded 100 of 372 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user