Two I2S Input to .wav #1966
-
Hi, |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 19 replies
-
You would use 2 I2SStream and one EncodedAudioStream if you want to write to 1 file only. I think the easiest would be just to read one frame of each I2SStream and write it to the EncodedAudioStream. Assuming you have bits_per_sample=16 it is something like this: int16_t frame[2];
void loop() {
i2s_1.read((uint8_t*) frame, sizeof(frame));
wav.write((uint8_t*) frame, sizeof(frame))
i2s_2.read((uint8_t*) frame, sizeof(frame));
wav.write((uint8_t*) frame, sizeof(frame));
} |
Beta Was this translation helpful? Give feedback.
-
I already told you: the frame size must be 2! You have only 2 input channels and not 512! |
Beta Was this translation helpful? Give feedback.
-
If it is distorted you need to do some measurements: the SD drive is just too slow to write that amount of data in the available time! |
Beta Was this translation helpful? Give feedback.
-
If you want to have correct timing you need to calculate the time in terms of samples. For 5 seconds you need to process 5 * 44100 loops (using your current sample rate) I suggest that you reduce the sample rate down to 8000 and the start to figure out where the limit is... |
Beta Was this translation helpful? Give feedback.
You would use 2 I2SStream and one EncodedAudioStream if you want to write to 1 file only. I think the easiest would be just to read one frame of each I2SStream and write it to the EncodedAudioStream.
Assuming you have bits_per_sample=16 it is something like this: