VideoHelp Forum

Try DVDFab and copy Ultra HD Blu-rays and DVDs! Or rip iTunes movies and music! Download free trial !
+ Reply to Thread
Results 1 to 22 of 22
Thread
  1. My audio file pcm_f32le has some values above 0 db. I'd like to cut/clip everything above 0. I know that I can use alimiter or loudnorm but the goal is to make values more than 0 to be equal to 0 and keep everything else unchanged. I cannot find appropriate command for this in the documentation.

    Quote Quote  
  2. I'd recommend using a real wave editor, one like Audacity. Then add in the Relife VST plugin and more-or-less fix the problem. What you want to do doesn't fix anything.
    Quote Quote  
  3. I need a command line tool. Also I don't need to restore clipped values. I want to cut everything above 0 and nothing more.
    Quote Quote  
  4. Try: ffmpeg -i "your.wav" -acodec pcm_s16le -ar 44100 "output.wav" (for music).
    ffmpeg -i "your.wav" -acodec pcm_s16le -ar 48000 "output.wav" (for video audiotrack).
    Quote Quote  
  5. This line adds frequencies above 12k.
    Image
    [Attachment 55915 - Click to enlarge]
    Quote Quote  
  6. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    I want to cut everything above 0 and nothing more.
    First, there is NOTHING above 0. Digital signals go up from -XXdB (depending on bitdepth) to 0dB. There is nothing above that. Greater than 0dB exists in the analog world because they utilize a thing called "headroom". Thus, there is a spread above 0dB for consumer gear (usually ~10-14dB) and professional gear (usually ~18-24dB) to accommodate signal peaks while avoiding the onset of gross distortion. With digital, once you hit the 0 ceiling, you clip and have massive distortion (because the clipping creates what amounts to a square wave, which is high in odd harmonic distortion).
    BTW, best practices of pro audio is to always set the nominal level at ~-18-24dB or so, to accommodate the digital equivalent of headroom.

    Second, your example looks to already be clipping. IOW, it has already removed any signal that would have been above 0dB.
    Note that your 2nd pic is a frequency-based plot. Yes, because of the clipping, and the square-waving, you have those added odd harmonics (aka spurious aliasing artifacts, which unfortunately are also correllated with the signal and so are even more noticeable than non-correllated noise). Those are what you are seeing in the frequency area above the normal limits. Those harmonics are lower in level (remember, you're not seeing LEVEL on the X or Y axes of the plot, except by looking at the intensity of the color - notice that the bulk of the intensity is in the lower frequencies).

    Third, why on earth would you NOT want to un-clip? The way to restore the signal properly (beyond the preferred method of re-capturing using proper signal levels to begin with), is to un-clip. Un-clipping will result in the overall level of the signal being reduced to accommodate, and then synthesizing the peaks (based on sinusoidal extrapolation). This will do what I believe you are ultimately wanting to do, whether you realize it or not.

    Fourth, I don't know of any command-line tools that are worthwhile that feature un-clipping (aka "clip restoration", "peak restoration", etc).


    Scott
    Quote Quote  
  7. I selected clipped area, reduced the volume and got all clipped information back. My file is in float format pcm_f32le.

    Image
    [Attachment 55920 - Click to enlarge]


    I think I can open wav file as a numpy array and then replace all values above 0 with 0.

    Image
    [Attachment 55921 - Click to enlarge]


    But I'm not sure what is the right range for pcm_f32le [-1.0, 1.0) or [-1.0, 1.0] or (-1.0, 1.0)?
    Quote Quote  
  8. Member ItaloFan's Avatar
    Join Date
    Jul 2018
    Location
    Colorado, USA
    Search Comp PM
    Originally Posted by Cornucopia View Post
    First, there is NOTHING above 0.
    You are thinking of integer PCM formats. OP said his audio file is 32-bit floating-point. ▒1.0* in that format may be thought of as zero dB because it correlates with the maximum/minimum amplitude possible in integer formats, but there is no actual limit in 32-bit float. It is the format used internally by wave editors and DSPs; it can go very far above or below zero, with very high precision.

    Although it might be possible, FFmpeg is primarily a video toolkit. I would use a compressor/limiter effect in a wave editor, or if I had to do it from the command-line, I'd use SoX (-l or the compand effect).

    I would not just replace everything with zeroes; that will add audible harmonics because it's pure clipping, no different than just doing a na´ve conversion to an integer bit depth. You want to use a limiter because it will e.g. logarithmically squish everything above -3 dB so that it fits into into the 0 to -3 dB range.

    * as the OP implies in the last question, one of these extremes (+1.0 or -1.0) might be an estimate; I'd have to look it up or experiment in an editor.
    Last edited by ItaloFan; 20th Nov 2020 at 13:36.
    Quote Quote  
  9. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    Yes, I didn't catch it the first time, but his last post made that quite clear.

    HOWEVER, unless this stuff was captured by some of the latest Sound Devices, or Zoom, or Tentacle Sync gear (all $$), it may CURRENTLY be 32bit float, but it wasn't captured that way. And my guess is that in the (standard PCM) capturing, it looks to have been clipped. Just because something is expressed in 32bit float format does not mean it can't represent clipped material.

    ***********************

    The OP keeps mentioning "0dB" when referring to the spectral (frequency-based) plot - which he highlighted. But there is no gauge of 0dB on that. The cutoff seems to be ~11 or 12 kHz (probably 11.025, which is common for 22.050kHz aka 1/2 of 44.1kHz sampling rate). If you really want to remove items above the 11.025kHz line (which is what I think you think you are trying to do), either resample again to 22.050kHz (which should automatically apply an anti-aliasing filter at the Fs/2 cutoff of 11.025), or just use a brick wall Low-Pass filter at 11.025kHz without resampling.

    And again, this kind of stuff is NOT best served using CLI tools.


    Scott
    Last edited by Cornucopia; 20th Nov 2020 at 17:32.
    Quote Quote  
  10. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    Note: if you actually DO have a 32bitFloat file that came from one of those new 32bitFloat devices, here is a link to what the demo'er experienced and how to get seemingly "clipped" signals to act un-clipped...
    https://www.thebroadcastbridge.com/content/entry/14755/hands-on-with-32-bit-float-recording
    First, the user records a 32-bit float file on a compatible recorder to record a 32-bit float file. When the DAW first reads a 32-bit float file, signals greater than 0 dBFS may first appear clipped since, by default, files are read in with 0 dB of gain applied.

    By applying attenuation to the file in the DAW, signals above 0 dBFS can be brought below 0 dBFS, undistorted, and used just like any 24- or 16-bit file.
    So, basically, just simple attenuation.

    Scott
    Quote Quote  
  11. Member ItaloFan's Avatar
    Join Date
    Jul 2018
    Location
    Colorado, USA
    Search Comp PM
    The spectrogram indicates a low-quality lossy source, like maybe a 64 kbps MP3. If he has access to an MP3, a better way to deal with it would be to downward-adjust the global gain field in the MP3 frames, e.g. with a tool designed for ReplayGain adjustments (MP3Gain/AACGain or foobar2000).
    Quote Quote  
  12. You are right it is a low-quality mp3. But occasionally there are some 1 frame peaks above 0. When I cut them out with numpy array I see the same artifacts on the spectrogram above 12 kHz. I think the best thing I can do is to use hard limiter.
    Quote Quote  
  13. Member
    Join Date
    Apr 2018
    Location
    Croatia
    Search Comp PM
    With ffmpeg, it is possible to do it with asoftclip=type=hard, or even aeval filter. But note that will give you distortions.
    Also with ffmpeg is even possible to declip audio.
    Quote Quote  
  14. Member ItaloFan's Avatar
    Join Date
    Jul 2018
    Location
    Colorado, USA
    Search Comp PM
    Clipping (sudden flattening of wave tops) creates a square wave, which is the sum of infinite harmonics, so yes, when you introduce hard clipping, your spectrogram will show broadband spikes of noise in those places.

    As I mentioned, I'd want to use a ReplayGain-applying tool to scale down the volume of the MP3. It could have been made from a heavily clipped source that is now partially clipped due to the nature of MP3 encoding, or it could have been made from an unclipped source but the MP3 was made obnoxiously loud due to its internal volume control (the global gain field in each frame). Either way, if we reduce that volume, we can then apply dynamic range compression as needed to bring the volume up to where you want without introducing any new clipping.

    Feel free to PM a link to the file and I'll have a look.
    Quote Quote  
  15. If you're patient, you can adjust the volume of single MP3 frame with MP3DirectCut (it can be a bit "fiddly"). Converting to a wave file too still helps, because MP3DirectCut doesn't display a real waveform, so opening a wave file in another program can tell you where to look in MP3DirectCut. Changes are you'll only be able to reduce the volume of small sections of audio by a few dB without causing audible glitches, but it might be worth a try.

    For the record, the MP3 format is capable of encoding peaks above 0dB, at least to some extent, and the same applies to AAC. Unfortunately though, not all codecs accept a 32 bit float input, and in the case of LAME which I think does, it converts to 24 bit before it encodes and clips the peaks that way. I'm fairly certain ffmpeg's version encodes 32 bit float directly and can therefore encode peaks above 0dB, although I kind of remember +6dB to +10dB being about as much as the encoder itself was happy with. It's been a while since I've tried, but I remember QAAC handling peaks well over +10dB.

    So I agree with ItaloFan. Try using something like Mp3Gain or foobar2000 to adjust the volume down over-all (it's lossless for MP3/AAC) to see if looks prettier when it's decoded. Failing that, if I need to squish the occasional peak and I'm converting anyway, I mostly use foobar2000's limiter and convert/limit in a single step. The Advanced Limiter seems to do a good job, but it doesn't kick in until the audio samples hit 0dB (I don't think) so the true peaks can still exceed 0dB. My tip of the day.... I add the Amplify DSP to the conversion chain first to increase the volume by a few dB, followed by the limiter, and followed by the Amplify DSP again to reverse the volume boost. For example
    Amplify (+3dB) -> Limiter -> Amplify (-3dB)
    would limit to -3dB, as the audio is processed in 32 bit float.

    These days, the thought of having to convert to wave, import into an editor, run a filter, adjust it, run it again, export, convert.... it's depressing just thinking about it.
    Last edited by hello_hello; 22nd Nov 2020 at 17:14.
    Quote Quote  
  16. Member
    Join Date
    Apr 2018
    Location
    Croatia
    Search Comp PM
    Originally Posted by hello_hello View Post
    These days, the thought of having to convert to wave, import into an editor, run a filter, adjust it, run it again, export, convert.... it's depressing just thinking about it.
    That is definitely the reason to use ffmpeg, all that above mentioned steps can be made with ffmpeg too.
    Quote Quote  
  17. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    Quote Quote  
  18. Originally Posted by Cornucopia View Post
    First, the user records a 32-bit float file on a compatible recorder to record a 32-bit float file. When the DAW first reads a 32-bit float file, signals greater than 0 dBFS may first appear clipped since, by default, files are read in with 0 dB of gain applied.

    By applying attenuation to the file in the DAW, signals above 0 dBFS can be brought below 0 dBFS, undistorted, and used just like any 24- or 16-bit file.
    So, basically, just simple attenuation.

    Scott
    It sounds more like he's describing the process of working with the audio you've recorded, rather than anything the Zoom itself does, but I only bring it up again because I happened to be looking at the manual today, and then 3 or 4 YouTube videos with 3 or 4 explanations on how 32 bit mode works.... but get ready to hear about the awesomeness of 32 bit float for the next five years.
    There's no going back. The cat's out of the bag.

    Anyway, from what I can gather those things have dual A/D converters sensitive to different input gains on each input, sharing the work with the combined output being 32 bit float. And some of the YouTube videos indicate it works quite well. There's no way to adjust the input gain in 32 bit mode, but from what I can tell the device doesn't try to adjust the gain either. One YouTube sceptic did say he was a little impressed when it came to amplifying very quiet sections, in respect to the noise floor, and thanks to the awesomeness of 32 bit float.
    Last edited by hello_hello; 22nd Nov 2020 at 20:59.
    Quote Quote  
  19. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    Yeah, 32bit float very cool. Puts normalizing on a whole new level (pun intended), or in another sense makes it moot.

    The idea of banking inputs on recorders (e.g. input 1 has mic A at low sensitivity, input 2 has same mic A at high sensitivity) is not new. In fact, I was doing that very thing, AND combining them into a much higher bitdepth consolidated master signal as much as 15 years ago. But then it was 24 or 32 bit int format. This just extends that idea even further.

    The thing with mixing these is not a complete panacea, however. The adage of "every channel you mix into the master adds to the noise floor" is still true, but it just helps with the linearity and lack of quantization distortion when you work fully in 32bit float. Which isn't insignificant.


    Scott
    Quote Quote  
  20. The idea of clipping above 0 was wrong. Hard limiter works better. Thank you everybody.
    Quote Quote  
  21. Originally Posted by Cornucopia View Post
    Yeah, 32bit float very cool. Puts normalizing on a whole new level (pun intended), or in another sense makes it moot.
    I'm all for working in 32 bit float, but I was a little surprised when some YouTube videos made it sound like the latest thing. It also appears to have more dynamic range than it did ten years ago. I've seen the same number quoted more than once now, so maybe it'll evolve into a fact. I don't think "precision" was mentioned in the video used for the screenshot attached.

    Image
    [Attachment 55957 - Click to enlarge]
    .

    I swear the next time some c%n$ asks me to subscribe to a f%#@ YouTube channel while I'm watching a video my head will explode.....

    I'm off on a bit of a tangent here, but perfection should be shared
    This guy has taken the art of trolling to such an amazing level..... as I watched I found myself wondering if this could be as close as it gets to the perfect troll.
    The Dark Side of the Moon: analog & digital comparison (CD, SACD, Vinyl, Tape)
    Last edited by hello_hello; 23rd Nov 2020 at 16:01.
    Quote Quote  
  22. Member
    Join Date
    Apr 2018
    Location
    Croatia
    Search Comp PM
    Do not tell him about long doubles.
    Quote Quote  



Similar Threads