Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - madhav_iiith

Pages: [1]
1
Audio / Memory problem with buffer
« on: July 12, 2009, 02:20:41 am »
I have to synchronize both audio and video That's why I am using Pthreads. I dont have any idea abt the SFML threads. btw I have solved the problem. Thanks

2
Audio / Memory problem with buffer
« on: July 12, 2009, 01:25:22 am »
Code: [Select]

#include<iostream>
#include <SFML/Audio.hpp>
#include<pthread.h>
#include<cstdlib>
using namespace std;

void* SoundCapture(void *unncessary){
string AudioName;
int SampleRate = 44100;bool z=1;int FileCount =1;
sf::SoundBufferRecorder *Recorder=new sf::SoundBufferRecorder;
time_t sec1,sec2;
time(&sec1);
while(1)
{
time(&sec2);
if(z ){
Recorder->Start(SampleRate);z =0;
}
if(sec2-sec1==30)
{
sec1=sec2;
z=1;
Recorder->Stop();
char arr[100];
sprintf(arr,"%d",FileCount);
FileCount++;
string temp=arr;
AudioName ="Audio_"+temp+".wav";


const sf::SoundBuffer &B = Recorder->GetBuffer();
B.SaveToFile(AudioName);
free(Recorder);
Recorder = new sf::SoundBufferRecorder;


}
}
}
main(){
pthread_t t;
        int a;
        //pthread_create(&t[0],NULL,CaptureVideo,(void *)a[0]);
        pthread_create(&t,NULL,SoundCapture,(void *)a);
        void *status;
        pthread_join(t,&status);
        pthread_exit(NULL);
}


I need to use Threads in my code because I need to record Video simultaneously for my application


to compile dont forget add -lpthread

While the code is running we can infer its memory requirements from top command
i Linux

3
Audio / Memory problem with buffer
« on: July 12, 2009, 12:31:50 am »
This code is causing me segFault
Code: [Select]

SampleRate = 44100;bool z=1;int FileCount =1;
 sf::SoundBufferRecorder *Recorder=new sf::SoundBufferRecorder;
time_t sec1,sec2;
time(&sec1);
while(1)
{
 time(&sec2);
      if(z ){
                 Recorder->Start(SampleRate);z =0;
      }
if(sec2-sec1==30)
  {
                sec1=sec2;
                z=1;
                Recorder->Stop();
                char arr[100];
                          sprintf(arr,"%d",FileCount);
                           FileCount++;
                        string temp=arr;
                         AudioName ="Audio_"+temp+".wav";

 
                         const sf::SoundBuffer &B = Recorder->GetBuffer();
                                 B.SaveToFile(AudioName);
                    free(Recorder);
                     Recorder = new sf::SoundBufferRecorder;


   }
}

               On running the above code for 200minutes with 2gb ram crashes . I dont know why but for every file that I create 5MB of more memory is required which can be inferred from the "top"  command in Linux

4
Audio / Memory problem with buffer
« on: July 11, 2009, 11:00:59 pm »
I need to create a wav file every 1 minute once the audio capture starts .  I am doing so with the above mentioned code. Now My system crashes after it records for 5-10 minutes. Now I saw the memory it was consuming by the help of top command in Linux . The memory required by my program is continuously increasing and Hence finally resulting in a crash

5
Audio / Memory problem with buffer
« on: July 11, 2009, 07:50:03 pm »
Hi,
     I have to record some audio and after every 5 minutes I need to create a new wav file from the audio captured.  This process of recording must continue until I stop it Here  is the psuedo code of what I am doing

Code: [Select]

bool flag =True;
while( true){
                           if(flag is True)
                           flag = false
                            Recorder.Start(SampleRate);


                             if( timeInterval  is  5 minutes )
                                      then
                                             flag = true
                                             Recorder.stop() //stop the recorder
                                             //Obtain the buffer  and the write it into a file
                                              sf::SoundBuffer Buffer = Recorder->GetBuffer();
                                               Buffer.SaveToFile(SomeAudioFile.wav)
}

When I implement this in the form of a code and use top command to see the memory requirements  of this process . The momory consumption is increasing very rapildly. within 10 minutes after the start of this program The memory it was using was 1.5 gb  Is it because of not clearance of the soundbuffer ??  I checked for the member functions of class SoundBuffer But I could not find any function which can clear the memory. Can any one suggest what to do . If I cannot solve this problem I need to search for other software  which can record audio  :(  :( :(  After a lot of searching for 15 hours I could find this and I want to use it coz its easy. Please help me resolve this problem . Thanks in advance

Regards,
Nasini Madhava Rao

Pages: [1]
anything