Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2932


Ignore:
Timestamp:
Apr 27, 2009, 3:30:34 PM (15 years ago)
Author:
erwin
Message:

Sound: implemented sample file loading via alut

Location:
code/branches/sound/src/sound
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/sound/src/sound/SoundBase.cc

    r2931 r2932  
    113113    }
    114114
     115    bool SoundBase::loadFile(std::string filename) {
     116        this->buffer_ = alutCreateBufferFromFile(filename.c_str());
     117        if(this->buffer_ == AL_NONE) {
     118            COUT(2) << "OpenAL ALUT: " << alutGetErrorString(alutGetError());
     119            return false;
     120        }
     121
     122        alGenSources(1, &this->source_);
     123        alSourcei(this->source_, AL_BUFFER, this->buffer_);
     124        if(alGetError() != AL_NO_ERROR) {
     125            COUT(2) << "OpenAL: Error loading sample file";
     126            return false;
     127        }
     128        return true;
     129    }
     130
    115131    ALint SoundBase::getSourceState() {
    116132        ALint state;
  • code/branches/sound/src/sound/SoundBase.h

    r2931 r2932  
    2929#define _SOUNDBASE_H__
    3030
    31 #include <al.h>
     31#include <AL/al.h>
     32#include <AL/alut.h>
    3233#include <string>
    3334
     
    5758        bool isStopped();
    5859
    59         virtual void loadFile(std::string filename) = 0;
     60        bool loadFile(std::string filename);
    6061
    6162    private:
  • code/branches/sound/src/sound/SoundManager.cc

    r2931 r2932  
    2727 */
    2828
    29 #include <OgreSceneNode.h>
     29#include <AL/alut.h>
    3030
    3131#include "orxonox/CameraManager.h"
     
    5757    SoundManager::SoundManager()
    5858    {
    59         // OpenAL device and context creation
    60         this->device_ = alcOpenDevice(NULL); // we operate on the default sound device
    61         if(this->device_)
    62             COUT(2) << "OpenAL: Could not create sound device, there will be no sound!" << std::endl;
    63 
    64         this->context_ = alcCreateContext(this->device_, NULL);
    65         alcMakeContextCurrent(this->context_);
    66         ALenum error = alcGetError(this->device_);
    67         if(error != ALC_NO_ERROR)
    68             COUT(2) << "OpenAL: Could not create sound context." << std::endl;
    69 
     59        if(!alutInit(NULL,NULL)) {
     60            COUT(2) << "OpenAL ALUT: " << alutGetErrorString(alutGetError());
     61        }
    7062    }
    7163
  • code/branches/sound/src/sound/SoundManager.h

    r2930 r2932  
    2828#define _SOUNDMANGER_H__
    2929
    30 #include <al.h>
    31 #include <alc.h>
     30#include <AL/al.h>
     31#include <AL/alc.h>
    3232
    3333#include <orxonox/objects/Tickable.h>
     
    5757        static SoundManager* singleton_;
    5858
    59         ALCcontext* context_;
    60         ALCdevice* device_;
    61 
    6259        std::list<SoundBase*> soundlist_;
    6360
Note: See TracChangeset for help on using the changeset viewer.