Apu volume handling

Discuss emulation of the Nintendo Entertainment System and Famicom.
User avatar
Anes
Posts: 717
Joined: Tue Dec 21, 2004 8:35 pm
Location: Mendoza, Argentina

Apu volume handling

Post by Anes »

Well, my emulator is getting a "float" sample from a LUT that is built as blargg says.
I want to implement volume in my emulator with a win32 slide bar.

Code: Select all

scale_factor = pow(1.122018454, db);
Then i get the sample multipling it by that "scale_factor" given a decibel -> db value.
A db value is between -36 to 12.

Im using "short" (16 bit) per sample.
All this give me a float value that is small, so i multiply for example by 5000.
I want to know which value should i multiply the sample to get min and max volume,
ANes
Joe
Posts: 773
Joined: Mon Apr 01, 2013 11:17 pm

Re: Apu volume handling

Post by Joe »

Anes wrote: Wed Sep 24, 2025 8:44 amA db value is between -36 to 12.
Normally max volume is 0 dBFS. Where did you get 12 from?
Anes wrote: Wed Sep 24, 2025 8:44 amI want to know which value should i multiply the sample to get min and max volume,
Your scale factor is (approximately) 4 when your volume is set to "12 dB". If your unscaled samples have peaks at -1 and 1, and you want "12 dB" to be 0 dBFS to avoid clipping, you would multiply the scaled samples by (approximately) 8192 to move the peaks from -4 and 4 to -32767 and 32767.
User avatar
Anes
Posts: 717
Joined: Tue Dec 21, 2004 8:35 pm
Location: Mendoza, Argentina

Re: Apu volume handling

Post by Anes »

Well, as you said i multiplied by 8192 and things got better.
I want to ask which will be the range of decibels to do things well.
That range was given to me by Tepples.

Which is the correct decibels range? and how to make volume control well?
ANes
tepples
Posts: 22993
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)

Re: Apu volume handling

Post by tepples »

In the past, I might have guesstimated a nominal level of 12 decibels below full scale (-12 dBFS) to give the signal some headroom to cooperate with other audio sources that the operating system is mixing together. That would mean 0 dBFS corresponds to +12 dB nominal, and 0 dB nominal corresponds to -12 dBFS. In 16-bit, -12 dBFS corresponds to 8192 units, as full scale is 32768 units and each -6 dB corresponds to a halving of output voltage. I don't remember where I got that 12 dB headroom value. And in my experience, FCEUX default settings tend to be much louder than Mesen 2 default settings.

If I had to come up with appropriate absolute output levels from first principles, maybe the default overall scaling of an NES emulator's audio output should be based on how the output voltage compares to a nominal "line level." For home audio equipment, the nominal level is -10 decibel volts root mean square (-10 dBV). This corresponds to a sine wave at 0.894 volts peak-to-peak (Vp-p), 0.447 volts amplitude, or 0.316 volts root-mean-square (Vrms). The article claims that the maximum level of a line output is 2 Vp-p, which provides some headroom over the nominal level. A strict interpretation of this would treat each unit of 16-bit signed PCM as 1/32768 of a volt.

Another possibility is to normalize the levels to those of a Super NES Control Deck connected to the same A/V switch. We know what its full scale is because that system is a 16-bit DAC.

Further questions, if we go down this route of trying to standardize what the headroom "should" be:
  1. Is 1/32768 V per unit a reasonable convention?
  2. What is the actual Vp-p of each model's AV output (front-loading NES and new Famicom) when playing the loudest possible signal for each of the five internal channels?
  3. What is the actual Vp-p of a Super NES playing a sine wave, whether at full scale or at 25%?
User avatar
Dwedit
Posts: 5257
Joined: Fri Nov 19, 2004 7:35 pm

Re: Apu volume handling

Post by Dwedit »

I read the thread title and couldn't stop thinking of the Simpsons character rather than the NES Audio processing unit.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!