How would I go about making a Voice Recording and Playback device (INMP 441 to DFPlayerMini) #1508
-
Hey there, fairly new to coding but been trying to wrap my head around this sorta stuff for a very imminent uni project. I have been struggling to get i2s drivers to work on previous code and came across a video from Andreas talking about this miracle library! I was wondering how I would create a code that allows me to systematically record and save files onto an sd card I have in my DFPlayerMini module, and then would be able to play them back. I will attach the code below to show where I got up to before coming across this. Any help would be so appreciated as I am short for time to properly learn all the ins and outs myself. Amazing work Phil! `#include "SoftwareSerial.h" // Use pins 2 and 3 to communicate with DFPlayer Mini static const uint8_t MIC_BCK_PIN = 15; // BCK pin for microphone SoftwareSerial softwareSerial(PIN_MP3_RX, PIN_MP3_TX); volatile bool buttonPressed = false; int lastEncoderPosition = 0; // Last known position of the rotary encoder enum Mode { PLAY, RECORD }; void setup() { pinMode(ROTARY_ENCODER_CLK, INPUT_PULLUP); if (!SD.begin()) { if (player.begin(softwareSerial)) { // Initialize I2S interface for microphone attachInterrupt(digitalPinToInterrupt(ROTARY_ENCODER_SW), buttonInterrupt, FALLING); void loop() { if (currentMode == RECORD) { // Smooth rotation handling if (buttonPressed) { void buttonInterrupt() { int readEncoder() { void playSelectedFile(int fileIndex) { void switchModes() { void startRecording() { // Create buffer to store recorded audio data // Read audio data from I2S interface // Save recorded audio data to SD card // Free buffer memory Serial.println("Recording stopped."); void saveToFile(uint8_t *data, size_t size) { // Write audio data to file |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
^^ forgot to mention this is just code for trying to write data into the chip. I was going to attack playback only after I had any success with this. Cheers guys |
Beta Was this translation helpful? Give feedback.
-
The goal of my library was to implement things like this with a minimum number of lines of code: The shorter the code, the easier it is to reason about it and to find errors or to evaluate alternatives. I suggest that you have a look at this example. I think it will be pretty difficult to use the DFPlayerMini since this seems to be able to process mp3 files only, and mp3 encoding on the ESP32 is possible, but it is a pain to get it working and you would need probably an ESP32 version which has PSRAM. Should you be interested to use this library: please read the Wiki! |
Beta Was this translation helpful? Give feedback.
The goal of my library was to implement things like this with a minimum number of lines of code: The shorter the code, the easier it is to reason about it and to find errors or to evaluate alternatives.
I suggest that you have a look at this example.
I think it will be pretty difficult to use the DFPlayerMini since this seems to be able to process mp3 files only, and mp3 encoding on the ESP32 is possible, but it is a pain to get it working and you would need probably an ESP32 version which has PSRAM.
Should you be interested to use this library: please read the Wiki!