Debugging Audacity, learning how it imports audio

Hi All

I am new to Audacity and this forum, nice to meet you all.

I have a debug setup in windows and I am trying to figure out how Audacity works with regards to importing audio. The progress from you select a file till its open in Audacity.

I am interested in understanding where the demuxer or splitter takes over and where the handle to Audio actually is.

I just started debugging this and I thought it would not hurt to ask either :slight_smile: I am enjoying stepping through the code though :slight_smile:



Audacity uses a number of libraries for importing, notably libsndfile ( for most of the natively supported audio formats, and the optional FFmpeg library for many other formats including video formats (though Audacity only extracts the audio streams from video files).

Audacity has two ways of importing. It either copies the audio data immediately on import, converting the data as necessary to uncompressed “AU” data blocks (32-bit float PCM by default), or it creates “alias” blocks that point to the audio data in the audio file. The second method is called “on demand” loading, and can be a bit quicker than the direct loading. In particular, “on demand” allows the user to start working on a file before the import is complete (which can be useful when working with very large files), but “on demand” is only available for uncompressed file types (including FLAC). More complex formats (such as MP3, OGG or video formats) must be decoded on import.

In most cases Audacity links dynamically to the required import library, though there is also the “external library” interface that can pass command line arguments to an external stand-alone decoder.

The Audacity manual focusses on using Audacity (rather than the underlying code), but this section of the manual may provide some useful background information:

Thanks Steve.

I also found this site Redirecting… which explained abit about audacity handles sound it self, so its own datastructure so that editing and playback in any place in the whole audio file is possible.
I am trying to study enough of Audacity to figure out the whole flow from when you open and audio file, in this case its a mov file, til when its somewhere stored in an audio buffer, that buffer that then gets played when you hit the play button.

I you or other know about books or courses that explains the audacity engine I would be happy to know about it.

My background is computer science but not with dsp though, however I do follow what you talked about :slight_smile:

Thanks for the help so far :slight_smile:

Cheers FTF

For others who might be following

I just found out that Audacity has a log :slight_smile:

Help → Show log

So there I will be able to follow the whole process and debug how it all works, but I dont have to only step through code now.

Then what I can do is search the whole project for those strings, so I will get to where the call stacks / flow are in the code