ModPlug Central

OpenMPT => Technical Documents => Topic started by: LPChip on October 15, 2006, 17:29:28

Title: Everything about the Pre-Amp value!!!
Post by: LPChip on October 15, 2006, 17:29:28
Today, Rewbs, Atlantis and I were having a nice discussion.

Based on the bug .45 Plugin levels screw up DXM plugin (http://forum.openmpt.org/index.php?topic=879.0), we've got into a discussion on why it happened and such. This in particulair because Rewbs didn't seem to have this problem.

As it turned out, its all about the pre-amp value. In a past, a few comparisments gave as result that setting the preamp to max with a global volume of 64 creates very good circumstances to make music, as the levels would be at an ideal situation. The thing however is, that the way MPT handles the preamp levels and global volume, becomes an issue in certain situations. One of the issues is the bug, described above.

In order to go in-depth about how and why, first a few facts.

When you apply a DirectX plugin, Modplug will send the sound to the plugin, which does calculations, and then send its output back to modplug.

This is also the case with VST plugins, except that the DirectX plugin architecture does not allow the sound to go past 100% clipping point. So what basically happens, is that the sound inside of the plugin is being capped to produce 100% volume at max, where in a VST plugin, the volume can rise above it without causing clipping.

The reason behind this has everythign to do with both the plugin levels aswell as the pre-amp settings.

As you may know, we started with Original Plugin levels. This resulted in having volume twice as loud as intended, which was caused by a bug in the code. Pre-amp was actually there to bypass that bug. RC1 was going to fix this, but due to a typo it didn't do it 2x but 16x.

RC2 was going to fix it for good and make it as it supposed to be.

This is what RC2 plugin levels do:

MPT has a sample with a given volume. This sample is being amplified by the pre-amp setting, to alter the volume of the sample. It is then being send through the effects plugin. When it comes out the effects plugin, the Global volume will alter the end volume.

As you can see, its now easy to explain why the bug occurs.

I had the pre-amp at max with a global volume of 64.

With a vst, this happens:

sample is being amplified to extreme values, the vst does calculations with it, and the global volume reduces it back to normal values.

However, with DX plugins the following happens:

sample is being amplified to extrene values, the dx plugin does calculations, detects the output to be clipping like madness, and therefor reducing the output in such way that it sounds all destorted and such (eg. compressing) and the global volume then reduces it back to normal volume, except that due to the dx plugin, its not normal anymore.

With this knowledge, Rewbs, Atlantis and I were doing some tests.

It seems that a Pre-Amp value of about 33% (to 33.3333%) in conjunction to a global volume of 128 gets the perfect non-clipping range to make your music in.

For that reason, I recommend to use a Pre-Amp value of 33% at all times, with a combination of a global volume of 128.

Rewbs will make an RC3 plugin levels setting that will override the pre-amp value to 33% (the exact value is yet unknown, but it will result in a perfect 0.0 clip level.
Title: Everything about the Pre-Amp value!!!
Post by: Atlantis on October 15, 2006, 19:08:58
I'm still going to have to look into this a bit more tomorrow, but just to follow up on some of your points:

Yes, in the past (MPT 1.16), setting the Pre-Amp to full, and leaving the global volume at 128 gave a maximum output of -9.1 dB, which is an ideal situation for mixing most styles of music (the loudest instrument would get this level, i.e. a channel volume of 64, if the sample originally peaks at 0.0 dB, and the instrument and sample volumes are left at 64).

Based on the test I did earlier (OpenMPT1.17RC2), this output seems to have changed to -8.9 dB now (when using a global volume of 64 however), so there's another question for you...

About the DX architecture, what is "100% clipping", anyway? If you mean 0.0 dB, how does the level even get that high? I guess this would be something I need to look into still.

Now I'm not sure about DX effects, nor VST effects for that matter, but the Pre-Amp doesn't actually amplify the volume - it only scales it. As it is now (OpenMPT1.17RC2), a global volume of 128 and a Pre-Amp setting of full produces an output of -2.9 dB if the input sample peaks at 0.0 dB (and with all volumes on full), so it's not actually amplifying it...

As for setting the Pre-Amp to "33%", as far as I can tell this produces an output of around -13.0 dB, so wouldn't it be better to just set it closer to one step down from the middle line (thereby achieving the recommended -9.5 dB level)? Or in other words, 19 steps up from the bottom. Then again, I'm still not sure how the levels are handled internally, nor with DX effects for that matter, so I'll go over this all again tomorrow.

Finally, why would you even want to achieve a "perfect 0.0 dB clip"? What if it was an EQ effect, and you boosted the level higher?

What we want for RC3 (or at least I think so) is for the internal volume to be multiplied by 0.3333% to reduce the level by -9.54 dB, which is then fed into the plugin process (which is still well below clipping, and should allow for sufficient gain), and then further scaled down by the global volume (which would be 128 by default).

Well, this post is probably taking us back in circles again, so maybe I should just read our conversation again and do some more testing tomorrow. :)
Title: Everything about the Pre-Amp value!!!
Post by: LPChip on October 15, 2006, 19:22:28
I'm not good with technical stuff, but when comparing with my music, setting preamp to 33 % with a global volume of 128, my song seems to sound the best. These have plugins, but also have been tuned on my old setting. Its true, I haven't changed the volume settings and volumes sound different, but it doesn't clip.

I'll do further testing myself to see if the preamp can be raised, but as rewbs pointed out in our conversation, setting pre-amp to about 33% is equally to no preamp at all.

I also think that if no preamp is being used, plugins have lower values to work with, which could result in a little better cpu management. Maybe a bad theory, but why not?

calculating with values under 10 is easier than with values under 1000 right?
Title: Everything about the Pre-Amp value!!!
Post by: XAVT on October 15, 2006, 20:30:30
Aren`t you a programmer lp?
I dont see how would lower volume levels effect the cpu as the lower the levels are the "higher" the db number that represents them is. Besides, I seriously doubt that the difference in cpu power needed to calculate 10s or 1000s is significantly different. Finally, don`t forget that this whole thing would later on have to be amplified, thus consuming our dear cpu again ;)

