Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Location:
code/branches/presentation2/src/orxonox/sound
Files:
2 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())
  • code/branches/presentation2/src/orxonox/sound/BaseSound.h

    r6188 r6202  
    7474        void setLooping(bool val);
    7575
     76        float getPitch() const   { return this->pitch_; }
     77        void setPitch(float pitch);
     78
    7679        //ALuint getALAudioSource(void);
    7780
     
    9295        std::string     source_;
    9396        float           volume_;
     97        float           pitch_;
    9498        bool            bLoop_;
    9599        State           state_;
Note: See TracChangeset for help on using the changeset viewer.