Difference between revisions of "GSoC 2009 - Bugfix Automatic Volume Wiki"

From Audacity Wiki
Jump to: navigation, search
m (Text replace - "http://manual.audacityteam.org" to "https://manual.audacityteam.org")
Line 1: Line 1:
This page is a progress report on work in a past GSoC.  Much has changed since then.}}
== Contacts ==
== Contacts ==
Line 537: Line 540:

Revision as of 20:17, 19 February 2021

This page is a progress report on work in a past GSoC. Much has changed since then.


  1. Email: [email protected]
  2. IRC alias: apinto @ FreeNode
  3. Audacityteam forum: apinto
  4. wiki user page


This project is primarily a ‘BugFix Superstar’ application where I commit myself to help Audacity team to fulfill its main objective, reach a stable state for 1.4 release. Being myself an Audacity user as a DJ and producer I propose to create a new simple and useful feature for automatic volume detection during a record session. I will also work on User Interface improvements. To meet community needs I've included on my GSoC project the creation of a solution for problems in generation of the zipped manual.



During GSoC

Week 12


  • Fixed "P2 - Find Clipping: unwanted deletion of audio when linking enabled.".
  • Enabled view menu items if any type of track is present.
  • Fixed "P2 - If collapsing one of a number of tracks causes an autoscroll, some or all the tracks disappear."
  • Fixed Truncate Silence for "P2: Labels should move with all the timeline changing effects." (waiting confirmation) New white space behavior is not implemented yet.

Automatic Volume:

  • Removed gprefs read from OnMeterUpdate to improve speed. We just don't need it anymore. Suggested by Martyn.
  • Fixed some bugs and rewrote the latency system as the old one was not cross-platform. Reported by Leland.
  • Added debug.
  • Change the max peak detector to use msg peak instead of mbar (plain input so it avoids decay effect to be considered).
  • Greyed out meter option when AV is disabled. Suggested by Gale.
  • Added enable/disable to transport menu. Suggested by Gale.

Week 11


  • Fixed "P2 Generating audio fits the project in window". Refit is only done when a new track is created or when generating audio on an empty track at 0.0. When multiple tracks are selected for generation, refit is only done if all of them are empty.
  • Fixed "when you press CTRL+B a new label track should be added at the bottom instead of using the one that is above the audio track.". Old behavior is still used for CTRL+B when linking is off as suggested by Gale.
  • Fixed "P4 - ENTER and ESC delete empty labels."

Automatic Volume:

  • Changed some preferences and variables denominations.
  • Added option to stop automatic volume on the meter menu. Suggested by Martyn.
  • Reverted to old volume change function.
  • Added Change Factor to volume changes.
  • Added method to Meter to retrieve linear max peak. Formula and bug discovered by Martyn Shaw.
  • Some issues were happening because of the latency created between the analysis time and the portaudio's buffer processing. I've used Portaudio's aStreamInfo.inputLatency to deal with this (I hope this fixes the problem definitively).
  • Added top truncation as suggested by Martyn.
  • Added msg queue Clear to meters after stop to make sure there is no pending messages.
  • Added lots of debug printfs during the proccess. I've left them in the code (commented) as they might be useful later.

Week 10


  • "P2 Default View Mode in the Tracks Preferences has no effect" fixed.
  • "P3: If shortcut for "Add label at playback position" is an unmodified character, the second time the label is confirmed by ENTER, that shortcut will be entered in a label placed at the start cursor." fixed.
  • Drawing bug on Frequency Analysis with multiple projects fixed. Reported by Martyn Shaw.
  • Undesired selection and undo add when paste/generate is not possible fixed. Reported by Gale.

Automatic Volume:

  • Moving Automatic Volume to Meter Update as Richard suggested. This should avoid the crashes on OSX and Linux caused by GUI calls from portaudio callback function.
  • Changed volume change function. Suggested by Martyn Shaw.
  • Rolling back to the old clipping behaviour. Added isclipping boolean to MeterBar to use on AV.
