Page 1 of 1

Why does Audacity store audio in small chunks?

Posted: Sun Mar 14, 2021 1:27 pm
by madis
Hi,

I'm interested to know the reason why Audacity team decided to store audio in small chunks (~1.1MB) - as it's not really necessary for seeking (without loading the whole file into memory), and for working around e.g 4GB limit the chunk could be larger.

I noticed Audacity 3 changes this, but if I have correct information, the new project file is sqlite database and still contains little binary audio chunks inside?

It's not that this is wrong or anything, I'm only interested in *why* was this decision taken in the first place and would it be the same if you would start the project now?

Re: Why does Audacity store audio in small chunks?

Posted: Sun Mar 14, 2021 2:26 pm
by waxcylinder
For processing speed

Re: Why does Audacity store audio in small chunks?

Posted: Sun Mar 14, 2021 2:59 pm
by steve
madis wrote:
Sun Mar 14, 2021 1:27 pm
It's not that this is wrong or anything, I'm only interested in *why* was this decision taken in the first place and would it be the same if you would start the project now?
Say you have an 8 hour long track and you need to remove a click from somewhere within that track.
Because Audacity's data is stored in (approx) 1 MB blocks, you only need to write 1 MB of new data, and retain 1 MB of "undo" data.

Re: Why does Audacity store audio in small chunks?

Posted: Sun Mar 14, 2021 4:14 pm
by madis
Thank you for the quick reply.
steve wrote:
Sun Mar 14, 2021 2:59 pm
madis wrote:
Sun Mar 14, 2021 1:27 pm
It's not that this is wrong or anything, I'm only interested in *why* was this decision taken in the first place and would it be the same if you would start the project now?
Say you have an 8 hour long track and you need to remove a click from somewhere within that track.
Because Audacity's data is stored in (approx) 1 MB blocks, you only need to write 1 MB of new data, and retain 1 MB of "undo" data.
Ah, I really wasn't thinking about this. So, it makes the implementation of writing the data and the undo-redo engine simpler or more effective than it would be to edit and split large files afterwards.

Re: Why does Audacity store audio in small chunks?

Posted: Sun Mar 14, 2021 4:42 pm
by steve
madis wrote:
Sun Mar 14, 2021 4:14 pm
So, it makes the implementation of writing the data and the undo-redo engine simpler or more effective than it would be to edit and split large files afterwards.
There's also an important optimisation for the graphic waveform display. Each block contains peak and RMS "summary data". When zoomed out sufficiently for a block to be around the size of a screen pixel, the waveform can be drawn from the summary data without having to re-analyse the audio data. The summary data also allows effects such as "Amplify" to be able to calculate the peak level of a selection almost instantly. When part of a track is edited, Audacity only has to re-calculate the summary data for those blocks that have been modified.

Re: Why does Audacity store audio in small chunks?

Posted: Fri Mar 19, 2021 4:09 pm
by madis
Thanks for the insight! Out of interest - is this block summary data also directly inside of the binary file or only in the project xml?

Re: Why does Audacity store audio in small chunks?

Posted: Fri Mar 19, 2021 4:14 pm
by steve
Things have changed somewhat with the release of Audacity 3.0.0. The entire project is now within the "AUP3" project file.
(See: https://www.audacityteam.org/audacity-3-0-0-released/)

Re: Why does Audacity store audio in small chunks?

Posted: Fri Mar 19, 2021 4:28 pm
by madis
Uuh, I missed the big release! Congratulations shipping it!