Debugging Audacity, learning how it imports audio

Audio software developers forum.
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
Post Reply
FTF
Posts: 10
Joined: Thu Jun 25, 2015 8:58 am
Operating System: Please select

Debugging Audacity, learning how it imports audio

Post by FTF » Thu Jun 25, 2015 9:07 am

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 :) I am enjoying stepping through the code though :)

Cheers
FTF

steve
Site Admin
Posts: 49006
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Debugging Audacity, learning how it imports audio

Post by steve » Thu Jun 25, 2015 2:03 pm

Hi FTF,

Audacity uses a number of libraries for importing, notably libsndfile (http://www.mega-nerd.com/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: http://manual.audacityteam.org/o/man/im ... audio.html
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

FTF
Posts: 10
Joined: Thu Jun 25, 2015 8:58 am
Operating System: Please select

Re: Debugging Audacity, learning how it imports audio

Post by FTF » Fri Jun 26, 2015 8:19 am

steve wrote:Hi FTF,

Audacity uses a number of libraries for importing, notably libsndfile (http://www.mega-nerd.com/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: http://manual.audacityteam.org/o/man/im ... audio.html
Thanks Steve.

I also found this site http://aosabook.org/en/audacity.html 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 :)

Thanks for the help so far :)

Cheers FTF

FTF
Posts: 10
Joined: Thu Jun 25, 2015 8:58 am
Operating System: Please select

Re: Debugging Audacity, learning how it imports audio

Post by FTF » Fri Jun 26, 2015 12:57 pm

For others who might be following

I just found out that Audacity has a log :)

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

Cheers
FTF

Post Reply