Page 3 of 4

Re: Deleting Clipped Audio

Posted: Tue Nov 27, 2012 1:30 pm
by steve
"ESP-Clip-Fix" is currently for mono tracks only.
This as one of my first attempts at modifying a plug-in and the modification is written in spaghetti rather than LISP. I'd probably need to rewrite the whole thing from scratch to develop it further, but this seems to be quite a rare problem so it is not very high in my priorities.

Re: Deleting Clipped Audio

Posted: Thu Nov 29, 2012 8:33 am
by Gale Andrews
steve wrote:"ESP-Clip-Fix" is currently for mono tracks only.
Maybe a good idea to have a code comment for that, even though you rarely give the plug-in out?


Gale

Re: Deleting Clipped Audio

Posted: Fri Jun 13, 2014 8:53 pm
by momop540
tlm wrote:I've attached a small mp3 portion of the audio to this post for steve and others who've requested it.
test.mp3
In response to Gale: yes, you are surely right that the BEST way is to record the audio without clipping in the first place. But as I mentioned, I've found many posts online from folks in a similar situation to mine: The recording cannot be made again because the event is over and if we want to share it with others we are stuck with this recording. Based on my manual deleting, I KNOW that a much better product can be made by deleting the largest spikes -- but as I said, that process must be automated to be practical. I also agree that using EQ to magnify the portions to delete (the spikes seen in screenshot 3) is not 'ideal'. But I want to emphasize that for simple speech it's not necessary to have 'ideal' sound -- but it is necessary to remove glitches that hurt your ears, and that's all I'm after as the person who wants to 'repair' this audio.

In response to Koz: I guess you could say that I request 2 things in my post: (1) Being able to "select" all the data points which are highlighted when one chooses View-->Show Clipping. Once selected, you could then press "delete" and they'd be gone. (2) To be able to set a horizontal threshold above/below which data points would be selected -- thus the spikes of screen shot 3 (which is where all the unpleasant glitches occur) could then be removed by pressing "delete". I can do both (1) & (2) manually, but it just takes forever.

Thanks for all the great help, and so quick!!
---------

Tom - This is exactly what I am looking for also. Would greatly appreciate if you found a programmatic way of doing it. Thanks in advance!

Re: Deleting Clipped Audio

Posted: Sat Jun 14, 2014 1:37 am
by Gale Andrews
momop540 wrote:
tlm wrote:I've attached a small mp3 portion of the audio to this post for steve and others who've requested it.
test.mp3
In response to Gale: yes, you are surely right that the BEST way is to record the audio without clipping in the first place. But as I mentioned, I've found many posts online from folks in a similar situation to mine: The recording cannot be made again because the event is over and if we want to share it with others we are stuck with this recording. Based on my manual deleting, I KNOW that a much better product can be made by deleting the largest spikes -- but as I said, that process must be automated to be practical. I also agree that using EQ to magnify the portions to delete (the spikes seen in screenshot 3) is not 'ideal'. But I want to emphasize that for simple speech it's not necessary to have 'ideal' sound -- but it is necessary to remove glitches that hurt your ears, and that's all I'm after as the person who wants to 'repair' this audio.

In response to Koz: I guess you could say that I request 2 things in my post: (1) Being able to "select" all the data points which are highlighted when one chooses View-->Show Clipping. Once selected, you could then press "delete" and they'd be gone. (2) To be able to set a horizontal threshold above/below which data points would be selected -- thus the spikes of screen shot 3 (which is where all the unpleasant glitches occur) could then be removed by pressing "delete". I can do both (1) & (2) manually, but it just takes forever.

Thanks for all the great help, and so quick!!
---------

Tom - This is exactly what I am looking for also. Would greatly appreciate if you found a programmatic way of doing it. Thanks in advance!
As described in this topic you can open Effect > Nyquist Prompt... then paste in the following code and click OK:

Code: Select all

  (setq threhold 0.95)
    (setq frequency 16000)

    (let* ((control (rms
                      (sum (- threhold)
                        (s-max (snd-abs s) threhold))
                      20))
           (gain (/ (peak control ny:all)))
           (control (mult frequency
                      (sum 1
                        (mult control (- gain))))))
      (lp
        (lp
          (lp
            (lp
              (lp
                (lp
                  (lp
                    (lp s
                      control)
                    control)
                  control)
                control)
              control)
            control)
          control)
        control))
