Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 24, 2006, 12:58:19 PM (18 years ago)
Author:
bensch
Message:

Ported SoundBuffer to match the Data-Paradigm

File:
1 copied

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/sound/sound_buffer_data.cc

    r9801 r9803  
    1616#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_SOUND
    1717
    18 #include "sound_buffer.h"
     18#include "sound_buffer_data.h"
    1919
    2020#include "sound_engine.h"
     
    3535namespace OrxSound
    3636{
    37   ObjectListDefinition(SoundBuffer);
     37  ObjectListDefinition(SoundBufferData);
    3838  //////////////////
    3939  /* SOUND-BUFFER */
    4040  //////////////////
    4141  /**
    42    *  Creates a Soundbuffer out of an inputfile
     42   * @brief Creates a SoundbufferData out of an inputfile
    4343   * @param fileName The name of the File
    4444   */
    45   SoundBuffer::SoundBuffer(const std::string& fileName)
     45  SoundBufferData::SoundBufferData()
    4646  {
    47     this->registerObject(this, SoundBuffer::_objectList);
    48     this->setName(fileName);
     47    this->registerObject(this, SoundBufferData::_objectList);
     48    this->bufferID = 0;
    4949
    50     // generate a Buffer
    51     alGenBuffers(1, &this->bufferID);
    52     SoundEngine::checkError("Generate Buffer", __LINE__);
    53     if (!nocaseCmp(fileName.substr(fileName.size() - 3), "WAV"))
    54     {
    55       this->loadWAV(fileName);
    56     }
    57     else if (!nocaseCmp(fileName.substr(fileName.size() - 3), "OGG"))
    58       this->loadOGG(fileName);
     50    this->size = 0;
     51    this->loop = AL_FALSE;
     52
    5953
    6054  }
    6155
    62   SoundBuffer::~SoundBuffer()
     56  SoundBufferData::~SoundBufferData()
    6357  {
    6458    //  SoundEngine::getInstance()->removeBuffer(this);
     
    6862
    6963  /**
     64   * @brief check the File-extension and loads either Wav of Ogg
     65   * @param fileName the Name of the File to load.
     66   * @returns true on success (file found, and loaded.)
     67   */
     68  bool SoundBufferData::load(const std::string& fileName)
     69  {
     70    // generate a Buffer
     71    alGenBuffers(1, &this->bufferID);
     72    SoundEngine::checkError("Generate Buffer", __LINE__);
     73    if (!nocaseCmp(fileName.substr(fileName.size() - 3), "WAV"))
     74    {
     75      return this->loadWAV(fileName);
     76    }
     77    else if (!nocaseCmp(fileName.substr(fileName.size() - 3), "OGG"))
     78      return this->loadOGG(fileName);
     79    else
     80      return false;
     81  }
     82
     83  /**
    7084   * @brief loads a Waveform from the local fileSystem into this Source.
    7185   * @param fileName the Name of the File to Load.
    7286   * @returns true on success.
    7387   */
    74   bool SoundBuffer::loadWAV(const std::string& fileName)
     88  bool SoundBufferData::loadWAV(const std::string& fileName)
    7589  {
    7690    SDL_AudioSpec wavSpec;
     
    93107    }
    94108#endif
    95     alBufferData(this->bufferID, SoundBuffer::sdlAudioSpecToAlFormat(&wavSpec),
     109    alBufferData(this->bufferID, SoundBufferData::sdlAudioSpecToAlFormat(&wavSpec),
    96110                 wavBuffer, wavLength, wavSpec.freq);
    97111
     
    112126   * @returns true on success (file exists and is fully loaded), false otherwise.
    113127   */
    114   bool SoundBuffer::loadOGG(const std::string& fileName)
     128  bool SoundBufferData::loadOGG(const std::string& fileName)
    115129  {
    116130    void*     ovdata;
     
    156170   * @returns the AL_FORMAT
    157171   */
    158   ALenum SoundBuffer::sdlAudioSpecToAlFormat(const SDL_AudioSpec* audiospec)
     172  ALenum SoundBufferData::sdlAudioSpecToAlFormat(const SDL_AudioSpec* audiospec)
    159173  {
    160174    assert (audiospec != NULL);
Note: See TracChangeset for help on using the changeset viewer.