Sound & Music

Moderators: Sephiroth
Number of threads: 597
Number of posts: 1201

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
long time sound recording problems Posted by cbodapati on 12 Mar 2004 at 10:54 PM
hello
I have developed a program which listens to the user's and responds with some answer from the database. when I use this software for some time like 1.5 to 2 hrs, at some abrupt time the application suddenly stops recording and there ends the process.
Iam coding in VC++ 6.0, WinAPI.
OS - XP
RAM - 128MB
please help


Regards
srikanth
Report
Re: long time sound recording problems Posted by jason on 13 Mar 2004 at 3:02 AM
Could be a million and one things. 128mb of ram is not very high when using XP, add that to a possible memory leak in your code and you might find the application is quitting due to out of memory problems.

Have a look at the task manager whilst your code is running. Also, are you catching exceptions in your code when requesting memory from the heap?

Regards, Jason
Report
Re: long time sound recording problems Posted by cbodapati on 13 Mar 2004 at 6:24 AM
thanks jason
please suggest me how to check the memory leaks.
the task manager always shows 1226kb consumption of memory and 2-5 of the cpu load randomely.
as of now Iam not catching any of the exceptions.
if the requested memory is not allocated the what to do.
In the same condition(system configuration) a winamp(upto 4hrs continous audio) is woking fine.

please suggest


Regards
srikanth

Report
Re: long time sound recording problems Posted by jason on 13 Mar 2004 at 11:51 AM
This message was edited by jason at 2004-3-14 1:25:33

This message was edited by jason at 2004-3-13 11:52:15

There are several utilities that monitor memory and will show the number of handles to memory in the heap. Borland C++ Builder comes with one but i'm not sure about MS Visual Studio as I haven't had it long. You need to run the utility and your application simultaneously and see if your application fails to free any dynamically allocated memory on exit.

Let's say you need a block of memory from the heap.
Typically in C you might use:

int *myPtr = malloc( sizeof( int ) *1000 );
if ( myPtr )
{
/* do something with the memory here */
}
else
{
/* handle the error */
}

In C++ you might use the try, throw and catch statements.

try
{
// allocate memory for a new class on the heap
MyClass *myClassPtr;
myClassPtr = new MyClass;
}
catch ( Exception &e )
{
cout << "Error allocating memory!" << endl;
}

Hope this helps. Regards, Jason




Report
Re: long time sound recording problems Posted by cbodapati on 13 Mar 2004 at 9:18 PM
Thanks Mr.Jason
i'll try the code and come back.

can you give me some guidance about how to have an entry in
msconfig >>startup. How to add and delete an entry completely.


thanks


Regards
srikanth

Report
Re: long time sound recording problems Posted by jason on 14 Mar 2004 at 1:42 AM
The command to run processes at startup is contained in the registry. I think its somewhere like

HKEY_LOCAL_MACHINE->SOFTWARE->Microsoft->Windows->CurrentVersion->Run

Use regedit to have a look. You can delete the key of the process you don't want the system to load at startup.

Don't quote me on this as I haven't really got involved with the registry. You can alter the registry programmatically - see MSDN for details.

Regards, Jason
Report
Re: long time sound recording problems Posted by Jonathan on 17 Mar 2004 at 1:17 PM
Hi,

: I have developed a program which listens to the user's and responds with some answer from the database. when I use this software for some time like 1.5 to 2 hrs, at some abrupt time the application suddenly stops recording and there ends the process.
: Iam coding in VC++ 6.0, WinAPI.
: OS - XP
: RAM - 128MB
: please help
:
I'm guessing this is the exact same "abrupt time" everytime you do this, right? I've read the threads on memory leaks etc and very much doubt it's to do with that. It's much more likely to do with you reaching the maximum range of a given datatype.

Take your signed int, for example. It has a maximum value of 2^31 - 1. That may seem a big value, until you think like this:-

44100 sampling rate * 2 channels * 2 bytes per sample = 176400 bytes of data per second

2^31 / 176400 = 12173 seconds = 202 minutes ~= 3 and a bit hours

You may be using these values in a different way, and encounter this issue before my suggested limit of 3 hours like you mention - in terms of orders of magnitude we're pretty close. I very much suspect that this issue may be at the heart of your problems.

