WAV 8-bits mono #769
-
|
Hi @pschatzmann . I'm trying to use NumberFormatConverterStreamT<int16_t, uint8_t> nfc(kitStream), to transform line-in signal to 8-bits. Later I'd like to copy this signal to wav file but nothing is recorded. If I remove nfc all is ok but 16-bits. How Can I record on WAV 8-bits MONO signal from Line-in? |
Beta Was this translation helpful? Give feedback.
Replies: 11 comments 20 replies
-
|
I don't see any reason why this should not work! You could try to replace the output with a CsVOutput or a HexDumpOutput to see if you get any data... |
Beta Was this translation helpful? Give feedback.
-
|
Hi @pschatzmann . I try all possible but the result always is the same, WAV is empty. This is my sketch. What is wrong? kitStream is configured for AudioBoard audiokit v2.2 ESP32 A1S and works fine with WAV, MP3 playing and WAV 16 bits recording, but not 8-bit recording. kitStrem uses Line-in for recording and Line-out for sound monitoring. |
Beta Was this translation helpful? Give feedback.
-
|
I was testing with the following sketch and was getting the correct result. AudioInfo info(8000, 1, 16);
SineWaveGenerator<int16_t> sineWave( 32000);
GeneratedSoundStream<int16_t> sound( sineWave);
//CSVOutput<uint8_t> out;
HexDumpOutput out(Serial);
WAVEncoder wav;
EncodedAudioStream encoder(&out, &wav);
NumberFormatConverterStreamT<int16_t, uint8_t> converter(encoder);
StreamCopy copier(converter, sound);
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
delay(5000);
// Setup sine wave
auto cfgs = sineWave.defaultConfig();
cfgs.copyFrom(info);
sineWave.begin(info, N_B4);
converter.begin(info);
encoder.begin(converter.audioInfoOut());
out.begin();
Serial.println("Test started...");
}
void loop() {
copier.copy();
}Log I committed the following changes:
I was double checking the hex dump with Chatgpt fmt Subchunk ✅ NOW CORRECT FOR 8-BIT! |
Beta Was this translation helpful? Give feedback.
-
|
Hi @pschatzmann Here attach a minimal sketch. |
Beta Was this translation helpful? Give feedback.
-
|
This was annoying: your example does not even compile: #include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
#include <SD_MMC.h>
AudioBoardStream kitStream(AudioKitEs8388V1);
AudioInfo info(44100, 1, 16);
//File wavfile;
HexDumpOutput out;
NumberFormatConverterStreamT<int16_t, uint8_t> converter(kitStream);
EncodedAudioStream encoder(&out, new WAVEncoder()); // Encoder WAV PCM
StreamCopy copier(encoder, converter);
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
delay(10000);
Serial.println("starting...");
auto ncfg = kitStream.defaultConfig(RXTX_MODE);
ncfg.sample_rate = 44100;
ncfg.input_device = ADC_INPUT_LINE2;
kitStream.begin(ncfg);
// Declaration of wav file output
//wavfile = SD_MMC.open("/test.wav", FILE_WRITE);
// Converter object
// WAV encoder
copier.setSynchAudioInfo(true);
// Assignations
converter.setAudioInfo(info);
// Initializations
converter.begin(info);
encoder.begin(converter.audioInfoOut());
copier.copyN(2);
//wavfile.close();
}
void loop() {}
With the expected log: Your sketch
ps. Don't forget the set up the logging both with AudioToolsLogger.begin() and in the Tools menu, so you get the errors provided by the IDF |
Beta Was this translation helpful? Give feedback.
-
|
Hello @pschatzmann . I have tried the sketch with your considerations, but only I achieve:
Did you test the skecth recording to WAV file? I'm using MULTI. This is my function in my project (you could not compile but please tell me where do you thinks is the problem) On the other hand, if I not use converter, all works fine and WAV is recorder without problems. |
Beta Was this translation helpful? Give feedback.
-
|
Hi again @pschatzmann. I have test your sketch with file instead hexdump and nothing is recorded. I have test the skech in three differents AudioKit boards, without success. I'm using the last version of AudioTools. |
Beta Was this translation helpful? Give feedback.
-
|
Hi @pschatzmann, I achieved that 8-bit converter works with WAV, but line_out doesn't work fine (a constant low frecuency noise is earing). At the end for WAV in necessary that inicialization will be as following: I'm using the last version of AudioTools NOTE: nfc is converter |
Beta Was this translation helpful? Give feedback.
-
|
Hi @pschatzmann I continue having problems with audio out when after convert 16 bits WAV to 8-bits WAV on real time, the audio out through line-out (kitStream board) is bad although the WAV is recorded well. This case not occurs when I don't convert from 16-bits to 8-bits with NumberFormatConverterStreamT Cound you have a look and test it on AudioKit with ES8388 audio codec? I think that there is a bug. I attach two audio files.
|
Beta Was this translation helpful? Give feedback.
-
|
Using ffprobe: Input #0, wav, from 'rec-237373.wav': Input #0, wav, from 'line_out.wav': I guess you are writing 8 bit data but pretend that it is 16 bits! |
Beta Was this translation helpful? Give feedback.
-
|
At the I achieve to obtain 8-bits on WAV and 16-bits for output without lossing quality. Here is the code. |
Beta Was this translation helpful? Give feedback.
I don't see any reason why this should not work!
Did you eventually forgot to call begin on the converter ?
You could try to replace the output with a CsVOutput or a HexDumpOutput to see if you get any data...