What is the best way to setup record buffer

View: New views
2 Messages — Rating Filter:   Alert me  

What is the best way to setup record buffer

by Hao Zhou :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In patest_record example, a buffer with predefined time duration was created. But in reality, you normally don't know how long the recording will last. In my application, I used a expandable buffer to hold recorded data. Here comes two problems:
1. Inside the callback, we should do anything as quick as possible. In my case, memory reallocation will be called. That could be very time consuming.
2. If the recording process last too long, the memory space could be ran out.
My question is what other approaches are used? What is the best approach?
Thanks,
Frank


     
_______________________________________________
Portaudio mailing list
Portaudio@...
http://techweb.rfa.org/mailman/listinfo/portaudio

Re: What is the best way to setup record buffer

by Gordon Gidluck :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hao,
I would recommend that you allocate a buffer once and just keep reusing it.

Main() program code would have to be setup to get the data from the
buffer in the same sequence that the record callback places samples into
the buffer.

At some point when you reach the end you will need to reset the indexes
to the beginning of the buffer.

There is some time lapse between when the samples are placed into the
buffer and when they are picked up by the main program code. The key is
in getting the program code to exactly follow the same order as that of
the callback.

As far as design, you could logically split the buffer into two or more
segments and manage it that way or treat it as one circular buffer. If
you reset your pointers to the beginning and reuse your existing buffer
you don't really need your buffer to expand dynamically.

Gordon
http://live2496.com


Hao Zhou wrote:

> In patest_record example, a buffer with predefined time duration was created. But in reality, you normally don't know how long the recording will last. In my application, I used a expandable buffer to hold recorded data. Here comes two problems:
> 1. Inside the callback, we should do anything as quick as possible. In my case, memory reallocation will be called. That could be very time consuming.
> 2. If the recording process last too long, the memory space could be ran out.
> My question is what other approaches are used? What is the best approach?
> Thanks,
> Frank
>
>
>      
> _______________________________________________
> Portaudio mailing list
> Portaudio@...
> http://techweb.rfa.org/mailman/listinfo/portaudio
>
>  

_______________________________________________
Portaudio mailing list
Portaudio@...
http://techweb.rfa.org/mailman/listinfo/portaudio
LightInTheBox - Buy quality products at wholesale price