Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
volume
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jon Rafkind  
View profile  
 More options Jun 4 2010, 2:14 pm
From: Jon Rafkind <jon.rafk...@gmail.com>
Date: Fri, 4 Jun 2010 11:14:23 -0700 (PDT)
Local: Fri, Jun 4 2010 2:14 pm
Subject: volume
I am using GME successfully in my game but the sound it generates is
fairly quiet. How can I increase the volume that GME produces?

I'm not sure I should be touching gain..

If I print out the maximum amplitudes generated by GME I see the
following, where each printed line analyzes the output of one call to
emu->play(length, buffer). Amplitudes are in absolute value.

; for River City Ransom.nsf
...
Largest amplitude 7071
Largest amplitude 8131
Largest amplitude 7329
...

;  StreetsOfRage2-01.gym
...
Largest amplitude 3065
Largest amplitude 2706
Largest amplitude 1201
...

Whereas if I use some other music generator (the DUMB library for mod/
s3m/xm/it) I get much larger amplitudes:

; aqua.s3m
...
Largest amplitude 31884
Largest amplitude 28710
Largest amplitude 22977
...

I browsed the GME source but didn't find any obvious places to hack
volume.

I see lines like these in Gym_Emu.cpp:174

apu.volume( 0.135 * fm_gain * gain() );
dac_synth.volume( 0.125 / 256 * fm_gain * gain() );

With a default value for fm_gain of 3 and gain() of 1 that gives the
apu a volume of 0.405.

I tried setting the gain value in Music_Emu.cpp but for too large
values the output is distorted.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Shay  
View profile  
 More options Jun 6 2010, 3:24 pm
From: Shay <gbla...@gmail.com>
Date: Sun, 6 Jun 2010 12:24:31 -0700 (PDT)
Local: Sun, Jun 6 2010 3:24 pm
Subject: Re: volume
So if you set gain() to 2.0, you get distorted output? How are you
determining maximum amplitude? What sort of amplitudes do you see if
you run one of the demos and examine the WAV file in a sound editor?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jon  
View profile  
 More options Jun 7 2010, 12:19 pm
From: jon <jon.rafk...@gmail.com>
Date: Mon, 07 Jun 2010 10:19:29 -0600
Local: Mon, Jun 7 2010 12:19 pm
Subject: Re: [SNDEMU] Re: volume
On 06/06/2010 01:24 PM, Shay wrote:

> So if you set gain() to 2.0, you get distorted output? How are you
> determining maximum amplitude? What sort of amplitudes do you see if
> you run one of the demos and examine the WAV file in a sound editor?

gain() doesn't affect nsf files (as noted in the source) but for .gym
files I see distortion at various values of gain. For
StreetsOfRage2-01.gym I get distortion at gain=4, but if I set gain=5
then it starts to sound normal again. Then at gain=6 and up it sounds
distorted some more. I looked at the waveforms with different gain
settings using the player included with the GME source. For higher
values of gain I get higher amplitudes for some channels but others
don't seem to be affected very much.

I was determining maximum amplitude with this code:

emulator->play(length / 2, (short*) stream);
short large = 0;
     short small = 0;
     for (int i = 0; i < length / 2; i++){
         short z = ((short *) stream)[i];
         if (z < small){
             small = z;
         }
         if (z > large){
             large = z;
         }
     }
     Global::debug(0) << "Largest " << large << " Smallest " << small <<
std::endl;

Actually this code finds the highest and lowest amplitudes.

Anyway, if gain() doesn't affect all files equally (nsf) then I don't
think its the right parameter to use. Someone else recommended that I
figure out the maximum amplitude for a given file and scale every sample
by a constant such that the maximum amplitude from GME is the maximum
amplitude for my sound output.

int largestAmplitude = calculateLargest(gme_output);
double factor = (double) 0x7fff / largestAmplitude;
for (i = 0; i < length; i++){
    gme_output[i] *= factor;


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Shay Green  
View profile  
 More options Jun 8 2010, 7:20 pm
From: Shay Green <gbla...@gmail.com>
Date: Tue, 8 Jun 2010 18:20:52 -0500
Local: Tues, Jun 8 2010 7:20 pm
Subject: Re: [SNDEMU] Re: volume
gain() is only meant for small adjustments, say up to 2.0. 6.0 is
really high. It's probably best to just do the adjustment yourself
with the samples read back. You can do various clamping, or automatic
level control. I'm surprised it's too quiet. Are you running this on a
device without a volume control?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jon  
View profile  
 More options Jun 8 2010, 7:35 pm
From: jon <jon.rafk...@gmail.com>
Date: Tue, 08 Jun 2010 17:35:49 -0600
Local: Tues, Jun 8 2010 7:35 pm
Subject: Re: [SNDEMU] Re: volume
On 06/08/2010 05:20 PM, Shay Green wrote:

> gain() is only meant for small adjustments, say up to 2.0. 6.0 is
> really high. It's probably best to just do the adjustment yourself
> with the samples read back. You can do various clamping, or automatic
> level control. I'm surprised it's too quiet. Are you running this on a
> device without a volume control?

I'm just running this on a laptop, I can easily change the volume using
normal OS features. The point is that playing a song (either ogg or
mod/it/s3m/xm) have one volume level but playing anything with GME is at
a much lower volume level. The application I am writing is a game and I
don't want to force users to adjust their volume during gameplay.

I will look into adjusting the samples myself, but I find it surprising
no one else has wanted this feature.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »