Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Music & Sound FX / How often should sounds be manipulated to maintain a smooth change?

Author
Message
NeX the Fairly Fast Ferret
19
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 13th Oct 2009 21:38
Let's say I'm fading in some music. How many times a second should I change the volume to create the illusion of a perfectly smooth gradient? Is it the same for pitch, or a different amount of changes?

Beast E Gargoyle
17
Years of Service
User Offline
Joined: 15th Feb 2007
Location: Sunny San Diego, CA
Posted: 16th Oct 2009 07:22
Well if you are going for a boss battle I would recommend some of the popular 2D games style of incorporating music by lowering the main level theme and increasing the boss theme quickly. Otherwise, new-er games have a lot going on with 5.1 surround sound capabilities, but I am unsure of the best method for this in today's industry standards.

The Last Great Swordsmen a 3D hack N slash http://lastswordsmen.freezoka.com
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 16th Oct 2009 18:16
It's tricky, considering that you might replay sound at 44100, which is 44.1 times more accurate than the timer(). It might do the trick though - maybe best to play the main theme, check to see when it's stopped, then play it again and reset a timer.

I recently added a syncing routine to a game front end, basically kung fu noises, like chants every bar, so had to work out how frequently the chants come in. So I stored the timer() value before playing the music, then divided that by the bar length, was about 1.22 seconds, or 1220 miliseconds or...

musictime=timer()
play music 1
do

oldbar=musicbar
musicbar=int((timer()-musictime)/1220)
if oldbar<>musicbar
`Do whatever
endif
loop

I was able to get the syncing quite good with just that, worked out the 1220 milliseconds by counting the chants and dividing the sample length to get the seconds. Would obviosly be more accurate if your making the music yourself, based on the BPM.

So.... I suggest storing the timer(), then use a bar counter, and then work out a multiplier for the bar position.

bartime=timer()-musictime
barmul#=(bartime-(int(bartime/1220)*1220))/1220.0

So now barmul# goes from 0.0 to 1.0 in the space of 1 bar. If you reduce the volume based on that, it would fade out and in in the space of 1 bar. That way it would sound more natural, as if you'd composed the fade out specially. Would be especially nice if both songs use the same BPM. Getting an exact bar length in miliseconds would be the trickiest part, with that though it should be very accurate.


Health, Ammo, and bacon and eggs!
QuothTheRaven
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: United States
Posted: 17th Oct 2009 09:40
Human ears are much less sensitive to volume changes than to pitch changes. If you really really want to do the math, take the definition of a decibel:
"One decibel equals approximately the smallest difference in acoustic power the human ear can detect" (http://medical-dictionary.thefreedictionary.com/Decibels)

Then calculate the max dBm (I think dBm is what we want here) of a wave file at 44.1, and figure out what the equivalent of 1 dBm is. Of course you shouldn't do any of this. It honestly doesn't matter. If it sounds fine to you I guarantee it will be fine to everyone else. Just play it by ear, literally.

Login to post a reply

Server time is: 2024-05-05 08:44:17
Your offset time is: 2024-05-05 08:44:17