Skip to content

Commit e4a8940

Browse files
committed
encode audio
1 parent 69abdf3 commit e4a8940

File tree

8 files changed

+130
-135
lines changed

8 files changed

+130
-135
lines changed

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"editor.defaultFormatter": "ms-vscode.cpptools"
1414
},
1515
"C_Cpp.clang_format_style": "Mozilla",
16-
"window.zoomLevel": 0,
16+
"window.zoomLevel": 2,
1717
"C_Cpp.formatting": "clangFormat",
1818
"C_Cpp.clang_format_sortIncludes": true
1919
}

platformio.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ lib_deps =
4242
NTPClient
4343
ArduinoJson @ 6.21.4
4444
https://github.com/pschatzmann/arduino-audio-tools.git
45+
https://github.com/pschatzmann/arduino-liblame
4546
; https://github.com/pschatzmann/arduino-audiokit.git
4647

4748
board_build.partitions = default_16MB.csv
@@ -69,6 +70,7 @@ lib_deps =
6970
NTPClient
7071
ArduinoJson @ 6.21.4
7172
https://github.com/pschatzmann/arduino-audio-tools.git
73+
https://github.com/pschatzmann/arduino-liblame
7274
; https://github.com/pschatzmann/arduino-audiokit.git
7375

7476

@@ -92,4 +94,5 @@ lib_deps =
9294
NTPClient
9395
ArduinoJson @ 6.21.4
9496
https://github.com/pschatzmann/arduino-audio-tools.git
97+
https://github.com/pschatzmann/arduino-liblame
9598
; https://github.com/pschatzmann/arduino-audiokit.git

src/display.cpp

Lines changed: 115 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "display.h"
2-
#include "svgs/svgs.h"
2+
// #include "svgs/svgs.h"
33

44
// Add more as needed, with appropriate external declarations
55

