Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5924 in orxonox.OLD for branches/avi_play/src/lib/sound


Ignore:
Timestamp:
Dec 4, 2005, 11:37:49 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/avi_play: merged the Trunk back into the branche avi_play again

merged with command svn merge ../trunk/ avi_play/ -r5845:HEAD
no conflicts

Location:
branches/avi_play/src/lib/sound
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/avi_play/src/lib/sound/sound_engine.cc

    r5834 r5924  
    137137  if (this->sourceList != NULL)
    138138  {
    139     list<BaseObject*>::iterator source;
     139    list<BaseObject*>::const_iterator source;
    140140    for (source = this->sourceList->begin(); source != this->sourceList->end(); source++)
    141141    {
     
    182182  if (likely(this->sourceList != NULL))
    183183  {
    184     list<BaseObject*>::iterator sourceIT;
     184    list<BaseObject*>::const_iterator sourceIT;
    185185    SoundSource* source;
    186186    for (sourceIT = this->sourceList->begin(); sourceIT != this->sourceList->end(); sourceIT++)
     
    281281
    282282  // INITIALIZING THE DEVICE:
    283   ALchar deviceName[] =
     283#ifndef AL_VERSION_1_1
     284  ALubyte deviceName[] =
     285#else
     286  ALCchar deviceName[] =
     287#endif
    284288#ifdef __WIN32__
    285       "native";
     289      "Direct3D";
    286290#else
    287       "'( ( devices '( native arts null ) ) )";
     291      "'( ( devices '( native null ) ) )";
    288292#endif
    289293  //
     
    301305}
    302306
     307
     308/**
     309 * Allocates openAL sources
     310 * @param count how many sources to allocate
     311 * @returns true on success, false if at least one source could not be allocated
     312 */
     313bool SoundEngine::allocateSources(unsigned int count)
     314{
     315  ALuint* sourceList = new ALuint[count];
     316  ALenum result;
     317
     318  alGenSources(count, sourceList);
     319  if ((result = alGetError()) != AL_NO_ERROR)
     320  {
     321    SoundEngine::PrintALErrorString(result);
     322    return false;
     323  }
     324
     325  /// @TODO check syntax
     326
     327
     328  // Setting default values.
     329  for (int i = 0; i < count; i++)
     330  {
     331    alSourcef (sourceList[i], AL_PITCH,    1.0      );
     332    alSourcef (sourceList[i], AL_GAIN,     this->getEffectsVolume() );
     333    alSourcei (sourceList[i], AL_LOOPING,  AL_FALSE );
     334    this->ALSources.push(sourceList[i]);
     335  }
     336  return true;
     337}
     338
    303339/**
    304340 *  Transforms AL-errors into something readable
  • branches/avi_play/src/lib/sound/sound_engine.h

    r5819 r5924  
    1414
    1515#include <list>
     16#include <stack>
    1617
    1718#define SOUND_DOPPLER_FACTOR       0.001          //!< A factor for the audible doppler effect
     
    2122class PNode;
    2223class IniParser;
     24
    2325
    2426//! A class that handles audio via the openAudioLibrary
     
    5456    void flushAllBuffers();
    5557    void flushAllSources();
     58
     59    bool allocateSources(unsigned int count);
    5660    bool initAudio();
    5761
     
    6670
    6771  private:
    68     static SoundEngine*      singletonRef;             //!< Reference to this class
     72    static SoundEngine*            singletonRef;             //!< Reference to this class
    6973
    70     ALCdevice*               device;                   //!< the used audio-device.
    71     ALCcontext*              context;                  //!< the context, currently in use.
     74    ALCdevice*                     device;                   //!< the used audio-device.
     75    ALCcontext*                    context;                  //!< the context, currently in use.
    7276
    73     float                    musicVolume;              //!< the maximum volume of the music in % (0f,1f]
    74     float                    effectsVolume;            //!< the maximum volume of sound-effects in % (0f,1f]
    75     PNode*                   listener;                 //!< The listener of the Scene
     77    float                          musicVolume;              //!< the maximum volume of the music in % (0f,1f]
     78    float                          effectsVolume;            //!< the maximum volume of sound-effects in % (0f,1f]
     79    PNode*                         listener;                 //!< The listener of the Scene
    7680
    77     std::list<BaseObject*>*  bufferList;               //!< A list of buffers
    78     std::list<BaseObject*>*  sourceList;               //!< A list for all the sources in the scene.
     81    const std::list<BaseObject*>*  bufferList;               //!< A list of buffers
     82    const std::list<BaseObject*>*  sourceList;               //!< A list for all the sources in the scene.
    7983
    80 
     84    unsigned int                   maxSourceCount;           //!< How many Sources is the Maximum
     85    std::stack<ALuint>             ALSources;                //!< A list of real openAL-Sources, the engine allocates, and stores for reuse.
    8186};
    8287
  • branches/avi_play/src/lib/sound/sound_source.cc

    r5386 r5924  
    1818#include "sound_source.h"
    1919#include "sound_engine.h"
     20
    2021#include "alincl.h"
    2122#include "compiler.h"
  • branches/avi_play/src/lib/sound/sound_source.h

    r5386 r5924  
    3939
    4040  private:
     41    bool                   bPlay;                 //!< If the Source is Playing.
    4142    ALuint                 sourceID;              //!< The ID of the Source
    4243    const SoundBuffer*     buffer;                //!< The buffer to play in this source.
Note: See TracChangeset for help on using the changeset viewer.