From what I gather you`ve descovered that working with certain volume levels in combination with VST`s can produce unwanted distortion.

I suggest you think about it a lil` more before posting ;)
Title: Everything about the Pre-Amp value!!!
Post by: speed-goddamn-focus on October 15, 2006, 21:14:03
I'm a bit unsure about Atlantis' specified levels, aren't they depending on the number of channels?

Also, is there really a need for the preamp setting? There's already global volume, channel volume, a couple of sample volumes, instrument volume, VSTi volume and plugin gain.
Title: Everything about the Pre-Amp value!!!
Post by: rewbs on October 15, 2006, 21:29:08
I have to admit that here are a couple of things irritating me here:

-. This should not be an announcement: it is a normal discussion topic. The top of this forum is already crowded enough! :)
-. The original post makes things sound a lot more complex than they really are. Here's the story:

1. The original MPT had an issue by which the volume of samples was halved before being sent to plugins. The output of plugins was then doubled, masking the problem to some extent.

2. Those who noticed plugins were not receiving the correct level found they could resolve this by pumping up the general "pre-amp" setting, which boosts sample volumes (or more precisely ends up diminishing the amount of standard attenuation) before any plugin processing occurs.

3. In 1.17 RC2, we fixed the volume-halving bug. Therefore leaving the pre-amp pumped up can cause higher levels to reach the plugs, which might result in saturation.

4. Additionally, the 1.17RC2 mix mode fixes the global volume so that it is applied after plugin processing. Anything below 128 global volume will lower the overall final output.

5. If you are upset or confused by the fixes in 1.17RC2, you can emulate the original MPT by using the original mix mode.

That's all you really need to know.
A little more info here: http://openmpt.xwiki.com/xwiki/bin/view/Manual/SongProperties#HPluginLevels


We did have further discussions around this topic, of which the conclusions were:
1. We should introduce a new mix mode (probably called RC3) in which pre-amp is disabled, global volume defaults to 128, and the sampler attenuation is less obscure, i.e. it defaults to approx -10.0db (thanks for the suggestion Atlantis) and is explicitly adjustable with less parameters all over the place.
2.We should address any backwards compatibility issues this entails. Exactly what this requires is TBD but so far we have done a pretty damn good job at providing options to preserve backwards compat, imho.
Title: Everything about the Pre-Amp value!!!
Post by: rewbs on October 15, 2006, 21:41:27
Quote from: "speed-goddamn-focus"I'm a bit unsure about Atlantis' specified levels, aren't they depending on the number of channels?
There are several attenuation steps spread out in various places in the code. One is a fixed 16x downscale, one is indeed dependent on the number of channels (though it becomes fixed from 31 chans). And of course the levels also gets thrashed around by the parameters you list, plus envelopes, all the panning parameters, ramping, and probably some more.

This resulting opaqueness is source of confusion.
Title: Everything about the Pre-Amp value!!!
Post by: LPChip on October 15, 2006, 21:43:11
Well said Rewbs. Sometimes it can be so hard to say something so easy :)

2Xavt, no need to tell me that i have to think before posting... We had a discussion that went over for about 2 hours, with lots of information. It was hard to make a good post out of it. I'm not that much of a programmer. Just a little webdevelopment.

Rewbs explained how the levels work but due to that I'm using windows messenger atm, I didn't have the history of the chat, and couldn't look up what was said.
Title: Everything about the Pre-Amp value!!!
Post by: Atlantis on October 15, 2006, 22:50:26
Quote from: "speed-goddamn-focus"I'm a bit unsure about Atlantis' specified levels, aren't they depending on the number of channels?
Sure, but I'm talking about the loudest instrument (with the highest peak level), on which you'll base the rest of the mix, and which should take the mix level to around -3.0 dB (which you can of course increase during mastering). At least, that's when you start out with your kick around -8.0 dB in dance music, but for most other styles it will be around -10.0 dB (the kick usually being the highest peaking instrument).

QuoteAlso, is there really a need for the preamp setting? There's already global volume, channel volume, a couple of sample volumes, instrument volume, VSTi volume and plugin gain.
I think we all agreed on that.
Title: Everything about the Pre-Amp value!!!
Post by: Snu on October 16, 2006, 06:39:15
as much as i am for backwards compatability... i really think once we get the 'correct' mixing levels in the program, we should remove all the extra nonsense (pre amp, different mixing level presets), as they will only serve to confuse 99.99% of users, who would have no use for those...

that being said, if there are those that insist, perhaps there could remain an option in the .ini file, and it could merely be removed from the options dialogs...
but, i think that for whatever works in progress there are that are set to use a nonstandard mixing level, one could have an old version of mpt installed as well.
also, there is the point that this IS a beta version, no changes are guarenteed final as is the essence of a beta.
Title: Everything about the Pre-Amp value!!!
Post by: LPChip on October 16, 2006, 07:48:33
As for removing the plugin levels...

On one hand, I agree on you, whilst on the other hand, I don't. :)

Indeed, we don't need the older plugin levels for new songs, but what about old songs that you still want to play in MPT?

Hiding the setting perhaps is a nice idea.
Title: Everything about the Pre-Amp value!!!
Post by: speed-goddamn-focus on October 16, 2006, 08:02:28
Quote from: "LPChip"but what about old songs that you still want to play in MPT?

Keep your old version of MPT for those.

Quote from: "Atlantis"Sure, but I'm talking about the loudest instrument (with the highest peak level), on which you'll base the rest of the mix, and which should take the mix level to around -3.0 dB (which you can of course increase during mastering).
I think you misinterpret me, if you read rewbs post perhaps you'll get my point (which is that levels vary depending on circumstances such as thte number of channels in the mod).
Title: Everything about the Pre-Amp value!!!
Post by: Asharin on October 16, 2006, 08:19:08
I've always left the pre-amp setting alone :p
Title: Everything about the Pre-Amp value!!!
Post by: LPChip on October 16, 2006, 08:22:26
Quote from: "Asharin"I've always left the pre-amp setting alone :p

I'm not sure if the setting is good by default though...
Title: Everything about the Pre-Amp value!!!
Post by: Atlantis on October 16, 2006, 09:59:05
Quote from: "speed-goddamn-focus"
Quote from: "Atlantis"Sure, but I'm talking about the loudest instrument (with the highest peak level), on which you'll base the rest of the mix, and which should take the mix level to around -3.0 dB (which you can of course increase during mastering).
I think you misinterpret me, if you read rewbs post perhaps you'll get my point (which is that levels vary depending on circumstances such as thte number of channels in the mod).
I see what you mean now. I wasn't even aware of that, and this would complicate things even more. I really don't see why would you want to downscale based on the number of channels though.
Title: Everything about the Pre-Amp value!!!
Post by: Asharin on October 16, 2006, 11:22:45
Quote from: "LPChip"
Quote from: "Asharin"I've always left the pre-amp setting alone :p

I'm not sure if the setting is good by default though...
That's okay my music is crap enough that the volume doesn't afect it much :D
Title: Everything about the Pre-Amp value!!!
Post by: speed-goddamn-focus on October 16, 2006, 15:22:03
Quote from: "Atlantis"I really don't see why would you want to downscale based on the number of channels though.
To avoid clipping. Mixing is basically adding, which means that if two channels hit 0dB at the same time (not completely unlikely) you get 6dB. The higer number of channels you get, the higher the possible peaks get, even if they become more unlikely as you add channels.
Title: Everything about the Pre-Amp value!!!
Post by: xaimus on October 16, 2006, 17:13:30
That seems like a vestigial feature--the user should modify the mix to avoid such situations, not the sequencer/tracker.
Title: Everything about the Pre-Amp value!!!
Post by: speed-goddamn-focus on October 16, 2006, 20:54:01
Quote from: "xaimus"That seems like a vestigial feature--the user should modify the mix to avoid such situations, not the sequencer/tracker.
Well I don't *really* know how it works, I'm just pretending. I thought I had it all figured out then I started thinking about the virtual channels and I got a headache. On another note, I agree with Rewbs that there is absolutely no reason for this discussion to be posted as an announcement.
Title: Everything about the Pre-Amp value!!!
Post by: rewbs on December 22, 2006, 00:21:47
De-announcing. This thread is interesting but does not need to live at the top of the list.
Title: Everything about the Pre-Amp value!!!
Post by: Rxn on April 19, 2009, 22:12:15
Hi guys,

I was wondering actually about this pre-amp thing today. How does this actually work?

For example, we have a 16 bit normalized sample, how does pre-amplification work for it? You cannot increase the volume without it going into clip.
Title: Everything about the Pre-Amp value!!!
Post by: Sam_Zen on April 19, 2009, 23:11:09
Nice bump
Title: Everything about the Pre-Amp value!!!
Post by: Saga Musix on April 20, 2009, 13:02:11
The internal mixer routines are working with 32-bit precision, as the manual says.
Title: Everything about the Pre-Amp value!!!
Post by: Rxn on April 20, 2009, 13:05:29
Hi Jojo,

so what is the chain of conversion in this case?

Sample->convert to 32 bits (zero padding?)->multiply by Pre-Amp value->all the rest of operations?
Title: Everything about the Pre-Amp value!!!
Post by: Saga Musix on April 20, 2009, 13:40:09
I dunno :> But judging from the results, that sounds quite plausible.
Title: Everything about the Pre-Amp value!!!
Post by: Rxn on April 20, 2009, 13:52:52
I thought a developer might know that :)
Title: Everything about the Pre-Amp value!!!
Post by: LPChip on April 20, 2009, 14:12:21
Are you using the RC3 or RC2 mixmode settings?

By default from .48 and on, the mode has been set to RC3. In such cases, the pre-amp value is no longer being taken into account.
Title: Everything about the Pre-Amp value!!!
Post by: Saga Musix on April 20, 2009, 14:20:23
Rxn: Sure, but I have never touched the mixer routines since I've been a developer (read: since last october).
Title: Everything about the Pre-Amp value!!!
Post by: Rxn on April 20, 2009, 14:23:23
Hi LPChip,

I would like to figure out how both of them work. What is the conversion chain in RC3 including all the volume controls along the sample path?

The reason why I am asking is because it struck me that we might be losing resolution bits in samples if conversion\amplification steps are not done properly and\or in a right sequence.
Title: Everything about the Pre-Amp value!!!
Post by: LPChip on April 20, 2009, 16:20:43
Quote from: "Rxn"Hi LPChip,

I would like to figure out how both of them work. What is the conversion chain in RC3 including all the volume controls along the sample path?

The reason why I am asking is because it struck me that we might be losing resolution bits in samples if conversion\amplification steps are not done properly and\or in a right sequence.

Have you actually read the posts on the first page of this topic? Its being explained there by Rewbs.