Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Implementing bicycle audio


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 AhmedSaleh   Members   -  Reputation: 155

Like
0Likes
Like

Posted 10 March 2014 - 03:46 PM

Hi All,

 

I have a bicycle, and a sound that's "clicking" simulation of the freewheel. How would you implement that clicking noise ?

Would you change the pitch of the sound?


Game Programming is the process of converting dead pictures to live ones .

Sponsor:

#2 xbattlestation   Members   -  Reputation: 320

Like
1Likes
Like

Posted 10 March 2014 - 04:38 PM

The pitch should not change, the speed of the clicks should change, according to the speed of the bike.  I think if you change the speed of the sample, the pitch would change too much, but you may want to experiment and confirm that.  Alternatively you could have several samples of a wheel spinning at different speeds?


Storm Clouds over the Western Front - 2D aerial combat WIP | DarklightXNA on Twitter | 2DFlightSim on Youtube

#3 Stainless   Members   -  Reputation: 1070

Like
1Likes
Like

Posted 10 March 2014 - 06:42 PM

It depends on the platform you are running on.

 

In the general case you would create a new instance of the sound effect every time you want a click, but in practice this often sounds crap.

 

The best way I have found to do similar things is to create 3 or 4 sound effects for the click, each very slightly different.

 

Then randomly choose one of them and create a new instance of that when you want a click.

 

I honestly cannot tell you why this works better than just using one sound effect, but it does.



#4 AhmedSaleh   Members   -  Reputation: 155

Like
0Likes
Like

Posted 11 March 2014 - 07:13 AM

I'm currently doing the following code, but I'm not sure of it

// in game loop

if (currentSate == RunnerBase.BikerStates.RUNNING)
        {
            if (!mRunningSound.IsPlaying)
            {
                mRunningSound.Play();
            }
          //  clickCounter++;
           // if (clickCounter > 15)
          //  {
                mRunningSound.AudioSource.pitch =(mBiker.BikeRunner.Speed/30.0f);
          //      clickCounter = 0;
           // }

        }

Game Programming is the process of converting dead pictures to live ones .

#5 Stainless   Members   -  Reputation: 1070

Like
1Likes
Like

Posted 11 March 2014 - 09:39 AM

That just won't work I'm afraid

 

Start off by trying this (pseudo code)

 

     LoadSoundEffectIntoMemory(CLICK);

     Update()

     {

           accumulator += mBiker.BikeRunner.Speed;

           if (accumulator>CLICK_RATE)

           {

                PlayNewInstanceOfSOund(CLICK);

                accumulator-=CLICK_RATE;

           }

     }

 

The problem is that a click from the bike doesn't stop in real life when another click starts. You get a new sound every time a click happens. So the sound overlaps, interferes with itself, sounds completely different. It doesn't go up in pitch.

 

You need to have a sound manager that supports instances and keep the click sound effect short so that the number of sound effects playing doesn't explode.



#6 AhmedSaleh   Members   -  Reputation: 155

Like
0Likes
Like

Posted 11 March 2014 - 05:24 PM

would you tell me the idea in plain example ? the maths ?

 

I wanted to do if ( counter++>period) play, then make counter = 0;  is that wrong ?  why did you accumulate the speed then you subtract the rate from it ? 

this is not linear operation correct?


Game Programming is the process of converting dead pictures to live ones .

#7 Stainless   Members   -  Reputation: 1070

Like
1Likes
Like

Posted 12 March 2014 - 02:42 AM

okay consider a wheel with 36 spokes.

 

You have a clicker on one spoke.

 

So every time the wheel rotates one revolution, you get one click.

 

Say you start off slow, you only move the wheel 10 degrees in the first pass, that is one spoke moving past the reference point. So you don't make a click sound.

 

The next pass you accelerate and the wheel turns 370 degrees, that's 37 spokes passing the reference point, the accumulator is now at 38 so you make a click sound.

 

38 - 36 means that the clicker is 20 degrees past the reference point.

 

Zeroing the counter would put the clicker at the reference point, so you have lost 20 degrees of rotation and delayed the next click.

 

If you want a really good effect you will have to do a lot more work, but this simple technique will give you a starting point.


Edited by Stainless, 12 March 2014 - 02:44 AM.


#8 AhmedSaleh   Members   -  Reputation: 155

Like
0Likes
Like

Posted 12 March 2014 - 04:25 AM

That's really the idea of a basic wheel encoder, where you count the ticks of the wheel, correct?

 

What are your suggestions to make it better?


Edited by AhmedSaleh, 12 March 2014 - 04:25 AM.

Game Programming is the process of converting dead pictures to live ones .

#9 Stainless   Members   -  Reputation: 1070

Like
1Likes
Like

Posted 12 March 2014 - 07:55 AM

Once you get up to a speed where you are generating a lot of clicks, it will start to sound a bit weird.

 

It's due to the nature of sampled sound, analogue signals combine in a different way than digital signals.

 

Also the clicker does not return to a stable state between clicks. It doesn't have time to settle down to a stable state. So the sound it creates changes.

 

Think of a guitar string, pluck it when it is stationary and you get one sound, pluck it several times in a row and you get a more complex sound.

 

To emulate this I would have several click sound effects in memory and select one at random each time you play one. 

 

The end result should sound a lot better than the simple case.



#10 AhmedSaleh   Members   -  Reputation: 155

Like
0Likes
Like

Posted 12 March 2014 - 08:31 AM

How about getting the reverse ? when the bike settles or decelerating? it should clicks in reverse ?
doesn't hear nice :/

   clickCounter += mBiker.BikeRunner.Speed;
            
            if (clickCounter < clickRate)
            {
                if (!mRunningSound.IsPlaying)
                {
                    mRunningSound.Play();
                }

                clickCounter -= clickRate;
            }

Game Programming is the process of converting dead pictures to live ones .

#11 Stainless   Members   -  Reputation: 1070

Like
0Likes
Like

Posted 12 March 2014 - 10:48 AM

Because you are only playing one sound effect and if it is already playing, you don't play it at all.

 

You have to play multiple sound effects.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS