Record audio without data loss between save files | PortAudio.jl

Hello everyone!
I have a question, is there a way to record audio for example one minute through the following script using portaudio:

import LibSndFile
using PortAudio: PortAudioStream
using SampledSignals: s
using FileIO: save
using Dates
while true
        stream = PortAudioStream(1, 0)
        buf = read(stream, 60s)

and not have data loss between the time it is saved and another recording is created? I noticed that there is a data loss of ~0.02 seconds of data. I know it’s a bit far-fetched but I need to do a spectral analysis where every piece of data counts.
I am new with Julia so I ask for guidance. Is there any way to have a stream of data stored in a queue or buffer while those ~0.02 pass to save the file and then be able to retrieve that data? Thank you!

1 Like

Can you move the stream open and close operations outside of the loop?