Reputation: 443
I am using a superpowered recorder for recording, I am recording audio then adding track, So adding the track if I edit the first track and rerecord on first track it's mixing the audio with the old one instead of overwriting the audio. Is there any function available in superpowered SDK to overwrite the audio?. Any help would be much appreciated.
Thank you.
Upvotes: 0
Views: 178
Reputation: 1
You have to analyze the recorded pcm file and overwrite the file from the part you want to re-record. SuperPowered doesn't have that feature.
FILE *fin;
float runTime=0;
//PCM HEADER
int SampleRate_24to27=0;// 441000,...,8000
int ByteRate_28to31=0;
short MonoStreo_32to33=0;
short BitPerSample_34to35=0;
int DataChunkSize_40to43=0;
std::string file = GS->mWritePath;
file.append("rec1.wav");
fin=fopen(file.c_str(),"rb");
fseek(fin,24,SEEK_SET);
fread(&SampleRate_24to27 , sizeof(int) , 1, fin);
printf("SampleRate %d \n",SampleRate_24to27);
fseek(fin,28,SEEK_SET);
fread(&ByteRate_28to31 , sizeof(int) , 1, fin);
printf("ByteRate %d \n",ByteRate_28to31);
fseek(fin,32,SEEK_SET);
fread(&MonoStreo_32to33 , sizeof(short) , 1, fin);
printf("MonoStreo %d \n",MonoStreo_32to33);
fseek(fin,34,SEEK_SET);
fread(&BitPerSample_34to35 , sizeof(short) , 1, fin);
printf("BitPerSample %d \n",BitPerSample_34to35);
fseek(fin,40,SEEK_SET);
fread(&DataChunkSize_40to43 , sizeof(int) , 1, fin);
printf("DataChunkSize %d \n",DataChunkSize_40to43);
runTime=(float)(((float)DataChunkSize_40to43/(float)(SampleRate_24to27*MonoStreo_32to33)));
printf("duration sec = %fsec\n", runTime);
printf("duration min = %3.2fmin", (float)runTime/60);
fclose(fin);
int savePos = 0;
savePos = 44+reRecordStartSec*(SampleRate_24to27*MonoStreo_32to33);
// 44 -> HEADER SIZE
// 4sec * (SampleRate_24to27*MonoStreo_32to33)
char buf[SPLIT_BYTE]; //1000KB
std::string file1 = GS->mWritePath;
file1.append("rec1.wav");
std::string file2 = GS->mWritePath;
file2.append("rec2.wav");
FILE * rfp, * wfp;
wfp = fopen(file1.c_str(), "rb+"); //src
rfp = fopen(file2.c_str(), "rb"); //dst
fseek(wfp, savePos, SEEK_SET);
fseek(rfp, 44, SEEK_SET);// dst header skip
long count = 0;
while (feof(rfp) == 0) //
{
count = fread(buf, sizeof(char), SPLIT_BYTE, rfp);
fwrite(buf, sizeof(char), count, wfp);
memset(buf, 0, SPLIT_BYTE);
}
fclose(rfp);
fclose(wfp);
Upvotes: 0