Fred
1
I tried record2.ino with Muse Luxe. I recorded 2 wavs, one with USB cable plugged in, the other without the USB cable.
There is a background noise on both wavs and the one without the USB cable is more accentuated.
Is there a solution to increase the recording quality?
Can you share the wiring diagram of the microphone with the codec ?
please share your recording
Fred
3
Recording without USB cable:
Pretty bad indeed! let me check the code 
Fred
5
The code come from “record2.ino”, I added wifi connection and I switch frequency to 22Khz
// ***** Muse LUXE as a simple recorder*****
// -- records sound on a SD .wav file (BUTTON_PAUSE to start/stop recording)
// -- plays it
///////////////////////////////////////////////
#include "museWrover.h"
#include "ESP_I2S.h"
#include "wav_header.h"
#include "driver/gpio.h"
#include "SPI.h"
#include "SD.h"
#include "FS.h"
#include <WiFi.h>
#include "esp_wifi.h" // Include ESP-IDF WiFi control functions
const char *ssid = "mySSID"; // Change this to your WiFi SSID
const char *password = "myPassword"; // Change this to your WiFi password
// Serveur TCP
const char* serverIP = "myServerIP"; // IP du serveur
const uint16_t serverPort = 8765; // Port du serveur
WiFiClient client;
uint32_t timestamp = 0;
int volume = 100; // 0...100
int microVol = 96; // 0...96
File f;
// Initialize your objects and variables
I2SClass i2s;
ES8388 es;
pcm_wav_header_t H = PCM_WAV_HEADER_DEFAULT(0, 16, 22000, 2);
void setup() {
Serial.begin(115200);
// Connexion au WiFi
Serial.print("Connexion à ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
esp_wifi_set_max_tx_power(15);
Serial.println("\nWiFi connecté !");
Serial.print("Adresse IP : ");
Serial.println(WiFi.localIP());
// Connexion au serveur TCP
Serial.print("Connexion à ");
Serial.print(serverIP);
Serial.print(":");
Serial.println(serverPort);
if (client.connect(serverIP, serverPort)) {
Serial.println("Connexion réussie !");
// Envoyer un message au serveur
client.println("Hello, serveur !");
} else {
Serial.println("Échec de connexion !");
}
timestamp = millis();
////// GPIOs init
// power enable
gpio_reset_pin(GPIO_PA_EN);
gpio_set_direction(GPIO_PA_EN, GPIO_MODE_OUTPUT);
gpio_set_level(GPIO_PA_EN, HIGH);
// PAUSE
gpio_reset_pin(BUTTON_PAUSE);
gpio_set_direction(BUTTON_PAUSE, GPIO_MODE_INPUT);
gpio_set_pull_mode(BUTTON_PAUSE, GPIO_PULLUP_ONLY);
// SD init
SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
SPI.setFrequency(1000000);
if( !SD.begin(SD_CS))
{
printf( "SD init failed\n");
while(1);
}
printf("SD init OK\n");
//////I2S init
i2s.setPins(I2S_BCLK, I2S_LRCK, I2S_SDOUT, I2S_SDIN, I2S_MCLK);
if (!i2s.begin(I2S_MODE_STD, 22000, I2S_DATA_BIT_WIDTH_16BIT, I2S_SLOT_MODE_MONO, I2S_STD_SLOT_LEFT)) {
Serial.println("Failed to initialize I2S!");
while (1); // do nothing
}
if (!i2s.configureRX(22000, I2S_DATA_BIT_WIDTH_16BIT, I2S_SLOT_MODE_MONO, I2S_RX_TRANSFORM_NONE) ){
Serial.println("Failed to initialize RX Channel!");
while (1); // do nothing
}
if (!i2s.configureTX(22000, I2S_DATA_BIT_WIDTH_16BIT, I2S_SLOT_MODE_STEREO)) {
Serial.println("Failed to initialize TX Channel!");
while (1); // do nothing
}
// codec ES8388 init
Serial.printf("Connect to ES8388 codec... ");
while (not es.begin(IIC_DATA, IIC_CLK))
{
Serial.printf("Failed!\n");
while(1);
}
Serial.printf("OK\n");
// volumes
es.volume(ES8388::ES_MAIN, volume);
es.volume(ES8388::ES_OUT1, volume);
es.mute(ES8388::ES_OUT1, false);
es.mute(ES8388::ES_MAIN, false);
es.microphone_volume(microVol);
es.ALC(false);
es.Amp_D(true);
}
void loop() {
#define T 1024
size_t t;
char buf[T/2];
char bufb[T];
int tb;
int L;
if (gpio_get_level(BUTTON_PAUSE) == 0)
{
while(gpio_get_level(BUTTON_PAUSE) == 0) delay(10);
f = SD.open("/record.wav", "w");
f.seek(PCM_WAV_HEADER_SIZE); // leave room for the header
printf("recording...\n");
L = 0;
uint8_t M, N;
while(gpio_get_level(BUTTON_PAUSE) == 1)
{
t = i2s.readBytes(buf, T/2);
// one channel ==> two channels
for(int i=0;i<t;i=i+2)
{
bufb[i+i] = buf[i];
bufb[i+i+1] = buf[i+1];
bufb[i+i+2] = buf[i];
bufb[i+i+3] = buf[i+1];
}
f.write((const uint8_t*)bufb, t+t);
L = L + 2*t;
}
f.seek(0);
// to refresh size values
H.descriptor_chunk.chunk_size = L + PCM_WAV_HEADER_SIZE ;
H.data_chunk.subchunk_size = L;
// write the header
f.write((uint8_t*)&H, PCM_WAV_HEADER_SIZE);
f.seek(L + PCM_WAV_HEADER_SIZE);
f.close();
while(gpio_get_level(BUTTON_PAUSE) == 0) delay(10);
printf("playing...\n");
f = SD.open("/record.wav", "r");
f.seek(PCM_WAV_HEADER_SIZE); // skip the header
do
{
tb = f.read((uint8_t*)bufb, T);
i2s.write((uint8_t*)bufb, (size_t)tb);
}while(tb > 0);
f.close();
}
delay(100);
}
Have you tried to turn on ALC?