@@ -24,121 +24,122 @@ bool
2424
Display::showEmotion(const String& emotion)
2525
{
2626
const unsigned short* bitmap = nullptr;
27+
return true;
2728

28-
if (!emotion) {
29-
bitmap = image_smiley;
30-
// } else if (emotion == "grinning") {
31-
// bitmap = image_grinning;
32-
// } else if (emotion == "grin") {
33-
// bitmap = image_grin;
34-
// } else if (emotion == "joy") {
35-
// bitmap = image_joy;
36-
} else if (emotion == "smiley") {
37-
bitmap = image_smiley;
38-
// } else if (emotion == "smile") {
39-
// bitmap = image_smile;
40-
// } else if (emotion == "sweat_smile") {
41-
// bitmap = image_sweat_smile;
42-
// } else if (emotion == "laughing") {
43-
// bitmap = image_laughing;
44-
// } else if (emotion == "innocent") {
45-
// bitmap = image_innocent;
46-
// } else if (emotion == "wink") {
47-
// bitmap = image_wink;
48-
// } else if (emotion == "neutral_face") {
49-
// bitmap = image_neutral_face;
50-
// } else if (emotion == "expressionless") {
51-
// bitmap = image_expressionless;
52-
// } else if (emotion == "unamused") {
53-
// bitmap = image_unamused;
54-
// } else if (emotion == "sweat") {
55-
// bitmap = image_sweat;
56-
// } else if (emotion == "pensive") {
57-
// bitmap = image_pensive;
58-
// } else if (emotion == "confused") {
59-
// bitmap = image_confused;
60-
// } else if (emotion == "confounded") {
61-
// bitmap = image_confounded;
62-
// } else if (emotion == "kissing") {
63-
// bitmap = image_kissing;
64-
// } else if (emotion == "kissing_heart") {
65-
// bitmap = image_kissing_heart;
66-
// } else if (emotion == "kissing_smiling_eyes") {
67-
// bitmap = image_kissing_smiling_eyes;
68-
// } else if (emotion == "angry") {
69-
// bitmap = image_angry;
70-
// } else if (emotion == "cry") {
71-
// bitmap = image_cry;
72-
// } else if (emotion == "persevere") {
73-
// bitmap = image_persevere;
74-
// } else if (emotion == "triumph") {
75-
// bitmap = image_triumph;
76-
// } else if (emotion == "disappointed_relieved") {
77-
// bitmap = image_disappointed_relieved;
78-
// } else if (emotion == "frowning") {
79-
// bitmap = image_frowning;
80-
// } else if (emotion == "anguished") {
81-
// bitmap = image_anguished;
82-
// } else if (emotion == "fearful") {
83-
// bitmap = image_fearful;
84-
// } else if (emotion == "weary") {
85-
// bitmap = image_weary;
86-
// } else if (emotion == "cold_sweat") {
87-
// bitmap = image_cold_sweat;
88-
// } else if (emotion == "scream") {
89-
// bitmap = image_scream;
90-
// } else if (emotion == "astonished") {
91-
// bitmap = image_astonished;
92-
// } else if (emotion == "flushed") {
93-
// bitmap = image_flushed;
94-
// } else if (emotion == "sleeping") {
95-
// bitmap = image_sleeping;
96-
// } else if (emotion == "dizzy_face") {
97-
// bitmap = image_dizzy_face;
98-
// } else if (emotion == "dizzy_face") {
99-
// bitmap = image_dizzy_face;
100-
// } else if (emotion == "mask") {
101-
// bitmap = image_mask;
102-
// } else if (emotion == "slightly_frowning_face") {
103-
// bitmap = image_slightly_frowning_face;
104-
// } else if (emotion == "slightly_smiling_face") {
105-
// bitmap = image_slightly_smiling_face;
106-
// } else if (emotion == "face_with_rolling_eyes") {
107-
// bitmap = image_face_with_rolling_eyes;
108-
// } else if (emotion == "zipper_mouth_face") {
109-
// bitmap = image_zipper_mouth_face;
110-
// } else if (emotion == "money_mouth_face") {
111-
// bitmap = image_money_mouth_face;
112-
// } else if (emotion == "nerd_face") {
113-
// bitmap = image_nerd_face;
114-
} else if (emotion == "thinking_face") {
115-
bitmap = image_thinking_face;
116-
// } else if (emotion == "hugging_face") {
117-
// bitmap = image_hugging_face;
118-
} else if (emotion == "cowboy_hat_face") {
119-
bitmap = image_cowboy_hat_face;
120-
// } else if (emotion == "nauseated_face") {
121-
// bitmap = image_nauseated_face;
122-
// } else if (emotion == "rofl") {
123-
// bitmap = image_rofl;
124-
// } else if (emotion == "drooling_face") {
125-
// bitmap = image_drooling_face;
126-
// } else if (emotion == "sneezing_face") {
127-
// bitmap = image_sneezing_face;
128-
// } else if (emotion == "face_with_raised_eyebrow") {
129-
// bitmap = image_face_with_raised_eyebrow;
130-
// } else if (emotion == "starstruck") {
131-
// bitmap = image_starstruck;
132-
}
29+
// if (!emotion) {
30+
// bitmap = image_smiley;
31+
// // } else if (emotion == "grinning") {
32+
// // bitmap = image_grinning;
33+
// // } else if (emotion == "grin") {
34+
// // bitmap = image_grin;
35+
// // } else if (emotion == "joy") {
36+
// // bitmap = image_joy;
37+
// } else if (emotion == "smiley") {
38+
// bitmap = image_smiley;
39+
// // } else if (emotion == "smile") {
40+
// // bitmap = image_smile;
41+
// // } else if (emotion == "sweat_smile") {
42+
// // bitmap = image_sweat_smile;
43+
// // } else if (emotion == "laughing") {
44+
// // bitmap = image_laughing;
45+
// // } else if (emotion == "innocent") {
46+
// // bitmap = image_innocent;
47+
// // } else if (emotion == "wink") {
48+
// // bitmap = image_wink;
49+
// // } else if (emotion == "neutral_face") {
50+
// // bitmap = image_neutral_face;
51+
// // } else if (emotion == "expressionless") {
52+
// // bitmap = image_expressionless;
53+
// // } else if (emotion == "unamused") {
54+
// // bitmap = image_unamused;
55+
// // } else if (emotion == "sweat") {
56+
// // bitmap = image_sweat;
57+
// // } else if (emotion == "pensive") {
58+
// // bitmap = image_pensive;
59+
// // } else if (emotion == "confused") {
60+
// // bitmap = image_confused;
61+
// // } else if (emotion == "confounded") {
62+
// // bitmap = image_confounded;
63+
// // } else if (emotion == "kissing") {
64+
// // bitmap = image_kissing;
65+
// // } else if (emotion == "kissing_heart") {
66+
// // bitmap = image_kissing_heart;
67+
// // } else if (emotion == "kissing_smiling_eyes") {
68+
// // bitmap = image_kissing_smiling_eyes;
69+
// // } else if (emotion == "angry") {
70+
// // bitmap = image_angry;
71+
// // } else if (emotion == "cry") {
72+
// // bitmap = image_cry;
73+
// // } else if (emotion == "persevere") {
74+
// // bitmap = image_persevere;
75+
// // } else if (emotion == "triumph") {
76+
// // bitmap = image_triumph;
77+
// // } else if (emotion == "disappointed_relieved") {
78+
// // bitmap = image_disappointed_relieved;
79+
// // } else if (emotion == "frowning") {
80+
// // bitmap = image_frowning;
81+
// // } else if (emotion == "anguished") {
82+
// // bitmap = image_anguished;
83+
// // } else if (emotion == "fearful") {
84+
// // bitmap = image_fearful;
85+
// // } else if (emotion == "weary") {
86+
// // bitmap = image_weary;
87+
// // } else if (emotion == "cold_sweat") {
88+
// // bitmap = image_cold_sweat;
89+
// // } else if (emotion == "scream") {
90+
// // bitmap = image_scream;
91+
// // } else if (emotion == "astonished") {
92+
// // bitmap = image_astonished;
93+
// // } else if (emotion == "flushed") {
94+
// // bitmap = image_flushed;
95+
// // } else if (emotion == "sleeping") {
96+
// // bitmap = image_sleeping;
97+
// // } else if (emotion == "dizzy_face") {
98+
// // bitmap = image_dizzy_face;
99+
// // } else if (emotion == "dizzy_face") {
100+
// // bitmap = image_dizzy_face;
101+
// // } else if (emotion == "mask") {
102+
// // bitmap = image_mask;
103+
// // } else if (emotion == "slightly_frowning_face") {
104+
// // bitmap = image_slightly_frowning_face;
105+
// // } else if (emotion == "slightly_smiling_face") {
106+
// // bitmap = image_slightly_smiling_face;
107+
// // } else if (emotion == "face_with_rolling_eyes") {
108+
// // bitmap = image_face_with_rolling_eyes;
109+
// // } else if (emotion == "zipper_mouth_face") {
110+
// // bitmap = image_zipper_mouth_face;
111+
// // } else if (emotion == "money_mouth_face") {
112+
// // bitmap = image_money_mouth_face;
113+
// // } else if (emotion == "nerd_face") {
114+
// // bitmap = image_nerd_face;
115+
// } else if (emotion == "thinking_face") {
116+
// bitmap = image_thinking_face;
117+
// // } else if (emotion == "hugging_face") {
118+
// // bitmap = image_hugging_face;
119+
// } else if (emotion == "cowboy_hat_face") {
120+
// bitmap = image_cowboy_hat_face;
121+
// // } else if (emotion == "nauseated_face") {
122+
// // bitmap = image_nauseated_face;
123+
// // } else if (emotion == "rofl") {
124+
// // bitmap = image_rofl;
125+
// // } else if (emotion == "drooling_face") {
126+
// // bitmap = image_drooling_face;
127+
// // } else if (emotion == "sneezing_face") {
128+
// // bitmap = image_sneezing_face;
129+
// // } else if (emotion == "face_with_raised_eyebrow") {
130+
// // bitmap = image_face_with_raised_eyebrow;
131+
// // } else if (emotion == "starstruck") {
132+
// // bitmap = image_starstruck;
133+
// }
133134

134-
if (bitmap != nullptr) {
135-
displayBitmap(bitmap, 0, 0, BITMAP_WIDTH, BITMAP_HEIGHT);
136-
return true;
137-
} else {
138-
// Emotion not found, you could clear the display or leave as is.
139-
// tft.fillScreen(TFT_BLACK); // Optional: clear screen if emotion not found
140-
return false;
141-
}
135+
// if (bitmap != nullptr) {
136+
// displayBitmap(bitmap, 0, 0, BITMAP_WIDTH, BITMAP_HEIGHT);
137+
// return true;
138+
// } else {
139+
// // Emotion not found, you could clear the display or leave as is.
140+
// // tft.fillScreen(TFT_BLACK); // Optional: clear screen if emotion not
141+
// found return false;
142+
// }
142143
}
143144

