Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4961 in orxonox.OLD for orxonox/trunk/src/lib/sound


Ignore:
Timestamp:
Jul 28, 2005, 1:19:50 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: music now plays back, as one would expect, and the ReosurceManager handles ogg's.
Also the naming has changed a bit, and doxygen tags are complete in ogg_player.h/cc

Location:
orxonox/trunk/src/lib/sound
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/sound/ogg_player.cc

    r4750 r4961  
    2323#include "debug.h"
    2424
    25 void OggStream::open(string path)
     25
     26/**
     27 * initializes an Ogg-player from a file
     28 * @param fileName the file to load
     29 */
     30OggPlayer::OggPlayer(const char* fileName)
     31{
     32  this->setClassID(CL_SOUND_OGG_PLAYER, "OggPlayer");
     33  if (fileName != NULL)
     34  {
     35    this->open(fileName);
     36    this->setName(fileName);
     37  }
     38}
     39
     40/**
     41 * opens a file for playback
     42 * @param fileName the file to open
     43 */
     44void OggPlayer::open(const char* fileName)
    2645{
    2746    int result;
    2847
    29     if(!(oggFile = fopen(path.c_str(), "rb")))
     48    if(!(oggFile = fopen(fileName, "rb")))
    3049        PRINTF(2)("Could not open Ogg file.");
    3150
     
    5877}
    5978
    60 
    61 
    62 
    63 void OggStream::release()
     79/**
     80 * releases a stream
     81 */
     82void OggPlayer::release()
    6483{
    6584    alSourceStop(source);
     
    7392}
    7493
    75 
    76 
    77 
    78 void OggStream::display()
     94/**
     95 * displays some info about the ogg-file
     96 */
     97void OggPlayer::display()
    7998{
    8099    cout
     
    96115
    97116
    98 
    99 
    100 bool OggStream::playback()
     117/**
     118 * plays back the sound
     119 * @return true if running, false otherwise
     120 */
     121bool OggPlayer::playback()
    101122{
    102123    if(playing())
     
    115136}
    116137
    117 
    118 
    119 
    120 bool OggStream::playing()
     138/**
     139 *
     140 * @returns true if the file is playing
     141 */
     142bool OggPlayer::playing()
    121143{
    122144    ALenum state;
     
    127149}
    128150
    129 
    130 
    131 
    132 bool OggStream::update()
     151/**
     152 * updates the stream, this has to be done every few parts of a second, for sound-consistency
     153 * @returns true, if the Sound is playing flawlessly
     154 */
     155bool OggPlayer::update()
    133156{
    134157    int processed;
     
    153176}
    154177
    155 
    156 
    157 
    158 bool OggStream::stream(ALuint buffer)
     178/**
     179 * gets a new Stream from buffer
     180 * @param buffer the buffer to get the stream from
     181 * @return true, if everything worked as planed
     182 */
     183bool OggPlayer::stream(ALuint buffer)
    159184{
    160185    char pcm[BUFFER_SIZE];
     
    186211
    187212
    188 
    189 
    190 void OggStream::empty()
     213/**
     214 * empties the buffers
     215 */
     216void OggPlayer::empty()
    191217{
    192218    int queued;
     
    203229}
    204230
    205 
    206 
    207 
    208 void OggStream::check()
     231/**
     232 * checks for errors
     233 */
     234void OggPlayer::check()
    209235{
    210236        int error = alGetError();
     
    214240}
    215241
    216 
    217 
    218 const char* OggStream::errorString(int code)
     242/**
     243 * returns errors
     244 * @param code the error-code
     245 * @return the error as a String
     246 */
     247const char* OggPlayer::errorString(int code)
    219248{
    220249     switch(code)
  • orxonox/trunk/src/lib/sound/ogg_player.h

    r4836 r4961  
    11/*!
    22 * @file ogg_player.h
    3  *  Ogg-Player definition
     3 * Ogg-Player definition
    44 */
    55
     
    88#define _OGG_PLAYER_H
    99
    10 #include <string>
    1110#include <iostream>
    1211using namespace std;
     12
     13#include "base_object.h"
    1314
    1415#include <AL/al.h>
     
    2122
    2223
     24// the definition of a Ogg-Player
     25class OggPlayer : public BaseObject
     26  {
     27  public:
     28    OggPlayer(const char* fileName = NULL);
    2329
    24 class OggStream
    25 {
    26     public:
     30    void open(const char* fileName);
     31    void release();
     32    void display();
     33    bool playback();
     34    bool playing();
     35    bool update();
    2736
    28         void open(string path);
    29         void release();
    30         void display();
    31         bool playback();
    32         bool playing();
    33         bool update();
     37  protected:
    3438
    35     protected:
     39    bool stream(ALuint buffer);
     40    void empty();
     41    void check();
     42    const char* errorString(int code);
    3643
    37         bool stream(ALuint buffer);
    38         void empty();
    39         void check();
    40         const char* errorString(int code);
     44  private:
    4145
    42     private:
     46    FILE*               oggFile;              //!< general file-handler, to open the sound-file
     47    OggVorbis_File      oggStream;            //!< The stream this Ogg-player is playing back
     48    vorbis_info*        vorbisInfo;           //!< The information held in the opened ogg-file
     49    vorbis_comment*     vorbisComment;        //!< Comments about the ogg-file
    4350
    44         FILE*             oggFile;
    45         OggVorbis_File    oggStream;
    46         vorbis_info*      vorbisInfo;
    47         vorbis_comment*   vorbisComment;
    48 
    49         ALuint            buffers[2];
    50         ALuint            source;
    51         ALenum            format;
    52 };
     51    ALuint              buffers[2];           //!< buffers that handle sequentially buffering of the audio
     52    ALuint              source;               //!< The source we play back on
     53    ALenum              format;               //!< The format we play back
     54  };
    5355
    5456
  • orxonox/trunk/src/lib/sound/sound_engine.cc

    r4960 r4961  
    250250{
    251251  return new SoundSource(sourceNode, (SoundBuffer*)ResourceManager::getInstance()->load(fileName, WAV, RP_LEVEL));
    252 }
    253 
    254 
    255 /**
    256  *  sets The listener (normaly the Camera)
    257 */
    258 void SoundEngine::setListener(PNode* listener)
    259 {
    260   this->listener = listener;
    261252}
    262253
  • orxonox/trunk/src/lib/sound/sound_engine.h

    r4960 r4961  
    7777    SoundSource* createSource(const char* fileName, PNode* sourceNode = NULL);
    7878
    79     void setListener(PNode* listener);
     79    /** @param listener the listener in the scene */
     80    void setListener(PNode* listener) { this->listener = listener; };
    8081    void setDopplerValues(ALfloat dopplerFactor, ALfloat dopplerVelocity);
    8182
    8283
     84    void update();
     85
     86  // administrative
    8387    void addBuffer(SoundBuffer* buffer);
    8488    void removeBuffer(SoundBuffer* buffer);
    8589    void addSource(SoundSource* source);
    8690
    87     void update();
    88 
    89   // administrative
    9091    void flushUnusedBuffers();
    9192    void flushAllBuffers();
Note: See TracChangeset for help on using the changeset viewer.