Audacity Bug Summary
••• Introduction •••
••• Keywords •••
    Audacity 3.0.3 development began 19th April 2021

Audacity Bugzilla



Bug 50 - Calculation of "disk space remains for recording (time)" incorrect when recording in 24 bit quality
Calculation of "disk space remains for recording (time)" incorrect when recor...
Status: RESOLVED FIXED
Product: Audacity
Classification: Unclassified
Component: Application Core
1.3.11
Per OS All
: P3 Repeatable
Assigned To: Default Assignee for New Bugs
:
Depends on: 1436
Blocks:
  Show dependency treegraph
 
Reported: 2010-01-28 12:46 UTC by James Crook
Modified: 2018-08-20 11:45 UTC (History)
5 users (show)

See Also:
Steps To Reproduce:
1. Record at 24 bit quality. 2. Check the time remaining in the status bar. 3. Compare it to time remaining when recording at 32 bit quality. 32 bit should show 3/4 of the recording time of 24 bit. Instead the times are the same.
Release Note:
GROUP:Playback and Recording * '''Calculation of "disk space remains for recording (time)" shows too short a time when recording in 24-bit quality''', wrongly showing the same remaining time as when recording in 32-bit quality.
First Git SHA:
Group: ---
Workaround:
Closed: 2018-08-20 00:00:00
petersampsonaudacity: Test‑OK‑Win+
petersampsonaudacity: Test‑OK‑Mac+
richard: Test‑OK‑Lin+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description James Crook 2010-01-28 12:46:38 UTC
Macro now created by RA to return size on disk of 16/24/32 bit sample formats as 2, 3, 4 respectively as first part of a fix, but Audacity does not currently record in 24 bit.
Comment 1 James Crook 2010-02-12 10:25:37 UTC
Please clarify...

In project.cpp we have this code:

#define SAMPLE_SIZE_DISK(SampleFormat) ((SampleFormat == int24Sample) ? \
   3 : SAMPLE_SIZE(SampleFormat) )

recTime /= SAMPLE_SIZE_DISK(gAudioIO->GetCaptureFormat());
// note size on disk (=3 for 24-bit) not in memory (=4 for 24-bit)

What does the comment "Audacity does not currently record in 24 bit" mean?  I can select 24 bits as an option in preferences.  If that is taking 3 bytes per sample (on disk) then the above calculation looks right.  If that is taking four bytes per sample (on disk) then we need to change the 3 to a 4 in the #define and fix the comment about size on disk.  Either way it looks like we can clear this one easily??
Comment 2 Gale Andrews 2012-07-09 04:12:09 UTC
(In reply to comment #1)
> #define SAMPLE_SIZE_DISK(SampleFormat) ((SampleFormat == int24Sample) ? \
>
>   3 : SAMPLE_SIZE(SampleFormat) )
>
> recTime /= SAMPLE_SIZE_DISK(gAudioIO->GetCaptureFormat());
> // note size on disk (=3 for 24-bit) not in memory (=4 for 24-bit)
>
> What does the comment "Audacity does not currently record in 24 bit" mean? 
> I can select 24 bits as an option in preferences.  If that is taking 
> 3 bytes per sample (on disk) then the above calculation looks right. 
> If that is taking four bytes per sample (on disk) then we need to 
> change the 3 to a 4 in the #define and fix the comment about size
> on disk.  Either way it looks like we can clear this one easily??

It seems that code comment is correct as far as it goes. For example when recording 24-bit @ 96000 Hz on disk it takes about 33 MB per minute. But it 
takes about 46 MB per minute in RAM. 

The comment was probably something taken out of context from -devel list that nonetheless was given as an explanation why the size calculation for 24-bit 
was actually calculating what 32-bit requires.
Comment 3 Vaughan Johnson 2012-08-03 19:43:18 UTC
(In reply to comment #2)

So is this really a bug?
Comment 4 Gale Andrews 2012-08-04 17:38:52 UTC
(In reply to comment #3)
> So is this really a bug?
From user perspective, yes. When users record 24-bit we tell them they need 50% more disk space than they actually need.
Comment 5 Vaughan Johnson 2012-08-07 22:26:57 UTC
(In reply to comment #4)

Gale, that was not clear to me in your previous comment. Your saying
33MB per minute on disk and 46 in RAM (which I took to be record-to-RAM
pref) read to me like it was reporting correctly.

I had checked that in the code for SAMPLE_SIZE_DISK, it sets the SAMPLE_SIZE_DISK divisor to 3 for int24Sample.


The actual bug is completely elsewhere. Commit 5712 (from 2006!) -- if captureFormat is passed in to AudioIO::StartPortAudioStream() as int24bit, it is always treated as 32-bit float thereafter in the AudioIO class. So I think the calculations are correct as things stand, but r5712 is probably questionable. 

This has been around a long time, and has other repercussions, so I do not think it's a cherry, and removed that keyword.
Comment 6 Gale Andrews 2012-12-27 05:35:20 UTC
(In reply to comment #5)
> from http://code.google.com/p/audacity/source/detail?r=11903
> So we *never* actually handle 24-bit?! This causes mCapture to be set to 
> floatSample below  
FWIW (to clarify) the actual disk space taken by the recording is equivalent to 24-bit (150% of 16-bit and 75% of 32-bit).
Comment 7 Gale Andrews 2016-07-05 07:43:32 UTC
(In reply to Gale Andrews from comment #6)
In https://github.com/audacity/audacity/commit/18eb2bb James added this answer

>   // ANSWER-ME: So we *never* actually handle 24-bit?! This causes mCapture 
>   // to be set to floatSample below.
>   // JKC: YES that's right.  Internally Audacity uses float, and float has 
>   // space for 24 bits as well as exponent.  Actual 24 bit would require 
>   // packing and unpacking unaligned bytes and would be inefficient.

Does that answer have implications for this bug?
Comment 8 James Crook 2016-07-05 08:42:19 UTC
Re Comment #7 - It supports what you said in comment #2.  In RAM it takes 4 bytes per sample and is stored as floats.  When saved, apparently, Audacity converts (losslessly) from float to 24 bit integer.  Lossless because 32 bit float represents 24 bit integer without error.

RAs macro is correct and in 
GetEstimatedRecordingMinsLeftOnDisk()
used from timer record gives the correct value.  However when generating the status message from OnTimer() it calculates using the internal capture format (float) in its calculation.  If it used the preference /SamplingRate/DefaultProjectSampleFormat (int24) it would get the right answer.  However due to performance Bug 1436 I am reluctant to make that simple change since this happens every time Audacity writes a block during recording.
Comment 9 James Crook 2016-07-05 10:19:36 UTC
DEVEL-FIX MADE in
https://github.com/audacity/audacity/commit/101b3ee8cd324ee57f66789214f1b5084e37b722

In the end I went for using the preferences as the writes are about every 3 seconds and the slight performance hit does not seem to be of significance in practice.
Comment 10 Peter Sampson 2016-07-07 05:52:24 UTC
(In reply to James Crook from comment #9)
Testing on W10 and Mac El Capitan on r145a54d 05Jul16

Looks to be good now on 24-bit settings

W10 remaining disk space
32-bit: 313 hours 43 minutes
24-bit: 418 hours 17 minutes
16-bit: 627 hours 25 minutes 


Mac El Capitan remaining disk space
32-bit: 133 hours 16 minutes
24-bit: 177 hours 41 minutes
16-bit: 266 hours 32 minutes
Comment 11 Richard Ash 2016-11-26 15:44:55 UTC
Tested at 396a6f0 from audacity/audacity on Linux. 

32-bit: 3 hours 18 minutes
24-bit: 4 hours 24 minutes
16-bit: 6 hours 36 minutes

Works correctly, so flagging this as Test-OK-Lin.
Comment 12 Gale Andrews 2016-12-18 22:27:07 UTC
Main issue fixed so RESOLVED-FIXED.  

Append Record "disk space remains" is incorrect (unchanged) if you change the track format or rate. These issues are now at bug 1562 and bug 1563 respectively (both P4).
Comment 13 James Crook 2017-05-28 04:59:48 UTC
Just for information...  The dependence on Bug 1436 was discussed in comment #8, and should have been removed with comment #9.  Instead this bug stayed open (due to the dependence) until today when bug #1436 was closed as WORKSFORME.
Comment 14 Gale Andrews 2017-05-28 21:40:36 UTC
(In reply to James Crook from comment #13)
Hmm - looks like there is a bug in the software or settings then because I recall no warning about dependencies when setting RESOLVED - FIXED on 19Dec2016. History thinks that resolution was FIXED. 

I would suggest that comment #8 might have said that a dependency had actually been set. I did not infer that from the comment - had I noticed the dependency I would have removed it after comment #9.