Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 15, 2009, 3:43:06 PM (15 years ago)
Author:
rgrieder
Message:

Detail changes in the sound classes.
Plus fixed the level sound problem (order of XML parameters was wrong).
There is still a large issue when changing an ambient sound source though.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/sound3/src/orxonox/sound/AmbientSound.cc

    r6046 r6069  
    3131#include "core/CoreIncludes.h"
    3232#include "core/EventIncludes.h"
     33#include "core/GameMode.h"
    3334#include "core/XMLPort.h"
    3435#include "SoundManager.h"
     
    4243    {
    4344        RegisterObject(AmbientSound);
     45
     46        // Ambient sounds always fade in
     47        this->setVolume(0);
    4448    }
    4549
     
    5155    {
    5256        SUPER(AmbientSound, XMLPort, xmlelement, mode);
    53         XMLPortParamExtern(AmbientSound, BaseSound, this, "source", setSource, getSource, xmlelement, mode);
     57        XMLPortParamExtern(AmbientSound, BaseSound, this, "volume", setVolume, getVolume, xmlelement, mode);
    5458        XMLPortParamExtern(AmbientSound, BaseSound, this, "loop", setLoop, getLoop, xmlelement, mode);
    5559        XMLPortParamExtern(AmbientSound, BaseSound, this, "playOnLoad", setPlayOnLoad, getPlayOnLoad, xmlelement, mode);
     60        XMLPortParamExtern(AmbientSound, BaseSound, this, "source", setSource, getSource, xmlelement, mode);
    5661    }
    5762
     
    6469    void AmbientSound::play()
    6570    {
    66         COUT(3) << this->getSource() << ": Playing" << std::endl;
    67         if(GameMode::playsSound())
     71        if (GameMode::playsSound())
    6872        {
     73            COUT(3) << "Sound: " << this->getSource() << ": Playing" << std::endl;
    6974            SoundManager::getInstance().registerAmbientSound(this);
    70             this->BaseSound::play();
    7175        }
    7276    }
    7377
    74     void AmbientSound::replay()
     78    void AmbientSound::doPlay()
    7579    {
    76         this->BaseSound::play();
     80        BaseSound::play();
    7781    }
    7882
    7983    void AmbientSound::stop()
    8084    {
    81         if(GameMode::playsSound())
     85        if (GameMode::playsSound())
    8286        {
    8387            SoundManager::getInstance().unregisterAmbientSound(this);
     
    8791    void AmbientSound::doStop()
    8892    {
    89         this->BaseSound::stop();
     93        BaseSound::stop();
     94    }
     95
     96    void AmbientSound::pause()
     97    {
     98        if (GameMode::playsSound())
     99        {
     100            SoundManager::getInstance().pauseAmbientSound(this);
     101        }
     102    }
     103
     104    void AmbientSound::doPause()
     105    {
     106        BaseSound::pause();
    90107    }
    91108
    92109    void AmbientSound::setSource(const std::string& source)
    93110    {
    94         if(source.find('/') == std::string.npos && GameMode::playsSound())
     111        if (GameMode::playsSound())
    95112        {
    96113            std::string filePath = SoundManager::getInstance().getAmbientPath(source);
    97             if(!(filePath.empty()))
     114            if (!filePath.empty())
    98115            {
    99                 this->BaseSound::setSource(filePath);
     116                BaseSound::setSource(filePath);
    100117                return;
    101118            }
     119            COUT(3) << "Sound: " << source << ": Not a valid name! Ambient sound will not change." << std::endl;       
    102120        }
    103         COUT(3) << source << ": Not a valid name! Ambient sound will not change." << std::endl;       
    104121    }
    105122
    106123    void AmbientSound::changedActivity()
    107124    {
    108         COUT(3) << this->getSource() << ": ChangedActivity: " << this->isActive() << std::endl;
     125        COUT(3) << "Sound: " << this->getSource() << ": ChangedActivity: " << this->isActive() << std::endl;
    109126        this->BaseObject::changedActivity();
    110         if(this->isActive())
     127        if (this->isActive())
    111128        {
    112129            this->play();
Note: See TracChangeset for help on using the changeset viewer.