Skip to content

Commit 2e53474

Browse files
committed
AudioActions and audiokit examples quality
1 parent 027793b commit 2e53474

File tree

10 files changed

+997
-764
lines changed

10 files changed

+997
-764
lines changed

examples/examples-basic-api/basic-a2dp-audiokit/basic-a2dp-audiokit.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ void setup() {
2323
a2dp_sink.start("AudioKit");
2424
}
2525

26-
void loop() {}
26+
void loop() {
27+
kit.processActions();
28+
}

examples/examples-player/player-sd-audiokit/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ I found some cheap [AI Thinker ESP32 Audio Kit V2.2](https://docs.ai-thinker.com
66

77
You dont need to bother about any wires because everything is on one nice board. Just just need to install the dependencies:
88

9+
### Note
10+
11+
The log level has been set to Info to help you to identify any problems. Please change it to AudioLogger::Warning to get the best sound quality!
12+
13+
914
## Dependencies
1015

1116
- https://github.com/pschatzmann/arduino-audio-tools

examples/examples-player/player-sd-audiokit/player-sd-audiokit.ino

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,25 @@ const char *startFilePath="/";
1818
const char* ext="mp3";
1919
int speedMz = 10;
2020
AudioSourceSdFat source(startFilePath, ext, PIN_AUDIO_KIT_SD_CARD_CS, speedMz);
21-
AudioKitStream i2s;
21+
AudioKitStream kit;
2222
MP3DecoderHelix decoder;
23-
AudioPlayer player(source, i2s, decoder);
23+
AudioPlayer player(source, kit, decoder);
2424

2525

2626
void setup() {
2727
Serial.begin(115200);
2828
AudioLogger::instance().begin(Serial, AudioLogger::Info);
2929

3030
// setup output
31-
auto cfg = i2s.defaultConfig(TX_MODE);
32-
i2s.begin(cfg);
31+
auto cfg = kit.defaultConfig(TX_MODE);
32+
kit.begin(cfg);
3333

3434
// setup player
35+
player.setVolume(0.7);`
3536
player.begin();
3637
}
3738

3839
void loop() {
3940
player.copy();
41+
kit.processActions();
4042
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# A Simple Icecast Streaming Audio Player
2+
3+
Compared to the regular URLStream, and ICYStream provides audio Metadata.
4+
5+
<img src="https://pschatzmann.github.io/arduino-audio-tools/resources/audio-toolkit.png" alt="Audio Kit" />
6+
7+
You dont need to bother about any wires because everything is on one nice board. Just just need to install the dependencies:
8+
9+
I also demonstrate how to assign your own actions to the buttons of the audio kit.
10+
11+
### Note
12+
13+
The log level has been set to Info to help you to identify any problems. Please change it to AudioLogger::Warning to get the best sound quality!
14+
15+
16+
### Dependencies
17+
18+
- https://github.com/pschatzmann/arduino-audio-tools
19+
- https://github.com/pschatzmann/arduino-libhelix
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/**
2+
* @file player-url-kit.ino
3+
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-player/player-url-audiokit/README.md
4+
*
5+
* @author Phil Schatzmann
6+
* @copyright GPLv3
7+
*/
8+
9+
// set this in AudioConfig.h or here after installing https://github.com/pschatzmann/arduino-libhelix.git
10+
#define USE_HELIX
11+
12+
#include "AudioTools.h"
13+
#include "AudioCodecs/CodecMP3Helix.h"
14+
#include "AudioDevices/ESP32AudioKit/AudioKit.h"
15+
16+
using namespace audio_tools;
17+
18+
const char *urls[] = {
19+
"http://centralcharts.ice.infomaniak.ch/centralcharts-128.mp3",
20+
"http://centraljazz.ice.infomaniak.ch/centraljazz-128.mp3",
21+
"http://centralrock.ice.infomaniak.ch/centralrock-128.mp3",
22+
"http://centralcountry.ice.infomaniak.ch/centralcountry-128.mp3",
23+
"http://centralfunk.ice.infomaniak.ch/centralfunk-128.mp3"
24+
};
25+
const char *wifi = "wifi";
26+
const char *password = "password";
27+
28+
ICYStream urlStream(wifi, password);
29+
AudioSourceURL source(urlStream, urls, "audio/mp3");
30+
AudioKitStream kit;
31+
MP3DecoderHelix decoder;
32+
AudioPlayer player(source, kit, decoder);
33+
bool active;
34+
35+
void next() {
36+
player.next();
37+
}
38+
39+
void previous() {
40+
player.previous();
41+
}
42+
43+
void stopResume(){
44+
active=!active;
45+
if (active){
46+
player.stop();
47+
} else{
48+
player.play();
49+
}
50+
}
51+
52+
// Arduino setup
53+
void setup() {
54+
Serial.begin(115200);
55+
AudioLogger::instance().begin(Serial, AudioLogger::Info);
56+
57+
// setup navigation
58+
kit.addAction(PIN_KEY1, stopResume);
59+
kit.addAction(PIN_KEY4, next);
60+
kit.addAction(PIN_KEY3, previous);
61+
62+
// setup output
63+
auto cfg = kit.defaultConfig(TX_MODE);
64+
kit.begin(cfg);
65+
66+
// setup player
67+
player.setVolume(0.7);`
68+
player.begin();
69+
}
70+
71+
// Arduino loop
72+
void loop() {
73+
player.copy();
74+
kit.processActions();
75+
}

0 commit comments

Comments
 (0)