[fpc-pascal] TFileStream.WriteBuffer() and RAM used ?
joshyfun at gmail.com
Mon Dec 12 00:21:50 CET 2016
El 11/12/2016 a las 14:39, fredvs escribió:
> @ Jose : uos uses PortAudio library to grap input from devices. I will
> deeply study your propositions.
After a fast view of PortAudio API you can produce a code like:
lLocalBuffer: array [0..16383] of Byte;
while NotUserBreak_OrLimitReached do
lAvailableBytes:=lAvailableFrames * (YourStream_BYTES_PER_FRAME);
if lAvailableBytes<16384 then
// Don't read, just wait a bit.
16384 div (YourStream_BYTES_PER_FRAME
This code should work because PortAudio (and almost 100% APIs of this
kind) has an internal buffer which is large enough to hold new data
while you are writing to disk and performing other tasks. Some even use
a dynamic buffer which can hold audio for several seconds before you
extract them using the API.
Note: Of course the maths are the expected ones, you must know the
BYTES_PER_FRAME size and the format of that frames, maybe int16, maybe
float, maybe ....
More information about the fpc-pascal