VideoHelp Forum


Try DVDFab Video Downloader and rip Netflix video! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 10 of 10
Thread
  1. Member
    Join Date
    Jun 2012
    Location
    New Zealand
    Search Comp PM
    Is there any way to adjust the level of mp3 files by a known amount, and in a scripting or VBA environment?
    What I have is a pile of mp3's which I have used MP3Gain to process (No Undo so tags are not changed)
    Those with a difference of 3 or more "track gain" I use Foobars Apply Track Replay Gain to File Content hoping to convert them to approx the same level.

    But it doesn't quite do that.. if I run these back through MP3Gain some examples differences are:
    Before Foobar After Foobar
    File 1 3.0 6.0
    File 2 -3.0 3.0
    File 3 -3.0 6.0
    File 4 3.0 3.0
    File 5 6.0 4.5

    My goal is to have MP3Gains "track gain" show a value close to or on 0 where target volume is 95 db (rather than the default 89db).
    Anyone have any ideas how I can do that ? Thanks
    Last edited by kirkmc; 1st Dec 2020 at 22:07. Reason: Hadn't finished
    Quote Quote  
  2. Have you configured foobar2000 to adjust the volume to 95dB as well? The option is in Preferences under Tools/ReplayGain, although for fb2k 1.6 I think it become a popup dialogue, or I could be wrong. I'm still using an older version.
    By default I think the option to prevent clipping is enabled, so fb2k would adjust the volume to 95dB or until the peaks are at maximum, whichever comes first, and at 95dB it's likely to be the latter much of the time. There's also an option to only adjust the volume when it needs increasing.

    I converted half a dozen tracks to MP3 so I had virgin files to test, scanned them with MP3Gain, loaded them into fb2k and adjusted their volumes to 95dB, and MP3Gain displayed 0dB track gain for each (95dB target volume). All but one displayed clipping though.

    MP3Gain always writes the info to tags after it scans, as far as I know, but saves it to an APE tag whereas the rest of the word mostly writes ID3v2.3 tags. fb2k is aware of MP3Gain and while by default it uses ID3v2.3, if there's existing data in APE tags it'll also update it after adjusting the file volume, but MP3Gain is oblivious to ID3v2.3 tags, so if in doubt, tell fb2k to remove all the ReplayGain info and go through the process again. In case you're not aware, MP3Gain uses the original algorithm for scanning whereas fb2k uses the newer EBU128 method, and they can differ a bit, but that wouldn't be the cause, as long as you didn't rescan with MP3Gain after adjusting the volume with fb2k, which might result in different ReplayGain info being saved to each type of tag. If that happens I'm pretty sure fb2k goes with the info in the ID3v2.3 tag.
    The actual volume isn't written to tags, only the TrackGain or AlbumGain. MP3Gain adjusts the TrackGain or AlbumGain it displays when you change the target volume, but the info written to tags is always relative to 89dB.

    While I'm here.... here's some fb2k syntax for displaying volume in custom playlist columns if you're interested. I added a playlist view element dedicated to volume so as not to clutter playlists, and to make it easier to cut the MP3Gain cord. This syntax highlights the currently playing track, but it's not hard to change if need be.

    ReplayGain Volume
    Displays the volume in ReplayGain-speak based on any TrackGain info (not AlbumGain), but because 89dB is a sound pressure level and almost meaningless to mere mortals, I don't use it myself, although I added it as a column for the screenshot below.
    Code:
    $if(%replaygain_track_gain%,$puts(X,$sub(8900,$replace(%replaygain_track_gain%,.,)))$puts(VOLUME,$ifgreater($get(X),9999,$substr($get(X),1,3).$substr($get(X),4,5),$substr($get(X),1,2).$substr($get(X),3,4)) dB))$if(%isplaying%,>>>$get(VOLUME)<<<,$get(VOLUME)))
    Volume
    Displays the volume in human-speak (once again based on any TrackGain info). ReplayGain's 89dB is equivalent to -18 LUFS on an output meter (interchangeable as -18dB), so a 95dB target volume would translate to -12dB.
    (syntax edited to display the volume as dB to match the screenshot below, rather than as LUFS)
    Code:
    $if(%replaygain_track_gain%,$puts(X,$sub(-1800,$replace(%replaygain_track_gain%,.,)))$puts(VOLUME,$ifequal($get(X),0,0,$ifgreater($get(X),0,$replace(+$substr($num($get(X),4),1,2),+0,+),$replace($substr($num($get(X),5),1,3),-0,-))).$substr($num($get(X),5),4,5) dB)$if(%isplaying%,>>>$get(VOLUME)<<<,$get(VOLUME)))
    Track Gain
    Displays the TrackGain info, always relative to ReplayGain's 89dB.
    Code:
    [$if(%isplaying%,>>>%replaygain_track_gain%<<<,%replaygain_track_gain%)]
    Peak
    Displays the track peak in dB.
    Code:
    [$if(%isplaying%,>>>%replaygain_track_peak_db%<<<,%replaygain_track_peak_db%)]
    Image
    [Attachment 56042 - Click to enlarge]
    Quote Quote  
  3. Member
    Join Date
    Jun 2012
    Location
    New Zealand
    Search Comp PM
    Hi hello_hello thanks for the indepth rundown... always thought foobar could/would do far more than is obvious.
    No I had not altered the 89 to 95db setting. I couldn't see how to, and still can't. Using V1.4
    In Preferences-Tools-Replay Gain Scanner there's 3 checkboxes, 2 with drop downs. Neither seem to offer the 89/95 change. But both show "Configure" greyed out.

    The 4 code examples you show - are they cut/pasted into the text box "Album grouping pattern" ? It will accept more than one command ?

    When you say make it easier to cut the MP3Gain cord are you suggesting I don't need to use MP3Gain, just foobar? That would be good as it takes some time getting the mp3Gain results into something I can use. I have to screen capture and paste as text into Excel. This lets me filter and filecopy those for foobar.

    Clipping sounds like a bad thing. but I can't hear any defects and viewing in Abode Aubition shows the waveshape is not excessive.
    Quote Quote  
  4. At some stage the target volume setting was moved. Originally it was buried under Advanced preferences, and you had to type in the desired volume, whereas for newer versions it was moved to
    "Preferences/Tools/Replay Gain Scanner/Alter File Content"
    to make it more accessible, and there's a slider for adjusting the target volume.
    If there's no Alter File Content menu, you'll have to look under Advanced preferences.

    One advantage to using MP3Gain is it tells you when adjusting to the target volume will result in peaks greater than 0dB, from memory by displaying the track title in red text, and if there's already peaks above maximum the volume is displayed in red, and if "enable maximising features" is enabled in Advanced options there's a "max no clip" column displaying the maximum adjustment possible without the peaks exceeding 0dB, so it's definitely more intuitive than fb2k, which I don't think displays much ReplayGain info with any of the default themes, or possibly none at all.

    The columns I created are individual custom columns (right click on a playlist column header, select Columns/More) and not part of a grouping. Once they're created you can add them as Playlist columns. If you disable grouping you can then click on one of those columns to sort the files according to volume, or track gain etc, so sorting by volume you can easily find tracks outside a particular volume range, although I'm not sure why you wouldn't just tell fb2k to adjust them all. Files already at the target volume won't be adjusted, although keep in mind the adjustment can only be made in increments of 1.5dB (some MP3 limitation I don't understand), so you'll rarely achieve the exact target volume. When you're done adjusting you can go back to using your usual playlist grouping. If the extra columns bother you, they can be disabled until you need them again.

    One thing my fb2k columns don't tell you is the maximum possible adjustment before the peaks exceed 0dB, although you can get a fair idea looking at the track peak. The 1.5dB increment limitation might cause the peak to exceed 0dB a little. If you want to prevent that you can tell fb2k to prevent clipping when it adjusts, at least for versions 1.5 or newer. It'll adjust the target volume down according to each file's peak value if need be, but obviously for those tracks the average volume will be lower. When the peaks do exceed 0dB they're not actually clipped due to the volume adjustment, but it's likely they will be on playback so it's worth avoiding. Having said that, a peak of 1 or 2 dB above zero is possibly not going to cause clipping bad enough to hear, especially if it only happens once for a track, but there's no way to tell.

    You'll have to get used to the track gain being relative to 89dB, rather than being adjusted according to the target volume as MP3Gain displays it, but that's not too hard. For a file with a volume of exactly 89dB the track gain would be zero. If you adjust to exactly 95dB it's 6dB louder than the default, so the track gain would be -6dB.

    For the screenshot below I adjusted to 95dB without the option to prevent clipping enabled, and then clicked my custom volume header to sort by volume. Not that there's much variation as they're all adjusted to the same target volume, to the extent it's possible due to the 1.5dB increment limitation. As you can see most of the peaks now exceed 0dB but that won't always be the case. It's up to you if you want to care when it happens.

    Image
    [Attachment 56047 - Click to enlarge]
    Last edited by hello_hello; 12th Dec 2020 at 22:08.
    Quote Quote  
  5. Member
    Join Date
    Jun 2012
    Location
    New Zealand
    Search Comp PM
    Thanks again. Have just got latest version and working through... will advise.
    Quote Quote  
  6. I thought I'd deleted the file, but it turns out I hadn't so the link in the opening post here still works.

    It's for a portable version of foobar2000 I uploaded for converting audio as there's lots of conversion presets included, but the GUI is configured much like the screenshot I posted. If you want to try it you can just unzip it to a folder somewhere and run it. I think all the necessary DSPs and encoders for converting are included except for ffmpeg. There's a text file included with some instructions for where you might need to set the correct file paths in preferences, but to simply try the tab setup I use for displaying volume you only need to run it and load some tracks into a playlist. There's no column for displaying volume in ReplayGain-speak, but you can use the syntax I posted earlier to create one yourself, although I think it's ridiculous to refer to volume that way. Unfortunately though, that's how the original ReplayGain spec defined it.
    Quote Quote  
  7. Member
    Join Date
    Jun 2012
    Location
    New Zealand
    Search Comp PM
    Using the later version of Foobar and setting to 95db resulting in the files being much closer to "0" in MP3Gain.
    Can I ask you about "clipping" ? I assumed that happened when the file was too loud (no headroom). But I detect no problems listening to them or looking at the waveshape in Abode Audition. Is it a very subtle test or check and of little significance... or am I missing something?
    Thanks for the new link, I'll look at that next. I do want to get the same results as MP3Gain using just foobar to identify those to adjust.
    Is there a description of the figures in the columns? I'm guessing what "Track Gain"and "Replay Gain" actually mean.
    Quote Quote  
  8. Clipping refers to peaks going above 0dB (meaning 1 in amplitude). From what I understand, if a few samples go above 0dB, clipping them (limiting to 0dB ?) isn't a major problem. Audio tools such as Audacity and Foobar all use 32bit float representation, so the data format has headroom (going above 0dB is reversible), and this is applicable also to the Mp3 format. The issue would be different with a fixed point format (ex: 8bit integer) where the output is completely wrong when you go above the max value.
    Quote Quote  
  9. Based on hello_hello examples, foobar2K Custom column to display tagged Peak truncated to 3 decimals:
    Code:
    [$cut(%replaygain_track_peak%, 5)]
    manual: http://wiki.hydrogenaud.io/index.php?title=Foobar2000:Titleformat_Reference
    Quote Quote  
  10. Originally Posted by kirkmc View Post
    Can I ask you about "clipping" ? I assumed that happened when the file was too loud (no headroom). But I detect no problems listening to them or looking at the waveshape in Abode Audition. Is it a very subtle test or check and of little significance... or am I missing something?
    Thanks for the new link, I'll look at that next. I do want to get the same results as MP3Gain using just foobar to identify those to adjust.
    Is there a description of the figures in the columns? I'm guessing what "Track Gain"and "Replay Gain" actually mean.
    Each MP3 frame contains info specifying it's volume. To change the volume, MP3Gain and foobar2000 increases or decreases that information by the same amount for every frame in the file. To the best of my knowledge the encoded audio remains exactly the same, even when the volume is increased enough to result in the peaks exceeding 0dB. So for example, if you have an MP3 with a peak level of 0dB, you should be able to adjust the volume up by 10dB, then reduce it by 10dB and you'll be back where you started.

    It's different for a wave file, where for 16 or 24 bit PCM audio, 0dB is the maximum. If you increase the volume, any part of the waveform that would need to exceed 0dB would instead be flattened to 0dB.

    You probably know what it looks like, but here's a screenshot of an original waveform at the top, and the clipped waveform at the bottom, which was the result of increasing the volume by 10dB and then decreasing it by 10dB.

    Image
    [Attachment 56067 - Click to enlarge]


    Keep in mind though, the ReplayGain peak value is just the maximum. It doesn't tell you if 0dB is only exceeded once or if it's a regular occurrence. Often it'll only happen in one, or just a few places, but unless Abode Audition can look for clipping it's something you often need to zoom in on peaks a fair bit to see (Audacity has an Analyse/Find Clipping menu). For a lot of pop music, which is heavily compressed, it might result in clipping similar to the the next picture. I just grabbed it off the internet, but looking at the middle section of the waveform it appears clipped even though everything's below 0dB, so you'd need a closer look to be sure.

    Image
    [Attachment 56069 - Click to enlarge]


    However....
    Audacity decodes/imports all audio as 32 bit floating point by default (I'm pretty sure), so that's possibly a common practice for audio editors, and 32 bit float can store values above 0dB. So even though a waveform might look like it's clipped, sound like it's clipped and Audacity's Find Clipping option agrees, peaks above 0dB won't be clipped... until you export the audio as 16 or 24 bit PCM or encode with an encoder that doesn't support a 32 bit float input. The same thing will happen when your MP3s are decoded for playback. They'll mostly be decoded as PCM, and it can't hurt to assume 0dB is the maximum for any hardware in the playback chain, but as I said originally, if +1 or +2dB peaks aren't causing distortion, or not enough to hear, you can of course choose to ignore them.

    FYI...
    MP3Gain only looks at the sample values for the peak level. By default, foobar2000 is the same, but if you enable the True Peak scanning option, foobar2000 will reconstruct the analogue waveform as it scans, giving you the true peak, although it'll definitely slow the scanning speed by a fair amount too. The difference between sample peak and true peak is probably easier to explain with a picture.

    Image
    [Attachment 56068 - Click to enlarge]


    If you're not True Peak scanning, adjusting the volume so the peaks don't exceed -3dB is often recommended. I don't use True Peak scanning much, or fuss over peak levels unless they exceed 0dB, or even +0.5dB on a good day, but I rarely live more dangerously. That's just me though.
    I've never strayed from 89dB as the target volume, so most of the time the peak level isn't something to worry about. Except...
    When I'm transfer stuff to my mother's tablet. She uses it to play music in a fairly large hall, often connected to an amplifier/speaker setup that's only just adequate, so in order to squeeze the most out of them, I settled on 93dB for her, as mostly the peaks are still okay, but any louder and the chances increase quite a bit.
    Last edited by hello_hello; 16th Dec 2020 at 03:59.
    Quote Quote  



Similar Threads