Week 9


  • Fixed generation and pasting of clips when "Editing a clip can move other clips" is off and there is not enough space available. Reported by Gale.
  • Found and fixed clipping status bug when recording (awaiting confirmation). mBar[j].clipping was always true after first clipping.

Automatic Volume:

  • Studied Portmixer/Portaudio/Audacity behavior.
  • Implemented first approach to Automatic Volume feature.
  • Added configuration parameters in the Preferences.
Week 8


  • When linking is off it's now possible to apply clear over labels without affecting any other label besides the ones that are being selected.
  • Created Cut function that doesn't use group Clear function (fixes a bug when pasting multi-clips in groups).
  • "P2 - Audio generated or pasted when cursor is in white space overwrites instead of inserts." fixed. Following Gale's suggestion.
  • Muti-track Generator bug with Groups fixed. Reported by Gale.
  • Fixed delete when linking is off. Reported by Gale.
  • "P2 - Plot Spectrum: unwanted window switch" fixed. FreqWindow used is now relative to each project.
  • Fixed bug when generating over a label track. Reported by Dan Horgan.
Week 7



  • "P2 - Crash applying non-zero Speed, Tempo, Pitch or Sliding Time Scale effects if label and time tracks present" fixed.
  • Removed HandleGroupChangeSpeed as it's no longer needed.
  • Fixed labels move when changing speed, tempo. Reported by Martyn.
  • "P2: When Time and Label Tracks present and linking on, cannot delete a region by selecting only in the label track" fixed.
  • Repeat and Reverse with multiple tracks of a group fixed. Reported by Gale.
  • Delete of a multi-track region with time tracks fixed.
  • Found and fixed multi-track paste bug.
Week 6


  • Found and fixed the bug with paste from individual sources to multiple targets.
  • Change Speed with Groups fixed.
  • Minor fix to how Labels are treated on WaveTrack::Paste (called ShiftLabels OnClear and OnInsert methods based on the signal of delta).
  • Fix to Reverse finishes fixing of "P2 - Labels should move with all the timeline changing effects."
  • Labels are now reversed (distance from the start of the label to beginning of selection reversed swaps with the distance from the label end to the selection end), if the selection includes all the label (additional conditions are tested to make sure the references to the other tracks in the group are kept).
  • Fixed P2: Edit > Silence Audio silences or corrupts labels fixed. Silence Audio is only applied to WaveTracks now.
  • Added TrackAndGroupIterator that can iterate over tracks and groups.
  • Fixed Clear bug for multiple tracks within a Group (reported by Vaughan Johnson).

Week 5


  • Fixed Paste bug with Linked Tracks (solves Generate Silence bug reported by Martyn Shaw)
  • Fix for Paste when the initial paste position is not the same as the initial selection (ex.: Repeat Effect).
  • Created iterator over Selected Wave Tracks (mainly) for effects.
  • Discussion
  • Commits:


Week 4


  • Finished fixing of Bugs Related with Clearing tracks inside Groups (p.e. Truncate Effect Bug, Clear WaveTrack between Time and Label Track) (reported by Rupinder Singh and Leland Lucius).
  • Removed some warnings.
  • Added Track::All enum to match all tracks. Edited TrackListOfKindIterator to match Track::All meaning.
  • Discussion
  • Commits :


  • Fixed unclosed 'a' tags that were causing the render problems on IE (reported by Gale Andrews).
  • Discussion
  • CVS Commit
Week 3



Week 2

