Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e3bc35493 | ||
|
|
3349608b11 |
No files matched your search
@@ -86,3 +86,10 @@ jobs:
|
|||||||
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 ./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 ./midi
|
||||||
|
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: arduino/arduino-lint-action@v1
|
||||||
|
with:
|
||||||
|
library-manager: 'update'
|
||||||
@@ -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
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
class AudioOutputNullSlow : public AudioOutput
|
class AudioOutputNullSlow : public AudioOutput
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AudioOutputNullSlow(int hertz) { SetRate(hertz); };
|
AudioOutputNullSlow() { };
|
||||||
~AudioOutputNullSlow() {};
|
~AudioOutputNullSlow() {};
|
||||||
virtual bool begin() { samples = 0; startms = millis(); return true; }
|
virtual bool begin() { samples = 0; startms = millis(); return true; }
|
||||||
virtual bool ConsumeSample(int16_t sample[2]) {
|
virtual bool ConsumeSample(int16_t sample[2]) {
|
||||||
@@ -34,7 +34,10 @@ class AudioOutputNullSlow : public AudioOutput
|
|||||||
// sometimes to let the main loop running
|
// sometimes to let the main loop running
|
||||||
constexpr int everylog2 = 10;
|
constexpr int everylog2 = 10;
|
||||||
if ((++samples & ((1<<everylog2)-1)) == 0) {
|
if ((++samples & ((1<<everylog2)-1)) == 0) {
|
||||||
delay(1000/(hertz >> everylog2));
|
if (hertz > 0) {
|
||||||
|
// simulate real time
|
||||||
|
delay(1000/(hertz >> everylog2));
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -8,7 +8,13 @@
|
|||||||
#include "AudioFileSourceICYStream.h"
|
#include "AudioFileSourceICYStream.h"
|
||||||
#include "AudioFileSourceBuffer.h"
|
#include "AudioFileSourceBuffer.h"
|
||||||
#include "AudioGeneratorMP3.h"
|
#include "AudioGeneratorMP3.h"
|
||||||
|
#if AUDIO
|
||||||
|
#pragma message("Outputting audio")
|
||||||
|
#include "AudioOutputLinuxDSP.h"
|
||||||
|
#else
|
||||||
|
#pragma message("No audio")
|
||||||
#include "AudioOutputNullSlow.h"
|
#include "AudioOutputNullSlow.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// To run, set your ESP8266 build to 160MHz, update the SSID info, and upload.
|
// To run, set your ESP8266 build to 160MHz, update the SSID info, and upload.
|
||||||
|
|
||||||
@@ -23,6 +29,8 @@ const char* password = STAPSK;
|
|||||||
|
|
||||||
// Randomly picked URL
|
// Randomly picked URL
|
||||||
const char *URL="http://kvbstreams.dyndns.org:8000/wkvi-am";
|
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";
|
//const char *URL="http://icecast.radiofrance.fr/franceinter-lofi.mp3";
|
||||||
|
|
||||||
AudioGeneratorMP3 *mp3;
|
AudioGeneratorMP3 *mp3;
|
||||||
@@ -82,7 +90,7 @@ void setup()
|
|||||||
file->RegisterMetadataCB(MDCallback, (void*)"ICY");
|
file->RegisterMetadataCB(MDCallback, (void*)"ICY");
|
||||||
buff = new AudioFileSourceBuffer(file, 2048);
|
buff = new AudioFileSourceBuffer(file, 2048);
|
||||||
buff->RegisterStatusCB(StatusCallback, (void*)"buffer");
|
buff->RegisterStatusCB(StatusCallback, (void*)"buffer");
|
||||||
out = new AudioOutputNullSlow(44100);
|
out = new AudioOutputNullSlow();
|
||||||
mp3 = new AudioGeneratorMP3();
|
mp3 = new AudioGeneratorMP3();
|
||||||
mp3->RegisterStatusCB(StatusCallback, (void*)"mp3");
|
mp3->RegisterStatusCB(StatusCallback, (void*)"mp3");
|
||||||
mp3->begin(buff, out);
|
mp3->begin(buff, out);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ fi
|
|||||||
|
|
||||||
THISLIB=$(pwd)/../..
|
THISLIB=$(pwd)/../..
|
||||||
MAD=$(ls ${THISLIB}/src/libmad/*.c)
|
MAD=$(ls ${THISLIB}/src/libmad/*.c)
|
||||||
|
PAGER=${PAGER:-less}
|
||||||
|
|
||||||
cd ${ESP8266ARDUINO}/tests/host
|
cd ${ESP8266ARDUINO}/tests/host
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ if [ "$1" = "clean" ]; then
|
|||||||
exit 0
|
exit 0
|
||||||
elif [ "$1" = diff ]; then
|
elif [ "$1" = diff ]; then
|
||||||
cd ${THISLIB}/examples
|
cd ${THISLIB}/examples
|
||||||
diff -u StreamMP3FromHTTP/StreamMP3FromHTTP.ino ${ino}/${ino}.ino
|
diff -u StreamMP3FromHTTP/StreamMP3FromHTTP.ino ${ino}/${ino}.ino | ${PAGER}
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
echo ""
|
echo ""
|
||||||
@@ -27,30 +28,39 @@ else
|
|||||||
echo " $0"
|
echo " $0"
|
||||||
echo " $0 clean"
|
echo " $0 clean"
|
||||||
echo " $0 diff"
|
echo " $0 diff"
|
||||||
echo " FORCE32=0 $0 (run with valgrind)"
|
echo " AUDIO=a VALGRIND=v FORCE32=f $0"
|
||||||
echo " FORCE32=1 $0 (run in 32 bits)"
|
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 "variable ESP8266ARDUINO must point to esp8266 Arduino core directory"
|
||||||
echo ""
|
echo ""
|
||||||
[ "$1" = "-h" ] && exit 0
|
[ "$1" = "-h" ] && exit 0
|
||||||
sleep 1
|
sleep 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -z "${FORCE32}" ] && FORCE32=0
|
run=""
|
||||||
|
|
||||||
if [ "${FORCE32}" = 0 ]; then
|
[ -z "${FORCE32}" ] && FORCE32=0
|
||||||
run=valgrind
|
[ -z "${AUDIO}" ] && AUDIO=1
|
||||||
else
|
|
||||||
run=
|
if [ "${AUDIO}" = 1 ]; then
|
||||||
|
run="${run} padsp"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "${VALGRIND}" = 1 ]; then
|
||||||
|
FORCE32=0
|
||||||
|
run="$run valgrind"
|
||||||
|
fi
|
||||||
|
|
||||||
|
touch ${THISLIB}/examples/${ino}/${ino}.ino # rebuild
|
||||||
|
|
||||||
eval make FORCE32=${FORCE32} -j \
|
eval make FORCE32=${FORCE32} -j \
|
||||||
USERCSOURCES=\"${MAD}\" \
|
USERCSOURCES=\"${MAD}\" \
|
||||||
USERCXXSOURCES=\"${THISLIB}/src/AudioFileSourceBuffer.cpp ${THISLIB}/src/AudioLogger.cpp ${THISLIB}/src/AudioGeneratorMP3.cpp ${THISLIB}/src/AudioFileSourceICYStream.cpp ${THISLIB}/src/AudioFileSourceHTTPStream.cpp\" \
|
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/\" \
|
USERCFLAGS=\"-I${THISLIB}/src/ -DAUDIO=${AUDIO}\" \
|
||||||
${THISLIB}/examples/${ino}/${ino}
|
${THISLIB}/examples/${ino}/${ino}
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
$run ./bin/${ino}/${ino} "$@"
|
$run ./bin/${ino}/${ino} "$@"
|
||||||
stty sane
|
stty sane
|
||||||
|
|
||||||
+1
-1
@@ -14,7 +14,7 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/earlephilhower/ESP8266Audio"
|
"url": "https://github.com/earlephilhower/ESP8266Audio"
|
||||||
},
|
},
|
||||||
"version": "1.8",
|
"version": "1.8.1",
|
||||||
"homepage": "https://github.com/earlephilhower/ESP8266Audio",
|
"homepage": "https://github.com/earlephilhower/ESP8266Audio",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"SPI": "1.0",
|
"SPI": "1.0",
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
name=ESP8266Audio
|
name=ESP8266Audio
|
||||||
version=1.8
|
version=1.8.1
|
||||||
author=Earle F. Philhower, III
|
author=Earle F. Philhower, III
|
||||||
maintainer=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.
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
// 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 "AudioOutputMixer.h"
|
||||||
|
#include "AudioOutputNull.h"
|
||||||
|
#include "AudioOutputSerialWAV.h"
|
||||||
|
#include "AudioOutputSPDIF.h"
|
||||||
|
#include "AudioOutputSPIFFSWAV.h"
|
||||||
|
#include "AudioOutputSTDIO.h"
|
||||||
|
#include "AudioOutputULP.h"
|
||||||
Reference in new issue
Block a user