Compare commits
5 Commits
179bba0829
...
6110583190
| Author | SHA1 | Date | |
|---|---|---|---|
| 6110583190 | |||
| f47f87cd5f | |||
| 25d5183a73 | |||
| dc7c4bbb17 | |||
| cd47e00a7d |
95
.github/workflows/pr-or-master-push.yml
vendored
95
.github/workflows/pr-or-master-push.yml
vendored
@@ -1,95 +0,0 @@
|
||||
# Run whenever a PR is generated or updated.
|
||||
|
||||
# Most jobs check out the code, ensure Python3 is installed, and for build
|
||||
# tests the ESP8266 toolchain is cached when possible to speed up execution.
|
||||
|
||||
name: ESP8266Audio
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
|
||||
build-esp8266:
|
||||
name: Build ESP8266
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
chunk: [0, 1, 2, 3, 4]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- name: Build Sketches
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
TRAVIS_TAG: ${{ github.ref }}
|
||||
BUILD_TYPE: build
|
||||
BUILD_MOD: 5
|
||||
BUILD_REM: ${{ matrix.chunk }}
|
||||
run: |
|
||||
bash ./tests/common.sh
|
||||
|
||||
|
||||
build-esp32:
|
||||
name: Build ESP-32
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
chunk: [0, 1, 2, 3, 4]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- name: Build Sketches
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
TRAVIS_TAG: ${{ github.ref }}
|
||||
BUILD_TYPE: build_esp32
|
||||
BUILD_MOD: 5
|
||||
BUILD_REM: ${{ matrix.chunk }}
|
||||
run: |
|
||||
bash ./tests/common.sh
|
||||
|
||||
# Run host test suite under valgrind for runtime checking of code.
|
||||
host-tests:
|
||||
name: Host tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- name: Run host tests
|
||||
env:
|
||||
TRAVIS_BUILD_DIR: ${{ github.workspace }}
|
||||
TRAVIS_TAG: ${{ github.ref }}
|
||||
run: |
|
||||
sudo dpkg --add-architecture i386
|
||||
sudo apt-get update
|
||||
sudo apt-get install valgrind lcov gcc-multilib g++-multilib libc6-dbg:i386
|
||||
cd ./tests/host/
|
||||
make
|
||||
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 ./midi
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: arduino/arduino-lint-action@v1
|
||||
with:
|
||||
library-manager: 'update'
|
||||
32
.gitignore
vendored
Normal file
32
.gitignore
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
.DS_Store
|
||||
.pio
|
||||
.vscode
|
||||
|
||||
# kicad Temporary files
|
||||
*.000
|
||||
*.bak
|
||||
*.bck
|
||||
*.kicad_pcb-bak
|
||||
*.kicad_sch-bak
|
||||
*.kicad_prl
|
||||
*.sch-bak
|
||||
*~
|
||||
_autosave-*
|
||||
*.tmp
|
||||
*-save.pro
|
||||
*-save.kicad_pcb
|
||||
fp-info-cache
|
||||
|
||||
# Netlist files (exported from Eeschema)
|
||||
*.net
|
||||
|
||||
# Autorouter files (exported from Pcbnew)
|
||||
*.dsn
|
||||
*.ses
|
||||
|
||||
# Exported BOM files
|
||||
*.xml
|
||||
*.csv
|
||||
|
||||
# other files
|
||||
CAD/Leo_muziekdoos_ESP32/~$ESP32 Pins.xlsx
|
||||
1
.piopm
1
.piopm
@@ -1 +0,0 @@
|
||||
{"type": "library", "name": "ESP8266Audio", "version": "1.9.2", "spec": {"owner": "earlephilhower", "id": 1964, "name": "ESP8266Audio", "requirements": null, "url": null}}
|
||||
@@ -24,7 +24,7 @@
|
||||
//#ifndef ESP32 // No LittleFS there, yet
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <LITTLEFS.h>
|
||||
#include <LittleFS.h>
|
||||
|
||||
#include "AudioFileSource.h"
|
||||
#include "AudioFileSourceFS.h"
|
||||
@@ -32,8 +32,8 @@
|
||||
class AudioFileSourceLittleFS : public AudioFileSourceFS
|
||||
{
|
||||
public:
|
||||
AudioFileSourceLittleFS() : AudioFileSourceFS(LITTLEFS) { };
|
||||
AudioFileSourceLittleFS(const char *filename) : AudioFileSourceFS(LITTLEFS, filename) {};
|
||||
AudioFileSourceLittleFS() : AudioFileSourceFS(LittleFS) { };
|
||||
AudioFileSourceLittleFS(const char *filename) : AudioFileSourceFS(LittleFS, filename) {};
|
||||
// Others are inherited from base
|
||||
};
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
AudioOutputI2S
|
||||
Base class for I2S interface port
|
||||
@@ -313,3 +314,333 @@ bool AudioOutputI2S::stop()
|
||||
i2sOn = false;
|
||||
return true;
|
||||
}
|
||||
// /*
|
||||
// AudioOutputI2S
|
||||
// Base class for I2S interface port
|
||||
|
||||
// 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/>.
|
||||
// */
|
||||
|
||||
// #include <Arduino.h>
|
||||
// #ifdef ESP32
|
||||
// #include "driver/i2s.h"
|
||||
// #if defined ESP_ARDUINO_VERSION_VAL
|
||||
// #if (ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(2, 0, 0)
|
||||
// #include "soc/soc_caps.h"
|
||||
// #define ESP_V2
|
||||
// #define I2S_FORMAT (I2S_COMM_FORMAT_STAND_I2S)
|
||||
// #endif
|
||||
// #else
|
||||
// #define I2S_FORMAT (I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB)
|
||||
// #endif
|
||||
// #elif defined(ARDUINO_ARCH_RP2040) || defined(ESP8266)
|
||||
// #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;
|
||||
// this->i2sOn = false;
|
||||
// this->dma_buf_count = dma_buf_count;
|
||||
// if (output_mode != EXTERNAL_I2S && output_mode != INTERNAL_DAC && output_mode != INTERNAL_PDM) {
|
||||
// output_mode = EXTERNAL_I2S;
|
||||
// }
|
||||
// this->output_mode = output_mode;
|
||||
// this->use_apll = use_apll;
|
||||
|
||||
// //set defaults
|
||||
// mono = false;
|
||||
// bps = 16;
|
||||
// channels = 2;
|
||||
// hertz = 44100;
|
||||
// bclkPin = 26;
|
||||
// wclkPin = 25;
|
||||
// doutPin = 22;
|
||||
// SetGain(1.0);
|
||||
// }
|
||||
|
||||
// bool AudioOutputI2S::SetPinout()
|
||||
// {
|
||||
// #ifdef ESP32
|
||||
// if (output_mode == INTERNAL_DAC || output_mode == INTERNAL_PDM)
|
||||
// return false; // Not allowed
|
||||
|
||||
// i2s_pin_config_t pins = {
|
||||
// .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;
|
||||
// return false;
|
||||
// #endif
|
||||
// }
|
||||
|
||||
// bool AudioOutputI2S::SetPinout(int bclk, int wclk, int dout)
|
||||
// {
|
||||
// bclkPin = bclk;
|
||||
// wclkPin = wclk;
|
||||
// doutPin = dout;
|
||||
// if (i2sOn)
|
||||
// return SetPinout();
|
||||
|
||||
// return true;
|
||||
// }
|
||||
// #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;
|
||||
// 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
|
||||
// }
|
||||
// #elif defined(ESP8266)
|
||||
// if (i2sOn)
|
||||
// i2s_end();
|
||||
// #elif defined(ARDUINO_ARCH_RP2040)
|
||||
// stop();
|
||||
// #endif
|
||||
// i2sOn = false;
|
||||
// }
|
||||
|
||||
// bool AudioOutputI2S::SetRate(int hz)
|
||||
// {
|
||||
// // TODO - have a list of allowable rates from constructor, check them
|
||||
// this->hertz = hz;
|
||||
// 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;
|
||||
// }
|
||||
|
||||
// bool AudioOutputI2S::SetBitsPerSample(int bits)
|
||||
// {
|
||||
// if ( (bits != 16) && (bits != 8) ) return false;
|
||||
// this->bps = bits;
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// bool AudioOutputI2S::SetChannels(int channels)
|
||||
// {
|
||||
// if ( (channels < 1) || (channels > 2) ) return false;
|
||||
// this->channels = channels;
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// bool AudioOutputI2S::SetOutputModeMono(bool mono)
|
||||
// {
|
||||
// this->mono = mono;
|
||||
// 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 SOC_I2S_SUPPORTS_DAC
|
||||
// mode = (i2s_mode_t)(mode | I2S_MODE_DAC_BUILT_IN);
|
||||
// #endif
|
||||
// }
|
||||
// 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_FORMAT);
|
||||
// if (output_mode == INTERNAL_DAC)
|
||||
// {
|
||||
// #if SOC_I2S_SUPPORTS_DAC
|
||||
// comm_fmt = (i2s_comm_format_t)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 = 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)
|
||||
// {
|
||||
// #if SOC_I2S_SUPPORTS_DAC
|
||||
// i2s_set_pin((i2s_port_t)portNo, NULL);
|
||||
// i2s_set_dac_mode(I2S_DAC_CHANNEL_BOTH_EN);
|
||||
// #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.setBCLK(bclkPin);
|
||||
// I2S.setDOUT(doutPin);
|
||||
// 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];
|
||||
// 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;
|
||||
// }
|
||||
// #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);
|
||||
// }
|
||||
// // Deprecated. Use i2s_write
|
||||
// // return i2s_write_bytes((i2s_port_t)portNo, (const char *)&s32, sizeof(uint32_t), 0);
|
||||
// size_t bytes_written;
|
||||
// i2s_write((i2s_port_t)portNo, (const char*)&s32, sizeof(uint32_t), &bytes_written, 0);
|
||||
// return 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)
|
||||
// return !!I2S.write((void*)ms, 4);
|
||||
// #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);
|
||||
// }
|
||||
// }
|
||||
// #elif defined(ARDUINO_ARCH_RP2040)
|
||||
// I2S.flush();
|
||||
// #endif
|
||||
// }
|
||||
|
||||
// bool AudioOutputI2S::stop()
|
||||
// {
|
||||
// if (!i2sOn)
|
||||
// return false;
|
||||
|
||||
// #ifdef ESP32
|
||||
// i2s_zero_dma_buffer((i2s_port_t)portNo);
|
||||
// #elif defined(ARDUINO_ARCH_RP2040)
|
||||
// I2S.end();
|
||||
// #endif
|
||||
// i2sOn = false;
|
||||
// return true;
|
||||
// }
|
||||
Reference in New Issue
Block a user