Hi, I had a question recently about PortAudioStreamRecorderMBS having drop outs, I think it was on my end but I have a question.
With the stream constructor you indicate the size of the internal ring buffer, which the larger it is, the longer you can go without calling ReadStream() and losing data (because the buffer already wraps around). In your examples you set it to 1024*1024 but I set it to 2048*2048. My mistake (I think) was I was essentially doing this with ReadFrames(): Dim numFrames As Integer Dim m As New MemoryBlock(5120) numFrames = AudioStream.ReadFrames(m, m.Size) AppendMemoryBlock(MasterBuffer, m, m.Size) // an internal function to append memoryblocks I was ignoring that ReadFrames() might not fill up the memoryblock m and return numFrames that is lower than the size of m, in cases where the ringbuffer isn't filled up enough. Although it's strange that I was getting dropouts further into stream, not right at the start. The correction is this: AppendMemoryBlock(MasterBuffer, m, numFrames * 4) My question is - what is a "frame"? Sometimes the term is used for a set of bytes representing one sample, other times it's used to indicate bytes that represent all the channel's samples. (So the former it would be 4 bytes, in cases of stereo it's 8.) I think in your case it's the former, but I wanted to ask to make sure. And in almost most cases, you always are recording in stereo and the data is in floats, right? I know in OpenStream() you can say channels=1, but that assumes the left input since most/all sources are stereo? I think your documentation is clear but it could be clearer. "Values are stored in floats (memoryblock.singlevalue) so you get at maximum SizeInBytes/4 values. And if you use more than one channel, you will receive them interlaced. ReadFrames uses a mutex to access share data, so this call is expensive. Use a big buffer." (It's your references to "/4" where I assume a frame is a single sample, not all the channels' samples.) You say "use a big buffer" but is that the size of the ring buffer or the size of "m" which you grab things out of ReadFrames()? Also, since you say the call to ReadFrames() is expensive, it discourages one to call it a lot, where it's beneficial to call it a lot so you don't lose out if the ring buffer wraps around. I use paFramesPerBufferUnspecified in OpenStream() so it's kind of the Wild West here when it comes to efficiency. I know you can use BufferWriteIndex or BufferReadIndex to debug, perhaps I could write code to indicate if I hit a wraparound circumstance but I was sort of expecting the stream to flag that, but perhaps it's busy with its own work? When you say calling ReadFrames is expensive, I get that, but does it matter? Given a large ring buffer and getting as much out of ReadFrames() as possible, I'm kind fo rich as it is. I call ReadFrames with a timer, I call it every 250ms, could I call it quicker? Garth Hjelte Sampler User _______________________________________________ Mbsplugins_monkeybreadsoftware.info mailing list [email protected] https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info