144145
void

src/flash.h

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/flash_manager.cpp

Whitespace-only changes.

src/main.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ normal_loop()
105105
now.replace(":", "-");
106106
int randomPart = random(1000, 9999);
107107

108-
mic.startRecording("/" + now + "--" + randomPart + ".audio");
108+
mic.startRecording("/" + now + "--" + randomPart + ".mp3");
109109
} else if (touchPinPressedCycles > MAX_TOUCH_BUTTON_CYCLES_TO_RESPOND) {
110110
mic.record();
111111
}

src/mic.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ I2SStream i2sStream;
1212
SPIClass sd_spi;
1313
File file;
1414

15+
EncodedAudioStream encoder(&file, new MP3EncoderLAME());
1516
StreamCopy copier;
1617

1718
MicManager::MicManager(int bckPin,
@@ -41,14 +42,14 @@ MicManager::MicManager(int bckPin,
4142
cfg.pin_bck = bckPin;
4243
cfg.pin_ws = wsPin;
4344
cfg.pin_data = dataPin; // output
44-
45-
sd_spi.begin(sdCLKPin, sdMISOPin, sdMOSIPin, sdCSPin);
4645
}
4746

4847
void
4948
MicManager::startRecording(String fileName)
5049
{
5150

51+
sd_spi.begin(sd_CLK, sd_MISO, sd_MOSI, sd_CS);
52+
5253
if (!SD.begin(sd_CS, sd_spi)) {
5354
printf("SD card failed to initialize");
5455
return;
@@ -60,7 +61,7 @@ MicManager::startRecording(String fileName)
6061
copier.setCheckAvailableForWrite(false);
6162

6263
i2sStream.begin(cfg);
63-
copier.begin(file, i2sStream);
64+
copier.begin(encoder, i2sStream);
6465
}
6566

6667
void

src/mic.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
#ifndef MIC_MANAGER_HPP
2-
#define MIC_MANAGER_HPP
1+
#ifndef MIC_HPP
2+
#define MIC_HPP
33

44
#include "AudioTools.h"
55
#include "SD.h"
66
#include "driver/i2s.h"
77
#include <Arduino.h>
88

9+
#include "AudioCodecs/AudioEncoded.h"
10+
#include "AudioCodecs/CodecMP3LAME.h"
11+
912
using AudioBufferCallback = void (*)(void);
1013

1114
class MicManager
@@ -27,4 +30,4 @@ class MicManager
2730
int sd_CS, sd_MISO, sd_MOSI, sd_CLK;
2831
};
2932

30-
#endif // MIC_MANAGER_HPP
33+
#endif // MIC_HPP

0 commit comments

Comments
 (0)