Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 2, 2009, 4:52:42 PM (14 years ago)
Author:
youngk
Message:

Implemented speed dependent audio pitch. BUG pitching doesn't currently work.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/orxonox/sound/BaseSound.cc

    r6190 r6202  
    5050        RegisterRootObject(BaseSound);
    5151
     52        this->volume_ = 1;
     53        this->pitch_ = 1;
     54
    5255        if (GameMode::playsSound())
    5356        {
     
    129132        if (GameMode::playsSound())
    130133            alSourcei(this->audioSource_, AL_LOOPING, (val ? AL_TRUE : AL_FALSE));
     134    }
     135
     136    void BaseSound::setPitch(float pitch)
     137    {
     138        if (pitch > 2 || pitch < 0.5)
     139        {
     140            COUT(2) << "Sound warning: pitch out of range, cropping value." << std::endl;
     141            pitch = pitch > 2 ? 2 : pitch;
     142            pitch = pitch < 0.5 ? 0.5 : pitch;
     143        }       
     144        this->pitch_ = pitch;
     145        if (GameMode::playsSound())
     146            alSourcei(this->audioSource_, AL_PITCH, pitch);
    131147    }
    132148
     
    194210        alSource3f(this->audioSource_, AL_POSITION,  0, 0, 0);
    195211        this->updateVolume();
     212        this->setPitch(this->getPitch());
    196213        alSourcei (this->audioSource_, AL_LOOPING, (this->bLoop_ ? AL_TRUE : AL_FALSE));
    197214        if (this->isPlaying() || this->isPaused())
Note: See TracChangeset for help on using the changeset viewer.