Very strange "damage" to audio track - need to repair

Help for Audacity on Windows.
Forum rules
ImageThis forum is for Audacity on Windows.
Please state which version of Windows you are using,
and the exact three-section version number of Audacity from "Help menu > About Audacity".


Audacity 1.2.x and 1.3.x are obsolete and no longer supported. If you still have those versions, please upgrade at https://www.audacityteam.org/download/.
The old forums for those versions are now closed, but you can still read the archives of the 1.2.x and 1.3.x forums.
steve
Site Admin
Posts: 81627
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Very strange "damage" to audio track - need to repair [SOLVED]

Post by steve » Wed Jan 02, 2019 4:55 pm

tcmullet wrote:
Wed Jan 02, 2019 3:00 pm
Maybe I need to bite the bullet and learn how to write a C++ utility that will subtract 16384 from every 3rd sample in the right channel.
You could do that with Nyquist in Audacity.
Unfortunately I don't think it would be a complete solution because:
1) The left channel is also affected, though to a lesser degree.
2) The offset (right channel) does not appear to be totally constant - it seems to be around 0.60 to 0.62.

This is a proof of concept, but only suitable for short selections (not much more than a few seconds):

Code: Select all

;version 4
(defun process (sig)
  (setf ln (truncate len))
  (setf ar (snd-fetch-array sig ln ln))
  (do ((i 0 (+ i 3)))
      ((>= i ln)(snd-from-array 0 *sound-srate* ar))
    (setf (aref ar i)(- (aref ar i) 0.61))))

(vector (aref *track* 0)
        (process (aref *track* 1)))
The above code processes the right channel only, and subtracts 0.61 from the value of every third sample.
This is the result:
weird-error-processed.wav
(1.28 KiB) Downloaded 5 times
First Track001.png
First Track001.png (15.03 KiB) Viewed 82 times
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

tcmullet
Posts: 87
Joined: Tue Aug 28, 2018 5:02 pm
Operating System: Windows 10

Re: Very strange "damage" to audio track - need to repair [SOLVED]

Post by tcmullet » Wed Jan 02, 2019 6:45 pm

I'm confused. Where did you get the .61? Based on what I can see in the graphic I included, the amount needing subtraction is about (or exactly) 16384, not an integer less than 1. (I don't grasp enough of your code to interpret it.)

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

Re: Very strange "damage" to audio track - need to repair [SOLVED]

Post by steve » Wed Jan 02, 2019 8:00 pm

tcmullet wrote:
Wed Jan 02, 2019 6:45 pm
Where did you get the .61
Sample values may be represented as integers (usually 8, 16 or 24 bit) or as floating point numbers (usually 32-bit). When integer formats are used, the numeric values are "normalized" to a range of +/- 1.0. This is why the vertical ruler on the left end of a track shows a range of +/- 1.0.

For floating point formats, the literal range of +/- 1.0 is "valid" audio, in that +/- 1.0 represent "full scale" (0 dB, full track height). 32-bit float also supports values greater than 0 dB, which makes it an extremely useful format when working with sound (if you inadvertently cause the level to exceed 0 dB, then it can be recovered back to the "valid" range without loss.)

A single sample value may be found using the Nyquist Prompt and the command SND-FETCH.

Example for a mono track:

Code: Select all

;version 4
(snd-fetch *track*)
The above command fetches the value of the first sample in the selection.

To see the values of the first three sample of the selection, you can use:

Code: Select all

;version 4
(print (snd-fetch *track*))
(print (snd-fetch *track*))
(print (snd-fetch *track*))
Click the "Debug" button to see the three results.


I got the figure of 0.61 by looking at sample values in several places where there was one of the high values, with a low value either side (such as the 3rd, 4th and 5th samples). I then took the average of the outer two "correct" values, and subtracted that from the value of the "too high" sample, so as to derive an approximation of the offset.

Testing a few values this way gave "offset" results in the range of about 0.60 to 0.62.

The code in my previous post can run in the Nyquist Prompt. Try it :)
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Post Reply