Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3114 in orxonox.OLD for orxonox/branches/sound


Ignore:
Timestamp:
Dec 6, 2004, 12:39:37 PM (20 years ago)
Author:
simon
Message:

/branches/sound: HUD reconfigured. Didn't commit earlier because something is amiss and it doesn't compile. Will make the thing materials functions to make bmp and tga.

Location:
orxonox/branches/sound
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/sound/hud/Makefile

    r3020 r3114  
    11CC = gcc -Wall -ansi
    2 SOURCE = hud.cc
    3 FLAGS = -lGL -lGLU `sdl-config --cflags --libs`
    4 BINARY = hud
     2SOURCE = hud_tga.cc
     3FLAGS = -lGL -lGLU
     4SDL = `sdl-config --cflags --libs`
     5INCLUDES = -I/usr/include/SDL -L/usr/lib
     6BINARY = hud_tga
    57
    68all:
    7         $(CC) $(SOURCE) -o $(BINARY) $(FLAGS)
     9        $(CC) $(SOURCE) -o $(BINARY) $(FLAGS) $(SDL) $(INCLUDES)
    810
    911clean:
  • orxonox/branches/sound/sound/sound_control.cc

    r3020 r3114  
    2121int sfx_channel2 = -1;
    2222int finished = 0;
    23 static SoundControl* instance = NULL;
    24 static SoundControl* sound = SoundControl::getInstance();
     23SoundControl* SoundControl::sound = SoundControl::getInstance();
     24SoundControl* SoundControl::instance = 0;
    2525int volume = SDL_MIX_MAXVOLUME;
    2626int track_number = 1;
    27 static Mix_Music* music = NULL;
     27Mix_Music* music = NULL;
    2828int audio_rate = 44100, audio_channels = MIX_DEFAULT_CHANNELS,
    2929audio_buffers = 16384, bits = 0;
     
    3434/**
    3535    \brief standard constructor
    36    
    37     This constructor builds a SoundControl Object, which waits for callers.
     36    This constructor builds a SoundControl Object and initialises it .
    3837    All sound output is handled by this singleton object.
    3938*/
    40 SoundControl::SoundControl () {
     39SoundControl::SoundControl() {
    4140  if(SDL_Init(SDL_INIT_AUDIO)<0) {
    4241    printf("SDL_Init: INIT_AUDIO error.\n");
     
    5150    \brief Default destructor
    5251*/
    53 SoundControl::~SoundControl () {
     52SoundControl::~SoundControl() {
    5453}
    5554
    5655/**
    57    \brief Returns a reference to the singleton
     56   \brief Returns a reference to the SoundControl singleton
    5857*/
    5958SoundControl* SoundControl::getInstance() {
    60   if (instance == NULL) {
     59  if (instance == 0) {
    6160    instance = new SoundControl;
    6261  }
     
    6564
    6665void SoundControl::deleteInstance() {
    67   delete instance;
    68   instance = NULL;
    6966}
    7067
     
    8279    \brief Sets the number of output Channels
    8380*/
    84 void SoundControl::setNumberOfChannels (int number_of_channels) {
     81void SoundControl::setNumberOfChannels(int number_of_channels) {
    8582  Mix_AllocateChannels(number_of_channels);
    8683}
    8784
    8885/**
    89     \brief May be called from any WorldEntity to play a .xm file
     86    \brief Static function to play a .xm file
    9087    \param filename: self-explanatory
    9188*/
    92 void SoundControl::playMod (char* fileName) {
     89void SoundControl::playMod(char* fileName) {
    9390  Mix_Chunk* chunk = NULL;
    9491  chunk = Mix_LoadWAV(fileName);
     
    9996
    10097/**
    101     \brief May be called from any WorldEntity to play a .wav file
     98    \brief Static function to play a .wav file
    10299    \param filename: self-explanatory
    103100*/
    104 void SoundControl::playWav (char* fileName) {
     101void SoundControl::playWav(char* fileName) {
    105102  Mix_Chunk* chunk = NULL;
    106103  chunk = Mix_LoadWAV(fileName);
     
    111108
    112109/**
    113     \brief May be called from any WorldEntity to play a .ogg file
     110    \brief Static function to play an .ogg file
    114111    \param filename: self-explanatory
    115112*/
    116 void SoundControl::playOgg (char* fileName) {
     113void SoundControl::playOgg(char* fileName) {
    117114  Mix_Music* music = NULL;
    118115  music = Mix_LoadMUS(fileName);
     
    126123    \brief Heightens the overall volume of output
    127124*/
    128 void SoundControl::volumeUp () {
     125void SoundControl::volumeUp() {
    129126  volume = (volume + 1) << 1;
    130127  if(volume > SDL_MIX_MAXVOLUME)
     
    137134    \brief Lowers the overall volume of output
    138135*/ 
    139 void SoundControl::volumeDown () {
     136void SoundControl::volumeDown() {
    140137  volume >>= 1;
    141138  Mix_VolumeMusic(volume);
     
    145142    \brief Rewinds music to the beginning
    146143*/ 
    147 void SoundControl::trackRewind () {
     144void SoundControl::trackRewind() {
    148145  Mix_RewindMusic();
    149146}
     
    152149    \brief Rewinds the music 5 seconds
    153150*/ 
    154 void SoundControl::forwardMusic () {
     151void SoundControl::forwardMusic() {
    155152  Mix_SetMusicPosition(+5);
    156153}
     
    166163    \brief Pauses music output
    167164*/
    168 void SoundControl::pauseMusic () {
     165void SoundControl::pauseMusic() {
    169166  Mix_PauseMusic();
    170167}
    171168
    172169/**
    173     \brief this function pauses music output
    174 */
    175 void SoundControl::resumeMusic () {
     170    \brief Pauses music output
     171*/
     172void SoundControl::resumeMusic() {
    176173  Mix_ResumeMusic();
    177174}
     175
     176/**
     177    \brief Fades in music
     178*/
     179void fadeInMusic(int time) {
     180
     181}
     182
     183/**
     184    \brief Fades out music
     185*/
     186void SoundControl::fadeOutMusic(int time) {
     187
     188}
    178189
    179190/**
     
    194205    if(key.type == SDL_KEYDOWN) {
    195206      if(sfx_channel1 < 0) {
    196         sfx_channel1 = sound->playWav("sound1.wav");
     207        sfx_channel1 = 1;
     208        sound->playWav("sound1.wav");
    197209      }
    198210    } else {
     
    204216    if(key.type == SDL_KEYDOWN) {
    205217      if(sfx_channel2 < 0) {
    206         sfx_channel2 = sound->playWav("sound2.wav");
     218        sfx_channel2 = 1;
     219        sound->playWav("sound2.wav");
    207220      }
    208221    } else {
     
    224237}
    225238
    226 int SoundControl::main(void) {
     239int SoundControl::main(int argc, char* argv[]) {
    227240  SDL_Surface* screen;
    228241  SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO);
  • orxonox/branches/sound/sound/sound_control.h

    r3020 r3114  
    1010  static SoundControl* getInstance();
    1111  static void deleteInstance();
     12 
    1213  void setNumberOfChannels(int number_of_channels);
    13   void playMod(char* filename);
    14   void playWav(char* filename);
    15   void playOgg(char* filename);
     14  static void playMod(char* filename);
     15  static void playWav(char* filename);
     16  static void playOgg(char* filename);
    1617  void volumeUp();
    1718  void volumeDown();
     
    2122  void pauseMusic();
    2223  void resumeMusic();
     24  void fadeInMusic(int time);
     25  void fadeOutMusic(int time);
    2326  static void musicDone();
     27 
    2428  void handleKey(SDL_KeyboardEvent key);
    25   int main (void);
    26   static SoundControl* instance;
     29  int main(int argc, char* argv[]);
     30 
     31  static SoundControl* sound;
    2732  int volume;
    2833  int track_number;
     
    3338  int sfx_channel2;
    3439  int finished;
    35 private:
    36   void initialise();
     40
     41 protected:
    3742  SoundControl();
    3843  ~SoundControl();
     44  void initialise();
     45
     46 private:
     47  static SoundControl* instance;
    3948};
    4049
Note: See TracChangeset for help on using the changeset viewer.