Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4961 in orxonox.OLD


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
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/defs/class_id.h

    r4932 r4961  
    172172  CL_SOUND_BUFFER               =    0x00000a01,
    173173  CL_SOUND_SOURCE               =    0x00000a02,
     174  CL_SOUND_OGG_PLAYER           =    0x00000a11,
    174175
    175176
  • 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();
  • orxonox/trunk/src/story_entities/world.cc

    r4959 r4961  
    6666
    6767#include "sound_engine.h"
     68#include "ogg_player.h"
    6869
    6970#include "class_list.h"
     
    206207
    207208  LoadClassDescription::printAll();
     209
     210
     211  ResourceManager::getInstance()->unload(this->music);
    208212  ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL);
    209213}
     
    226230  //strcpy(this->worldName, name);
    227231  this->debugWorldNr = worldID;
     232
     233  this->music = NULL;
    228234}
    229235
     
    517523
    518524  ClassList::debug();
     525
     526  this->music = (OggPlayer*)ResourceManager::getInstance()->load("sound/00-luke_grey_-_hypermode.ogg", OGG, RP_LEVEL);
     527  music->playback();
    519528}
    520529
     
    954963
    955964  SoundEngine::getInstance()->update();
     965  music->update();
    956966}
    957967
  • orxonox/trunk/src/story_entities/world.h

    r4836 r4961  
    2424class PilotNode;
    2525
     26class OggPlayer;
    2627//! The game world Interface
    2728/**
     
    112113
    113114
     115  OggPlayer* music;
    114116  // IMPORTANT WORLD-ENTITIES
    115117  PNode* nullParent;                  //!< The zero-point, that everything has as its parent.
  • orxonox/trunk/src/util/resource_manager.cc

    r4836 r4961  
    3434#ifndef NO_AUDIO
    3535#include "sound_engine.h"
     36#include "ogg_player.h"
    3637#endif /* NO_AUDIO */
    3738
     
    228229
    229230/**
    230  *  loads resources
     231 * loads resources
    231232 * @param fileName: The fileName of the resource to load
    232233 * @param type: The Type of Resource to load (\see ResourceType)
     
    346347          if(isFile(fullName))
    347348            tmpResource->pointer = new SoundBuffer(fullName);
     349          break;
     350        case OGG:
     351          if (isFile(fullName))
     352            tmpResource->pointer = new OggPlayer(fullName);
    348353          break;
    349354#endif /* NO_AUDIO */
     
    400405
    401406/**
    402  *  unloads a Resource
     407 * unloads a Resource
    403408 * @param pointer: The pointer to free
    404409 * @param prio: the PriorityLevel to unload this resource
     
    419424
    420425/**
    421  *  unloads a Resource
     426 * unloads a Resource
    422427 * @param resource: The resource to unloade
    423428 * @param prio the PriorityLevel to unload this resource
     
    446451            case WAV:
    447452              delete (SoundBuffer*)resource->pointer;
     453              break;
     454            case OGG:
     455              delete (OggPlayer*)resource->pointer;
    448456              break;
    449457#endif /* NO_AUDIO */
     
    500508
    501509/**
    502  *  Searches for a Resource by some information
     510 * Searches for a Resource by some information
    503511 * @param fileName: The name to look for
    504512 * @param type the Type of resource to locate.
     
    587595
    588596/**
    589  *  Searches for a Resource by Pointer
     597 * Searches for a Resource by Pointer
    590598 * @param pointer the Pointer to search for
    591599 * @returns a Pointer to the Resource if found, NULL otherwise.
     
    610618
    611619/**
    612  *  Checks if it is a Directory
     620 * Checks if it is a Directory
    613621 * @param directoryName the Directory to check for
    614622 * @returns true if it is a directory/symlink false otherwise
     
    657665
    658666/**
    659  *  Checks if the file is either a Regular file or a Symlink
     667 * Checks if the file is either a Regular file or a Symlink
    660668 * @param fileName the File to check for
    661669 * @returns true if it is a regular file/symlink, false otherwise
     
    693701
    694702/**
    695  *  touches a File on the disk (thereby creating it)
     703 * touches a File on the disk (thereby creating it)
    696704 * @param fileName The file to touch
    697705*/
     
    713721
    714722/**
    715  *  deletes a File from disk
     723 * deletes a File from disk
    716724 * @param fileName the File to delete
    717725*/
     
    726734
    727735/**
    728   * @param name the Name of the file to check
    729   * @returns The name of the file, including the HomeDir
    730    IMPORTANT: this has to be deleted from the outside
    731 */
     736 * @param name the Name of the file to check
     737 * @returns The name of the file, including the HomeDir
     738 * IMPORTANT: this has to be deleted from the outside
     739 */
    732740char* ResourceManager::homeDirCheck(const char* name)
    733741{
     
    755763
    756764/**
    757   * @param fileName the Name of the File to check
    758   * @returns The full name of the file, including the DataDir, and NULL if the file does not exist
    759     IMPORTANT: this has to be deleted from the outside
     765 * @param fileName the Name of the File to check
     766 * @returns The full name of the file, including the DataDir, and NULL if the file does not exist
     767 *  IMPORTANT: this has to be deleted from the outside
    760768*/
    761769char* ResourceManager::getFullName(const char* fileName)
     
    778786
    779787/**
    780  *  outputs debug information about the ResourceManager
     788 * outputs debug information about the ResourceManager
    781789*/
    782790void ResourceManager::debug() const
     
    824832        case WAV:
    825833          PRINT(0)("SoundFile\n");
     834          break;
     835        case OGG:
     836          PRINT(0)("MusicFile\n");
     837          break;
    826838#endif
    827839        default:
Note: See TracChangeset for help on using the changeset viewer.