Note that this code won't work on stereo audio and won't work properly on audio from MP3 files because the "corners" are smoothed by MP3 encoding.

After "fixing" the track with that code, it is possible that some parts may be over 0 dB, so use the Normalize effect and normalize to -1 dB.

And you can get very close to what you are directly asking for by using Analyze > Find Clipping... . That will label the clipped regions (above 0 dB).

Then click in the panel of the label track (to left of the labels, under the name of the label track) then choose Edit > Labeled Audio > Delete (or Edit > Labeled Audio > Silence Audio). This isn't perfect but is likely to improve things. It will leave clipped regions of one sample each (though those may well not be audible) and won't help if you have reversed polarity clipping where the clip overshoots and becomes the opposite sign.


Gale

Re: Deleting Clipped Audio

Posted: Sat Jun 14, 2014 10:48 pm
by momop540
Thanks much, Gale!

I tried the Nyquist prompt and it seems to work partially. If I do Analyze->Find Clipping, there are two "clusters" identified. When I try the Nyquist code above, it fixes only one cluster. Are there any parameters I could vary ? My input is WAV file (single, 48k). I then varied "frequency" to 48k, instead of 16k and that doesn't seem to work.

Re: Deleting Clipped Audio

Posted: Sun Jun 15, 2014 5:14 am
by Gale Andrews
That Nyquist code is Steve's. Did you try Normalizing to -1 dB after the Nyquist script? Does it still look flat-topped or does it sound distorted after Normalize?

If so, can you upload an example file that the script does not "fix" and give us the web address so we can download it?

Also if the clipped cluster only has runs where a few consecutive samples are clipped, you could try deleting or silencing using the Labeled Audio commands.


Gale

Re: Deleting Clipped Audio

Posted: Sun Jun 15, 2014 6:50 am
by momop540
Gale

Here's a sample clip: https://www.dropbox.com/s/dngbvxu87xpqelb/clip_34.wav

Yes, I did try Normalizing. The thing is the second clipping never goes away, so normalizing didn't affect it. I now tries silencing and it seems to work for most part (but there's a crackle kind of sound). If you have any ideas to fix it, let me know please. Thanks!

Re: Deleting Clipped Audio

Posted: Sun Jun 15, 2014 7:48 am
by Gale Andrews
You can try CTRL + R to run the script further times, and/or try selecting the second burst only.

For such a bad instance as that you might almost as well use Pop Mute: http://wiki.audacityteam.org/wiki/Nyqui ... s#Pop_Mute .

To install Nyquist plug-ins see http://wiki.audacityteam.org/wiki/Downl ... ns#install .


Gale

Re: Deleting Clipped Audio

Posted: Mon Jun 16, 2014 5:20 am
by momop540
Thanks Gale! Pop Mute does sound applicable here and I am playing with it. One more thing. I want to use this in a more programmatic way as a command line binary. Is it possible to use this plugin and Audacity as a command line driven program so I can script it ?

Re: Deleting Clipped Audio

Posted: Mon Jun 16, 2014 6:33 am
by Gale Andrews
momop540 wrote:Pop Mute does sound applicable here and I am playing with it. One more thing. I want to use this in a more programmatic way as a command line binary. Is it possible to use this plugin and Audacity as a command line driven program so I can script it ?
Can you explain what you are trying to do - have you got a large number of files as bad as that one that need fixing? It would be better to fix the recorder if you still have more recordings to make.

You can add PopMute to a Chain in Audacity then apply the Chain to audio files. The Chain would then run attended on the files you selected, but it doesn't support more than a few thousand files. See: http://manual.audacityteam.org/o/man/ch ... ation.html .

However you can't run the Chain from the command-line, you have to open the Audacity application. Do you need to do this from the command-line? If you can compile Audacity you can run a Chain from the command-line by writing a script http://manual.audacityteam.org/o/man/scripting.html .


Gale