Go Down

Topic: Record by 2 microphone with TMRpcm (Read 945 times) previous topic - next topic

sbq

May 22, 2019, 08:46 pm Last Edit: May 23, 2019, 05:58 pm by sbq
I try to use 2 microphone recording audio, but I don't know why it fails.

I first start with 1 microphone with following code, and everything is fine.

Code: [Select]
#include <SD.h>
#include <SPI.h>
#include <TMRpcm.h>

#define SD_ChipSelectPin 4

TMRpcm audio; // create an object for use in this sketch

void setup() {

  Serial.println("begin");

  Serial.begin(115200);
 
  if (!SD.begin(SD_ChipSelectPin)) { 
    Serial.println("SD Fail");
    return;
  }else{
    Serial.println("SD OK");
  }
  // The audio library needs to know which CS pin to use for recording
  audio.CSPin = SD_ChipSelectPin;
  //start recording
  audio.startRecording("test1.wav",2000,A0);
  Serial.println("Begin");
  delay(20000);
  audio.stopRecording("test1.wav");
  Serial.println("End");
  return;
 
}


void loop() {
}


Then I try to record by two microphone. But the second wav file could play, the first one cannot open. I have no idea why it happen.

Code: [Select]
#include <SD.h>
#include <SPI.h>
#include <TMRpcm.h>

#define SD_ChipSelectPin 4

TMRpcm audio; // create an object for use in this sketch
TMRpcm audio2;

void setup() {

  Serial.println("begin");

  Serial.begin(115200);
 
  if (!SD.begin(SD_ChipSelectPin)) { 
    Serial.println("SD Fail");
    return;
  }else{
    Serial.println("SD OK");
  }
  // The audio library needs to know which CS pin to use for recording
  audio.CSPin = SD_ChipSelectPin;
  audio2.CSPin = SD_ChipSelectPin;
  //start recording
  audio.startRecording("test1.wav",2000,A0);
  audio2.startRecording("test2.wav",2000,A1);
  Serial.println("Begin");
  delay(20000);
  audio.stopRecording("test1.wav");
  audio2.stopRecording("test2.wav");
  Serial.println("End");
  return;
 
}


void loop() {
}

Grumpy_Mike

Code: [Select]
audio.stopRecording("test1.wav");
  audio2.stopRecording("test1.wav");

Should that not be
Code: [Select]
audio.stopRecording("test1.wav");
  audio2.stopRecording("test2.wav");

sbq

Sorry it's a typo. I code 'test2.wav' in my code.

Grumpy_Mike

Don't you mean to say you typed in your code for this question and did not copy and paste it from the IDE?

Go Up