I am using genuine arduino due. after strugling alot finaly i am through to sd card data writng.
now new problem is when i up load ad card audi recording, every thing fine serial monitor says recording. when i play back nothing comes out . when i check the card with computer only wav header and data is written. but no data is writen on the cardany can any body help me out to record and play back standered aeduino libraries.please help me out , please. i want to record stereo 12 bit 20khz sampling that is my target. please help me out. thanks
Have you formatted your SD card as fat16/fat32? And are you creating a new recording everytime? As far as i know i only use SD card as a media to save .txt and .csv files.
I am facing problem in writing data to wav file with arduino due. it writes wav header but no data . i have seen in wave header construction in my file recording wich is part of example last line says DATA and it is put under single line comment like this // DATA Has any body any idea what should be written there so that it writes data to wav file Thanks for help.
I can NOT offer any direct help...
but perhaps looking at the libs available for the Adafruit WaveShield (one of them offers not only .wav playback..but recording).. to see how they tackle it?
i have arduino due genuine. i want to record sound on sd card. i am using example from ide that is analog audio sd recording. codes are from arduino ide, sd card is working fine , i can log data from analog read funtion . sd audio recording sd card is initilised audio begin function starts. when i stat recording it says recording audio, on stop it says wave header writen succesfuly. on play back there is no audio. when i check the card with computer , wav header is written the word data, rest all is blank. i could not figure out what is happening. no error but no recording , can any body give me clue PLEASE.
thanks for the help
You have created 3 threads on this same topic now:
http://forum.arduino.cc/index.php?topic=480649
http://forum.arduino.cc/index.php?topic=480609
DON'T CROSS POST!!!!!!!!!!!!!!!!!!!!
REPORTED
@sidhudalwinder, do not hijack. Other post removed.
@sidhudalwinder, what @pert said. Threads merged.
can not figure out why t is not writing data to record file. no error genrated. i am using example code example from arduino ide. please help me out. Thanks
i am using example code example from arduino ide.
You MUST post YOUR code here.
You MUST explain what SD shield you are using.
You MUST explain how you formatted the SD card.
i have geuine arduino due. i use hiletgo stag able shield.chip select is 4. sd cardformation is 16-32 . arduino writes the file test.wav writes header also but no data is written. I am using stander arduino example from auto analog audio >sd audio sd audio auto. that comes with my wave, my recording and sd recording. no error nothing monitor say sd card ok audio begin and recording ,no of samples per second bla bla. but no data is entered on sd card that is the issue. thanks for any help.
I am using stander arduino example from auto analog audio >sd audio sd audio auto. that comes with my wave,
The harder that you make it to help you, the fewer responses you will get. Not many people will go the the trouble to hunt that down. POST your code or provide a link to it.
ok here are all my codes
Auto Analog Audio Library Information:
#define SD_CS_PIN 10
#define AUDIO_DEBUG
#define RECORD_DEBUG
const char newWavFile[] = "test.wav";
/*********************************************************/
#include <SPI.h>
#include <SD.h>
#include <AutoAnalogAudio.h>
/*********************************************************/
AutoAnalog aaAudio;
File myFile;
File recFile;
/*********************************************************/
#include "myWAV.h"
#include "myRecording.h"
/*********************************************************/
void setup() {
Serial.begin(115200);
if (!SD.begin(SD_CS_PIN)) {
Serial.println("SD init failed!");
return;
}
Serial.println("SD ok\nAnalog Audio Begin");
aaAudio.begin(1, 1); // Start AAAudio with ADC & DAC
aaAudio.autoAdjust = 0; // Disable automatic timer adjustment
}
/*********************************************************/
uint32_t displayTimer = 0;
void loop() {
if(millis()-displayTimer>1000){
displayTimer = millis();
if(counter){
Serial.print("Samples per Second: ");
Serial.println(counter * MAX_BUFFER_SIZE);
}
counter = 0;
}
if (Serial.available()) {
char input = Serial.read();
switch (input) {
case '1': playAudio("M8b24kM.wav"); break; //Play a *.wav file by name - 8bit, 24khz, Mono
case '2': playAudio("M8b24kS.wav"); break; //Play 8bit, 24khz, Stereo
case '3': playAudio("M16b24kS.wav"); break; //Play 16bit, 24khz, Stereo
case '4': playAudio("M8b44kST.wav"); break; //Play 8bit, 44khz, Stereo
case '5': channelSelection = 0; break; //Play the audio on DAC0
case '6': channelSelection = 1; break; //Play the audio on DAC1
case '7': channelSelection = 2; break; //Play the audio on DAC0 & DAC1
case '8': Serial.println("OK"); break;
case '9': startRecording(newWavFile,11000); break; //Start recording @11khz,8-bit,Mono
case '0': stopRecording(newWavFile,11000); break; //Stop the recording and finalize the file
case 'p': playAudio(newWavFile); break; //Play back the recorded audio
case 'D': SD.remove(newWavFile); break; //Delete the file and start fresh
}
}
}
/*********************************************************/
Next time, please use the code tag button, </> on the menu.
Thanks - Moderator
there is difficulty in sending all thr
/*********************************************************/
/* WAV HEADER STRUCTURE */
struct wavStruct {
const char chunkID[4] = {'R','I','F','F'};
uint32_t chunkSize = 36; //Size of (entire file in bytes - 12 bytes) or (data size + 36)
const char format[4] = {'W','A','V','E'};
const char subchunkID[4] = {'f','m','t',' '};
const uint32_t subchunkSize = 16;
const uint32_t audioFormat = numChannels; //PCM == 1
uint32_t numChannels = 2; //1=Mono, 2=Stereo
uint32_t sampleRate = 11000;
uint32_t byteRate = 11000; //== SampleRate * NumChannels * BitsPerSample/12
uint16_t blockAlign = 2; //== NumChannels * BitsPerSample/16
uint16_t bitsPerSample = 12; //8,16,32...
const char subChunk2ID[4]= {'d','a','t','a'};
uint32_t subChunk2Size = 0; //== NumSamples * NumChannels * BitsPerSample/8
Data //The audio data
};
/*********************************************************/
uint32_t counter = 0;
/*********************************************************/
void ADC_Handler(void){ //ADC Interrupt triggered by ADC sampling completion
aaAudio.getADC();
if(recFile){
recFile.write(aaAudio.adcBuffer,MAX_BUFFER_SIZE); //Write the data to SD as it is available
counter++;
}
}
/*********************************************************/
void startRecording(const char *fileName, uint32_t sampleRate){
#if defined (RECORD_DEBUG)
Serial.print("Start Recording: ");
Serial.println(fileName);
#endif
if(recFile){
aaAudio.adcInterrupts(false);
recFile.close();
}
if (myFile) { //Close any open playback files & disable the DAC
aaAudio.disableDAC();
myFile.close();
}
recFile = SD.open(fileName,FILE_WRITE); //Open the file for writing
if(!recFile){
#if defined (RECORD_DEBUG)
Serial.println("Failed to open file");
#endif
return;
}
recFile.seek(0); //Write a blank WAV header
uint8_t bb = 0;
for(int i=0; i<44; i++){
recFile.write(bb);
}
aaAudio.adcBitsPerSample = 12; //Configure AAAudio
aaAudio.setSampleRate(sampleRate);
aaAudio.getADC();
aaAudio.getADC();
aaAudio.adcInterrupts(true);
}
/*********************************************************/
void createWavHeader(const char *fileName, uint32_t sampleRate ){
if(!SD.exists(fileName)){
#if defined (RECORD_DEBUG)
Serial.println("File does not exist, please write WAV/PCM data starting at byte 44");
#endif
return;
}
recFile = SD.open(fileName,FILE_WRITE);
if(recFile.size() <= 44){
#if defined (RECORD_DEBUG)
Serial.println("File contains no data, exiting");
#endif
recFile.close();
return;
}
wavStruct wavHeader;
wavHeader.chunkSize = recFile.size()-8;
wavHeader.numChannels = numChannels;
wavHeader.sampleRate = sampleRate;
wavHeader.byteRate = sampleRate * wavHeader.numChannels * wavHeader.bitsPerSample / 8;
wavHeader.blockAlign = wavHeader.numChannels * wavHeader.bitsPerSample / 8;
wavHeader.bitsPerSample = bitsPerSample;
wavHeader.subChunk2Size = recFile.size() - 44;
#if defined (RECORD_DEBUG)
Serial.print("WAV Header Write ");
#endif
recFile.seek(0);
if( recFile.write((byte*)&wavHeader,44) > 0){
#if defined (RECORD_DEBUG)
Serial.println("OK");
}else{
Serial.println("Failed");
#endif
}
recFile.close();
}
/*********************************************************/
void stopRecording(const char *fileName, uint32_t sampleRate){
aaAudio.adcInterrupts(false); //Disable the ADC interrupt
recFile.close(); //Close the file
createWavHeader(fileName,sampleRate); //Add appropriate header info, to make it a valid *.wav file
#if defined (RECORD_DEBUG)
Serial.println("Recording Stopped");
#endif
}
/*********************************************************/
ee skeches at atime so i am sending one at atime. this is second one
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.
ok here are all my codes
Really? Just how did you manage to compile that code without supplying playAudio(), startRecording() and stopRecording()?
Without the audio stuff, can you write to the SD card?
sir there are total three files 1 is swich case, 2 is my recording 3is wav recording all are interrelated. start and stop opration works fine,it writes the header but no data that is the issue . since there is no data it can not plat back, i am dude on this i could not figure out what is happening. i took this example from arduino IDE . if any one has clue please help me out i will highly oblise for same. Thanks
@sidhudalwinder, stop cross-posting. Last warning.
Threads merged. Again.
but no data that is the issue .
It's about f**king time you told us what the issue is.
Now, tell us why there is no data. We can NOT see what you are doing. You MUST tell us.
What do you think you are recording? Do you have some way to see what you think you are writing to the file? If that means hacking the library, DO IT!
I am so sorry , ican not explane, please pardon me for this . in fact i do not know how it works still my mistake , please forgive me every body thanks