If you look on my list of stuff to do with AMaMP I've already flagged this up as "Something ugly that will have to be dealt with some day". Using 64 bit integers is a possible solution, depending upon their availability. Of course, once you've dealt with stuff inside your app you still have to look at things at an OS level, which is probably going to be even more nasty.

I guess a little extension is possible by using an unsigned int...

Jonathan

###
for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
(tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
/(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

Report
Re: long time sound recording problems Posted by jason on 17 Mar 2004 at 1:39 PM
Hi Jonathan & Srikanth.

Yeh, I can see where you're coming from Jonathan. A quick question though Srikanth, does your program monitor ie "listen" to the user's vocal input, or does it "record" it? Maybe your program does both I don't know, but I would guess that the integer overflow issue described by Jonathan would probably apply more to recording.

Anyway, keep us informed.

Regards, Jason
Report
Re: long time sound recording problems Posted by cbodapati on 17 Mar 2004 at 10:43 PM
Hi Jonathan & jason

iam recording the data to the hard disk.
i moniter the signal,display the time domain and the frequency domain
of the signal.
iam using 8-bit unsigned,mono,6000 sampling rate.

iam recording 3sec for every 4sec.
is it ok to every time deallocate and reallocate the buffers.
or is it a redundant job.



Regards
srikanth

Report
Re: long time sound recording problems Posted by jason on 19 Mar 2004 at 1:43 PM
: Hi Jonathan & jason
:
: iam recording the data to the hard disk.
: i moniter the signal,display the time domain and the frequency domain
: of the signal.
: iam using 8-bit unsigned,mono,6000 sampling rate.
:
: iam recording 3sec for every 4sec.
: is it ok to every time deallocate and reallocate the buffers.
: or is it a redundant job.
:
:
:
: Regards
: srikanth
:
:

Hi. I guess it is a redundant job.

Regards, Jason

Report
Re: long time sound recording problems Posted by cbodapati on 23 Mar 2004 at 6:55 AM
hi
will any use of third party software help me out of this problem so that they manage memory handinlg in a better way ?



Regards
srikanth

Report
Re: long time sound recording problems Posted by Jonathan on 23 Mar 2004 at 9:32 AM
Hi,

Sorry I didn't get back to you for a while...health problems got in the way and I forgot your question was still needing a reply.

: will any use of third party software help me out of this problem so
: that they manage memory handinlg in a better way ?
:
I very much doubt that the Win32 APIs themselves would be the problem. I can sit and listen to music on my PC for many hours without running into problems, so internally they probably just pass the buffers of data you give them on to the soundcard driver. So I struggle to believe it's memory handling either, as we've already determined that stays stable.

If you look at loop conditions and other conditionals, you may well be able to see some that would cause the program to quit if a variable rolled over from its maximum range and went back to zero, or a large negative value (depends on whether you're using signed or unsinged ints). That'd be my first thing to look at.

It's nasty and VERY evil, but have you tried using a double instead of an integer data type? I don't really like to recommend this though. I'd much sooner recommend 64 bit integers if you have access to such a type through your compiler. Take a look and try using those. You need to identify the conditions when your program exits though. Is there anything you can change to make this happen sooner, for example? I may be wrong on my theory of why it's exiting at a certain point in time, but if it runs for exactly the same amount of time each time then exits this just seems very likely to me.

Jonathan

###
for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
(tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
/(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

Report
Re: long time sound recording problems Posted by cbodapati on 25 Mar 2004 at 2:57 AM
hi
is there any chance that the locked buffers for a long time does not remain locked.

iam monitoring the signal and the count does not exceed 50, if the returned buffers count reaches 50 the count is set to 0.
so at any point of time the count of the all the variables does not exceed the max value(32 bit unsigned integer).
the application does not stop all the times at a particular time.
If there are 5-6 instances of the internet explorers opened then the application stops at an early time, if no IE's then the applpication runs for a long time.

how to manage and tackle the problem sucessfully please help.
Regards
srikanth

Report
Re: long time sound recording problems Posted by Jonathan on 25 Mar 2004 at 3:21 AM
: is there any chance that the locked buffers for a long time does not remain locked.
:
What do you mean by locked buffers?

: iam monitoring the signal and the count does not exceed 50, if the returned buffers count reaches 50 the count is set to 0.
: so at any point of time the count of the all the variables does not exceed the max value(32 bit unsigned integer).
: the application does not stop all the times at a particular time.
OK, which makes my theory somewhat more unlikely.

: If there are 5-6 instances of the internet explorers opened then the application stops at an early time, if no IE's then the applpication runs for a long time.
:
: how to manage and tackle the problem sucessfully please help.
:
Maybe Jason was right in that it's a memory management issue. Or more to the point, memory mis-management. While you may not be leaking, C apps are notorious for having odd behaviour because a bit of memory gets corrupted by your program. Unfortunately, there isn't a lot more that I can do. You're just going to have to go to your code with a debugger and try and reproduce the problem under the debugger, then figure out the state that causes the app to terminate unexpectedly. Use Visual C++ if you have access to it; it's good at tracing bad memory management and damage.

Jonathan

###
for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
(tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
/(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

Report
Re: long time sound recording problems Posted by cbodapati on 25 Mar 2004 at 6:57 AM
hi jonathan

:What do you mean by locked buffers?

to lock the sound data(buffer) and to send to the device driver. this is what i mean by saying buffer.

is it not the way ?

please clarify...

probably the most ugly thing is that i don't know how to debug the code using VC++. I have coded my app in VC++ winapi.

any guidance is highly appreciated.
thanks


Regards
srikanth

Report
Re: long time sound recording problems Posted by Jonathan on 26 Mar 2004 at 10:47 AM
: :What do you mean by locked buffers?
:
: to lock the sound data(buffer) and to send to the device driver.
: this is what i mean by saying buffer.
:
: is it not the way ?
:
: please clarify...
:
To my understanding, when you use waveOutWrite to write a buffer of data you should not try and modify data in the buffer after it has been written as the soundcard device driver may lock it. But it depends on the driver. Or is what not what you meant? When you are getting data by waveIn APIs, I would imagine any data you are passed is not locked in any way.

: probably the most ugly thing is that i don't know how to debug the code using VC++. I have coded my app in VC++ winapi.
:
Debugging is just a skill you have to learn. You can run your app under the debugger using Build ==> Debug ==> Go. You can insert break points by right clicking on a line of code and choosing insert breakpoint. You can manipulate your program's data as it runs, see contents of variables, etc. See the Visual Studio docs.

Jonathan

###
for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
(tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
/(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

Report
Re: long time sound recording problems Posted by cbodapati on 12 Apr 2004 at 7:05 AM
thanks jonathan,
i have been out of this world for a while.
while playing the data,
1)lock memory
2)copy sound data to the pointer returned by globallock.
3)prepare the bufer
4) send it to the driver.


for recording..
lock memory, send to the queue, get the recorded data.
is this not the procedure...please clarify.



Regards
srikanth

Report
Re: long time sound recording problems Posted by Jonathan on 16 Apr 2004 at 10:48 AM
: thanks jonathan,
: i have been out of this world for a while.
: while playing the data,
: 1)lock memory
: 2)copy sound data to the pointer returned by globallock.
: 3)prepare the bufer
: 4) send it to the driver.
:
I've always just malloc'd the buffer myself, but that sounds fine.

: for recording..
: lock memory, send to the queue, get the recorded data.
: is this not the procedure...please clarify.
:
So far as I'm aware, use waveInOpen to get a handle for reading wave data. You use waveInPrepareHeader, again creating buffers like you did for output, but of course this time you don't copy data into them. You then call waveInAddBuffer to add this buffer to the queue of buffers waiting to be filled. When the buffer has been filled, the callback function (or event, or whatever) is called. You then take it and process it.

Jonathan

###
for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
(tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
/(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

Report
Re: long time sound recording problems Posted by jason on 14 Apr 2004 at 11:16 AM
Hi guys.

Been a month or so since you started this one, any luck?

Regards, Jason
Report
Re: long time sound recording problems Posted by cbodapati on 15 Apr 2004 at 1:29 AM
hi jason
I was off the track for some time, some personal work, started working again. problem not yet solved.


Regards
srikanth




 

Recent Jobs