Work done on the script based on community's feedback (thanks to Martyn for his useful feedback), mainly:

  • Fixed remotion of a hrefs to same url (that was causing the lost of the sidebar's logo).
  • Fixed url_to_filename usage of normalized urls (that was causing the wikipedia's logo problem).
  • Removed all external links except licenses.
  • Removed #searchInput links
  • Fixed CSS styles
  • Fixed anchor links



Week 1
  • Initial commit of MediaWiki to HTML script with the work I've done before GSoC startup.

Links: CVS commit (by Martyn Shaw - I hadn't cvs write access at the time) CVS commit (by Martyn Shaw)

  • Work done on the script based on community's feedback, mainly:
    • Fixing the dump script.
    • Added error counter.
    • Replaced deprecated sha module for hashlib.
    • Fixed sidebar.html links (they have to be related to the online wiki and not the local dump).
    • Fixed batch file so it doesn't retrieve a access denied when the destination folder is not empty.


Before GSoC

  • 2009/04/25 - Efficiency improvement of the Media Wiki to HTML Python Script. Total Static dump is now done almost 4 times faster than the original.
    • 864 files saved in 9m42.866s (initially dump took more than 30 minutes)
  • 2009/05/02 - James Crook's requests for the Manual Wiki script implemented. Filtering contents to be dumped and added --no-images option.
    • 398 files saved in 4m20.140s (with images)
    • 135 files saved in 1m48.039s (without images)

The dumps were done using a 4 Mbps connection




  • 3 ‘P1 or P2 issues’ fixed.
  • 7 ‘P3 to P5 issues’ fixed.


At least:

  • 6 ‘P1 or P2 issues’ fixed.
  • 16 ‘P3 to P5 issues’ fixed.


  • If I eventually find a bug that I can’t fix, I'll write a report about it (telling how to reproduce, related data/functions, what I’ve done when trying to fix it, and other valuable information).
  • I won’t do Mac only bugs because I have no Mac so I’m not able to test possible fixes.

Automatic Volume Feature (Optional - Implemented)

Description (as included in the Application)

Recording mode that monitors the input volume for some seconds (e.g. 15 seconds) and automatically adjusts the volume to best-fit the recording sound.

  • GA: Since it's apparently not intended for actual recording but as a more automatic way to do a pre-recording level test, shouldn't this be made clear at the outset?
  • AP: yes, it's that. do you have any suggestion to make it clear?
  • GA: For a start, the name of the feature "Automatic Volume Recording". I had no idea it wasn't for "real" recording (hence my concerns on -devel list are softened somewhat). But I think that many people will see AV in Preferences, not read the Manual, then assume if you give AV a few seconds of lead-in noise and music on a record, it will act as a limiter to prevent clipping irrespective of later volume changes in the input. Of course it may well work for real recording for a compressed pop track, but some people with high dynamic range music or speech might end up very disappointed. I mean, if it was called "Automated Recording Level Tester" at least it describes what its purpose is.
  • AP: It's ok for me, but the feature doesn't only test the volume, it also tries to find the input volume to achieve the target peak specified. It's not only a tester, it's a test & decision feature. But no biggie for me.
  • GA: Maybe it makes sense so as to save people having to reconfigure/re-analyze too often, that we suggest they test with the loudest piece of audio they ever expect to record (not just the one they want to record now)? Should we even suggest it's mostly for recording tapes and LPs (those recording with a mic will prefer to do a manual check, and those recording internet radio may have a problem since they don't know what level is to come)?
  • AP: Surely this feature is not for the professional sound engineer (as it was discussed on the list), it's for the people who want to make easier the process to find an acceptable volume setting. The loudest piece of audio they ever expect would be a nice input test if there is no big difference between that and the rest of the audio. If there is, it might eg be better letting the volume clip on that region but without causing the other regions to have a very low volume. The use cases are defined by the exigency of the user. I agree that it will be better to use it when we know at start all the content we will record and therefore we can pick the loudest region to test, but most times, testing with a "normal part" of the input will still have acceptable results. Most of the radios and songs won't have big volume changes after you monitor the input during a representative part. Variations occur but when you don't know all the input it's supposed that you choose a target peak that will be able to deal with that variations without causing clip or silence.
  • GA: I still think AV should have a toggle enable/disable in the Transport Menu. If you stop AV in the meters it still starts on next recording, so we are stopping it, not disabling it. I think this is behaviour is probably correct, but your instructions below suggest "stop" in the meters means "disable".
  • AP: Right, my bad. I'll add the enable disable to the transport menu. Thanks for the suggestion.
  • GA: Thanks. When AV is disabled, could you grey out "Start Automatic Volume" in the meter - otherwise it looks broken if user forgets it's disabled and tries to start it there.
  • AP: Done. Thanks again for the suggestion.

As DJ I find myself adjusting the recording level to fit the mixer output volume. An auto-adjust feature would be an helpful add-on for people willing to use Audacity for “fast recording”. This feature will not require big changes, conforming with the main target of getting a stable version for Audacity 1.4 release.

Note: The implementation of this new feature may be replaced by U.I. improvements, bug fixes and/or code optimization work. This would be discussed with the mentor.


Automatic Volume is a feature that tries to automatically find the right input volume to achieve the recording volume you want.

Use Case

  • Activate Automatic Volume with the settings you want (in Preferences -> Recording)
  • Start the input sound with a representative part of the audio (typically the loudest sound in the input you want to record).
  • Start recording.
  • Automatic Volume will try to find the correct volume using the analysis settings specified in Preferences. The input slider will move according to the volume adjustments made.
  • Stop recording when you are satisfied with the achieved recording volume (or after Automatic Volume finishes its analysis if you have specified a time limit).
  • Disable Automatic Volume in the Transport Menu or Preferences.
  • Start recording. If Automatic Volume set the input level correctly, Audacity should now record at the target peak level you chose in Preferences.


  • Enable Automatic Volume recording: check this box to start Automatic Volume analysis next time you record.
  • Target Peak: the desired maximum volume of the recording (from 0 to 100 - linear volume scale).
  • Within: sets the interval for max peak volume accepted [best-within; best+within]
    • GA: Please explain this better - is it some kind of limit of variability? What exactly does it do? What does "[best-within; best+within]" mean?
    • AP: It's the "acceptance range" (I'm not sure if this is the right denomination in English). It's really difficult to achieve a max peak of exactly "Target Peak" so we try to fit it into the range [best-within; best+within]. A max peak in that range is considered good/acceptable.
    • GA: Is "tolerance +/-" a better phrase than "within"? Does a setting of "2" mean that we let the acceptable peak vary from 1 point below to 1 point above the Target Peak? [If so, does that means if the slider is at 100, we necessarily permit clipping if "within" is not zero?]
    • AP: "Within" was suggested on the list by Martyn, but I also think "Tolerance +/-" is better. I'll change that. a setting of 2 will accept 2 points above and 2 below (that's why it is [best-within; best+within]). Clipping is different than volume, if volume is at 100 and you choose 2, the slider will be truncated to 0 after you press OK because there is nothing above 100 (this was not working because of a bug that I've now fixed) but clipping will also be detected as a condition to decrease volume (if the audio is always clipping in the specified acceptance range then we will not be able to find the desired volume).
  • Analysis Time: length of time for which the audio is analyzed before making each volume adjustment (milliseconds)
    • GA: Does the setting of this change the expected accuracy of the adjustment?
    • AP: Yes, as the feature will have more samples to analyze till a decision is taken. This should help taking a more representative decision (less probability to take a decision that is only valid in a small portion of the input sound).
    • GA: Do the adjustments on the way to the final one have any real purpose then? That is, looking at the default value of 1000 ms analysis and 5 analyses, would 5000 ms and one analysis be more accurate?
    • AP: They have because we don't know the impact that the input volume change will have on the audio we receive till we analyze it again. That's why we need various analysis.
  • Number of consecutive analysis: the total number of adjustments to the volume. The total length of time the audio is analyzed for is "Analysis time" multiplied by "Number of consecutive analysis". To set Automatic Volume to monitor until you stop recording, enter zero (0).

Some integrity validations are done to these values.

still in development

  • GA: Needs an explanation of the Status Bar messages (in particular the difference between "still too high", "still too low" and what user should do about that).
    • AP: Those messages are displayed in 2 different situations:
      • The total number of analysis were exceeded without finding an acceptable volume;
      • We can't improve it more because we are already in the maximum or minimum possible (eg we have the input volume at 0.0 but we still get a max peak above the target peak specified or; we have already marked a input volume as too high in the past, but now we verify that for current analysis that same input volume is too low - maybe this should just keep the volume without stopping AV?)
      • GA: You mean the marked input level on the slider? It would seem to me that AV should not stop in this second "already marked" case; and even for the first case, shouldn't AV wait a few seconds before deciding to stop? What about someone putting a record on and hitting the lead-in grooves?
      • AP: Yes. For the 1st case that's why I suggested removing the number of analysis. In that case the user will stop monitoring when he/she wants by selecting "Stop AV" in the meter menu.
  • GA: I've never seen a quit message ("number of analysis exceeded") where AV found an "acceptable volume". Is this a problem?
    • AP: In that case a message "Automatic Volume stopped. VOLUME seems an acceptable volume." should be displayed. Is normal that it doesn't appear many times if the input is not constant. Thinking about this, maybe a limitation by number of analysis doesn't make much sense in this scenario, probably we should just keep monitoring till the user choose to end the process?
    • GA: It seems in asking that, you're thinking of it again as a "real" recorder, not a test recorder? I might even ask the opposite question: should AV just stop recording when the analysis time is over? If it's only a tester, this saves user a step.
    • AP: I'm thinking about a "test recorder" that would require the user to stop the process. I suggest this because it may be difficult to previously choose the right number of analysis needed to get the volume right. In that case if the user manually stops AV then it maybe would also make sense to stop the recording as you said and even remove the created track.
  • GA: There seems no notification of the final adjustment, it is replaced by the quit message. I wonder if later on, a text output of the adjustments made might help?
    • AP: It should display the final adjustment (I'll test this later). You are thinking about a status bar message with all the adjustments made?
    • GA: I was thinking about a file or a log window (Status Bar could not have room for more than a few adjustments).
    • AP: OK.
  • AP: Thanks for the help with the text!

Manual Wiki

MediaWiki to HTML Python Script time usage (after 2nd performance boost)


Creation of a script to do static HTML dumps of the Audacity's Manual Wiki.

Current Dumps

Dumps generated using the last script version:

Work Already Done

Based on this "Public Domain" script.

  • Time performance optimization (almost 4x times faster). Current time limitations are constraint almost entirely by the libraries used and not by the script (as you can see on the side diagram).
    • 1st Optimization reduced the number of calls to urllib open. The original script did 2 calls for each file. After the first optimization, only one call was done without any functionality lost. This improved the time efficiency by (approximately) a factor of 2.
    • 2nd Optimization made the script do direct calls to httplib instead of urllib. urllib is a python library that handles some url open details (like some connection issues) and then calls httplib to retrieve the url content. Working directly with httplib I was able e.g. to keep the connection alive for the entire program execution instead of creating a new connection for each url. This improved the time efficiency by (approximately) a factor of 2.
You can check the old diagram (between 1st and 2nd performance boost) here.
  • Innumerous customization adds and changes (from html parsing to usage improvement).


The diagram on the right was build using cProfile Python module for data collecting process, Gprof2Dot script for data analysis and Graphviz (DOT format, equivalent linux tool) for diagram creation.

A node in the output graph represents a function and has the following layout:

function name
total time % ( self time % )
total calls


  • total time % is the percentage of the running time spent in this function and all its children;
  • self time % is the percentage of the running time spent in this function alone;
  • total calls is the total number of times this function was called (including recursive calls).

An edge represents the calls between two functions and has the following layout:

total time %
parent --------------------> children


  • total time % is the percentage of the running time transfered from the children to this parent (if available);
  • calls is the number of calls the parent function called the children.

This text was copied from Gprof2Dot. More information about the diagram can be found there.

Preliminary Work



  • Play Bug (P5 on Release Checklist @ wiki)
  • Focus Issue
  • Useless Envelope
  • Deficient Envelope Removal

JC: One of the GSoC requirements is (at the end) to submit a 'tarball' of code written. Please keep a folder with all your patches somewhere to make this step easy.

Found & Reported

  • Import Filter not working on Vista

UI De-Niggling


  • Sliders - Default Value & Precision Improvement

Incomplete / Subject on discussion

  • Precision Mouse Drag for Sliders

Manual Wiki


  • Rebuild of almost entire code of MW2HTML Python script.
  • Improvement of performance (almost 4 times faster than the original version - 9 minutes to dump audacity's manual on a 4 Mbps connection)