From 249d7138cb5c5e071c563a03f4955942cf997dde Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Sun, 26 Jun 2005 23:27:28 +0000 Subject: [PATCH] support for fading music SVN-Revision: 2646 --- src/audio/semantic.cache | 44 +++++++++++++++++---------------------- src/audio/sound_manager.cpp | 31 +++++++++++++++++++++------ src/audio/sound_manager.hpp | 3 ++- src/audio/stream_sound_source.cpp | 29 +++++++++++++++++++++++++- src/audio/stream_sound_source.hpp | 8 +++++-- src/game_session.cpp | 3 ++- 6 files changed, 82 insertions(+), 36 deletions(-) diff --git a/src/audio/semantic.cache b/src/audio/semantic.cache index d7bfa812a..6d0010e75 100644 --- a/src/audio/semantic.cache +++ b/src/audio/semantic.cache @@ -5,42 +5,36 @@ :tables (list (semanticdb-table "sound_manager.cpp" :file "sound_manager.cpp" - :pointmax 5898 + :pointmax 6589 :major-mode 'c++-mode - :tokens '(("sound_manager.h" include nil nil nil [1 27]) ("stdexcept" include t nil nil [29 49]) ("iostream" include t nil nil [50 69]) ("sstream" include t nil nil [70 88]) ("memory" include t nil nil [89 106]) ("sound_file.h" include nil nil nil [108 131]) ("sound_source.h" include nil nil nil [132 157]) ("stream_sound_source.h" include nil nil nil [158 190]) ("SoundManager" function ("SoundManager" type "class") nil ((parent . "SoundManager") (constructor . t)) nil nil [192 925]) ("SoundManager" function "void" nil ((parent . "SoundManager") (destructor . t)) nil nil [927 1366]) ("load_file_into_buffer" function ("ALuint" type "class") (("filename" variable ("std::string" type "class") nil ((const . t)) nil nil [1411 1439])) ((parent . "SoundManager")) nil nil [1368 2032]) ("create_sound_source" function ("SoundSource" type "class") (("filename" variable ("std::string" type "class") nil ((const . t)) nil nil [2081 2109])) ((parent . "SoundManager") (pointer . 1)) nil nil [2034 2556]) ("play" function ("void") (("soundname" variable ("std::string" type "class") nil ((const . t)) nil nil [2582 2611]) ("pos" variable ("Vector" type "class") nil ((const . t)) nil nil [2612 2630])) ((parent . "SoundManager")) nil nil [2558 3122]) ("enable_sound" function ("void") (("enable" variable ("bool" type "class") nil nil nil nil [3156 3168])) ((parent . "SoundManager")) nil nil [3124 3228]) ("enable_music" function ("void") (("enable" variable ("bool" type "class") nil nil nil nil [3262 3274])) ((parent . "SoundManager")) nil nil [3230 3363]) ("play_music" function ("void") (("filename" variable ("std::string" type "class") nil ((const . t)) nil nil [3395 3423])) ((parent . "SoundManager")) nil nil [3365 3746]) ("set_listener_position" function ("void") (("pos" variable ("Vector" type "class") nil nil nil nil [3789 3800])) ((parent . "SoundManager")) nil nil [3748 3850]) ("set_listener_velocity" function ("void") (("vel" variable ("Vector" type "class") nil nil nil nil [3893 3904])) ((parent . "SoundManager")) nil nil [3852 3954]) ("update" function ("void") nil ((parent . "SoundManager")) nil nil [3956 4410]) ("get_sample_format" function ("ALenum" type "class") (("file" variable ("SoundFile" type "class") nil ((pointer . 1)) nil nil [4451 4467])) ((parent . "SoundManager")) nil nil [4412 5081]) ("print_openal_version" function ("void") nil ((parent . "SoundManager")) nil nil [5083 5410]) ("check_alc_error" function ("void") (("message" variable "char" nil ((const . t) (pointer . 1)) nil nil [5447 5467])) ((parent . "SoundManager")) nil nil [5412 5669]) ("check_al_error" function ("void") (("message" variable "char" nil ((const . t) (pointer . 1)) nil nil [5705 5725])) ((parent . "SoundManager")) nil nil [5671 5896])) + :tokens '(("sound_manager.hpp" include nil nil nil [1 29]) ("stdexcept" include t nil nil [31 51]) ("iostream" include t nil nil [52 71]) ("sstream" include t nil nil [72 90]) ("memory" include t nil nil [91 108]) ("sound_file.hpp" include nil nil nil [110 135]) ("sound_source.hpp" include nil nil nil [136 163]) ("stream_sound_source.hpp" include nil nil nil [164 198]) ("SoundManager" function ("SoundManager" type "class") nil ((parent . "SoundManager") (constructor . t)) nil nil [200 959]) ("SoundManager" function "void" nil ((parent . "SoundManager") (destructor . t)) nil nil [961 1428]) ("load_file_into_buffer" function ("ALuint" type "class") (("filename" variable ("std::string" type "class") nil ((const . t)) nil nil [1473 1501])) ((parent . "SoundManager")) nil nil [1430 2094]) ("create_sound_source" function ("SoundSource" type "class") (("filename" variable ("std::string" type "class") nil ((const . t)) nil nil [2143 2171])) ((parent . "SoundManager") (pointer . 1)) nil nil [2096 2618]) ("play" function ("void") (("filename" variable ("std::string" type "class") nil ((const . t)) nil nil [2644 2672]) ("pos" variable ("Vector" type "class") nil ((const . t)) nil nil [2673 2691])) ((parent . "SoundManager")) nil nil [2620 3100]) ("enable_sound" function ("void") (("enable" variable ("bool" type "class") nil nil nil nil [3134 3146])) ((parent . "SoundManager")) nil nil [3102 3206]) ("enable_music" function ("void") (("enable" variable ("bool" type "class") nil nil nil nil [3240 3252])) ((parent . "SoundManager")) nil nil [3208 3460]) ("play_music" function ("void") (("filename" variable ("std::string" type "class") nil ((const . t)) nil nil [3492 3520]) ("fade" variable ("bool" type "class") nil nil nil nil [3521 3531])) ((parent . "SoundManager")) nil nil [3462 4173]) ("set_listener_position" function ("void") (("pos" variable ("Vector" type "class") nil nil nil nil [4216 4227])) ((parent . "SoundManager")) nil nil [4175 4277]) ("set_listener_velocity" function ("void") (("vel" variable ("Vector" type "class") nil nil nil nil [4320 4331])) ((parent . "SoundManager")) nil nil [4279 4381]) ("update" function ("void") nil ((parent . "SoundManager")) nil nil [4383 5101]) ("get_sample_format" function ("ALenum" type "class") (("file" variable ("SoundFile" type "class") nil ((pointer . 1)) nil nil [5142 5158])) ((parent . "SoundManager")) nil nil [5103 5772]) ("print_openal_version" function ("void") nil ((parent . "SoundManager")) nil nil [5774 6101]) ("check_alc_error" function ("void") (("message" variable "char" nil ((const . t) (pointer . 1)) nil nil [6138 6158])) ((parent . "SoundManager")) nil nil [6103 6360]) ("check_al_error" function ("void") (("message" variable "char" nil ((const . t) (pointer . 1)) nil nil [6396 6416])) ((parent . "SoundManager")) nil nil [6362 6587])) :unmatched-syntax 'nil ) - (semanticdb-table "stream_sound_source.h" - :file "stream_sound_source.h" - :pointmax 682 - :major-mode 'c++-mode - :tokens '(("__STREAM_SOUND_SOURCE_H__" variable nil nil ((const . t)) nil nil [35 71]) ("sound_source.h" include nil nil nil [89 114]) ("SoundFile" type "class" nil nil nil nil nil [116 132]) ("StreamSoundSource" type "class" (("public" label ((reparse-symbol . classsubparts)) [181 188]) ("StreamSoundSource" function ("StreamSoundSource" type "class") (("file" variable ("SoundFile" type "class") nil ((pointer . 1)) nil nil [209 225])) ((constructor . t) (prototype . t)) nil ((reparse-symbol . classsubparts)) [191 226]) ("StreamSoundSource" function "void" nil ((typemodifiers "virtual") (destructor . t) (prototype . t)) nil ((reparse-symbol . classsubparts)) [229 258]) ("update" function ("void") nil ((prototype . t)) nil ((reparse-symbol . classsubparts)) [262 276]) ("private" label ((reparse-symbol . classsubparts)) [280 288]) ("STREAMFRAGMENTS" variable ("size_t" type "class") "5" ((const . t) (typemodifiers "static")) nil nil [344 384]) ("STREAMFRAGMENTS" variable "int" nil nil nil nil [452 468]) ("fillBufferAndQueue" function ("void") (("buffer" variable ("ALuint" type "class") nil nil nil nil [496 510])) ((prototype . t)) nil ((reparse-symbol . classsubparts)) [472 511]) ("file" variable ("SoundFile" type "class") nil ((pointer . 1)) nil nil [514 530]) ("buffers" variable ("ALuint" type "class") nil ((dereference . 1)) nil nil [533 565]) ("format" variable ("ALenum" type "class") nil nil nil nil [568 582]) ("FadeState" type "enum" (("NoFading" variable "int" nil ((const . t)) nil ((reparse-symbol . enumsubparts)) [603 612]) ("FadingOn" variable "int" nil ((const . t)) nil ((reparse-symbol . enumsubparts)) [613 622]) ("FadingOff" variable "int" nil ((const . t)) nil ((reparse-symbol . enumsubparts)) [623 634])) nil nil nil ((reparse-symbol . classsubparts)) [586 635]) ("fade_state" variable ("FadeState" type "class") nil nil nil nil [638 659])) (("SoundSource")) nil nil nil [134 672])) - ) - (semanticdb-table "sound_manager.h" - :file "sound_manager.h" - :pointmax 1796 - :major-mode 'c++-mode - :tokens '(("__SOUND_MANAGER_H__" variable nil nil ((const . t)) nil nil [29 59]) ("math/vector.h" include nil nil nil [58 82]) ("string" include t nil nil [83 100]) ("vector" include t nil nil [101 118]) ("map" include t nil nil [119 133]) ("AL/alc.h" include t nil nil [135 154]) ("AL/al.h" include t nil nil [155 173]) ("SoundHandle" type "typedef" nil ("void") ((pointer . 1) (typedef "void")) nil nil [175 201]) ("SoundFile" type "class" nil nil nil nil nil [203 219]) ("SoundSource" type "class" nil nil nil nil nil [220 238]) ("StreamSoundSource" type "class" nil nil nil nil nil [239 263]) ("SoundManager" type "class" (("public" label ((reparse-symbol . classsubparts)) [286 293]) ("SoundManager" function ("SoundManager" type "class") nil ((constructor . t) (prototype . t)) nil ((reparse-symbol . classsubparts)) [296 311]) ("SoundManager" function "void" nil ((typemodifiers "virtual") (destructor . t) (prototype . t)) nil ((reparse-symbol . classsubparts)) [314 338]) ("enable_sound" function ("void") (("sound_enabled" variable ("bool" type "class") nil nil nil nil [360 379])) ((prototype . t)) nil ((reparse-symbol . classsubparts)) [342 380]) ("create_sound_source" function ("SoundSource" type "class") (("filename" variable ("std::string" type "class") nil ((const . t)) nil nil [692 720])) ((pointer . 1) (prototype . t)) nil ((reparse-symbol . classsubparts)) [659 721]) ("play" function ("void") (("name" variable ("std::string" type "class") nil ((const . t)) nil nil [890 914]) ("pos" variable ("Vector" type "class") "Vector(-1, -1)" ((const . t)) nil nil [915 949])) ((prototype . t)) nil ((reparse-symbol . classsubparts)) [880 951]) ("set_listener_position" function ("void") (("position" variable ("Vector" type "class") nil nil nil nil [982 998])) ((prototype . t)) nil ((reparse-symbol . classsubparts)) [955 999]) ("set_listener_velocity" function ("void") (("velocity" variable ("Vector" type "class") nil nil nil nil [1029 1045])) ((prototype . t)) nil ((reparse-symbol . classsubparts)) [1002 1046]) ("enable_music" function ("void") (("music_enabled" variable ("bool" type "class") nil nil nil nil [1068 1087])) ((prototype . t)) nil ((reparse-symbol . classsubparts)) [1050 1088]) ("play_music" function ("void") (("filename" variable ("std::string" type "class") nil ((const . t)) nil nil [1107 1135])) ((prototype . t)) nil ((reparse-symbol . classsubparts)) [1091 1136]) ("update" function ("void") nil ((prototype . t)) nil ((reparse-symbol . classsubparts)) [1140 1154]) ("private" label ((reparse-symbol . classsubparts)) [1156 1164]) ("SoundSource" type "class" nil nil nil nil ((reparse-symbol . classsubparts)) [1174 1192]) ("StreamSoundSource" type "class" nil nil nil nil ((reparse-symbol . classsubparts)) [1202 1226]) ("load_file_into_buffer" function ("ALuint" type "class") (("filename" variable ("std::string" type "class") nil ((const . t)) nil nil [1266 1294])) ((typemodifiers "static") (prototype . t)) nil ((reparse-symbol . classsubparts)) [1230 1295]) ("get_sample_format" function ("ALenum" type "class") (("file" variable ("SoundFile" type "class") nil ((pointer . 1)) nil nil [1330 1346])) ((typemodifiers "static") (prototype . t)) nil ((reparse-symbol . classsubparts)) [1298 1347]) ("print_openal_version" function ("void") nil ((prototype . t)) nil ((reparse-symbol . classsubparts)) [1351 1379]) ("check_alc_error" function ("void") (("message" variable "char" nil ((const . t) (pointer . 1)) nil nil [1403 1423])) ((prototype . t)) nil ((reparse-symbol . classsubparts)) [1382 1424]) ("check_al_error" function ("void") (("message" variable "char" nil ((const . t) (pointer . 1)) nil nil [1454 1474])) ((typemodifiers "static") (prototype . t)) nil ((reparse-symbol . classsubparts)) [1427 1475]) ("device" variable ("ALCdevice" type "class") nil ((pointer . 1)) nil nil [1479 1497]) ("context" variable ("ALCcontext" type "class") nil ((pointer . 1)) nil nil [1500 1520]) ("sound_enabled" variable ("bool" type "class") nil nil nil nil [1523 1542]) ("SoundBuffers" type "typedef" nil ("std::map") ((typedef "std::map" type "class")) nil nil [1546 1597]) ("buffers" variable ("SoundBuffers" type "class") nil nil nil nil [1600 1621]) ("SoundSources" type "typedef" nil ("std::vector") ((typedef "std::vector" type "class")) nil nil [1624 1671]) ("sources" variable ("SoundSources" type "class") nil nil nil nil [1674 1695]) ("music_source" variable ("StreamSoundSource" type "class") nil ((pointer . 1)) nil nil [1699 1731]) ("music_enabled" variable ("bool" type "class") nil nil nil nil [1735 1754]) ("current_music" variable ("std::string" type "class") nil nil nil nil [1757 1783])) nil nil nil nil [265 1786])) - :unmatched-syntax '((FRIEND 1195 . 1201) (FRIEND 1167 . 1173)) - ) - (semanticdb-table "stream_sound_source.cpp" + (semanticdb-table "stream_sound_source.cpp" :file "stream_sound_source.cpp" - :pointmax 1971 - :major-mode 'c++-mode - :tokens '(("config.h" include t nil nil [1 20]) ("stream_sound_source.h" include nil nil nil [22 54]) ("sound_manager.h" include nil nil nil [55 81]) ("sound_file.h" include nil nil nil [82 105]) ("StreamSoundSource" function ("StreamSoundSource" type "class") (("file" variable ("SoundFile" type "class") nil ((pointer . 1)) nil nil [144 160])) ((parent . "StreamSoundSource") (constructor . t)) nil nil [107 516]) ("StreamSoundSource" function "void" nil ((parent . "StreamSoundSource") (destructor . t)) nil nil [518 673]) ("update" function ("void") nil ((parent . "StreamSoundSource")) nil nil [675 1326]) ("fillBufferAndQueue" function ("void") (("buffer" variable ("ALuint" type "class") nil nil nil nil [1371 1385])) ((parent . "StreamSoundSource")) nil nil [1328 1970])) - ) - (semanticdb-table "sound_source.h" - :file "sound_source.h" - :pointmax 474 + :pointmax 2665 :major-mode 'c++-mode - :tokens '(("__SOUND_SOURCE_H__" variable nil nil ((const . t)) nil nil [28 57]) ("AL/al.h" include t nil nil [56 74]) ("math/vector.h" include nil nil nil [75 99]) ("SoundSource" type "class" (("public" label ((reparse-symbol . classsubparts)) [121 128]) ("SoundSource" function ("SoundSource" type "class") nil ((constructor . t) (prototype . t)) nil ((reparse-symbol . classsubparts)) [131 145]) ("SoundSource" function "void" nil ((typemodifiers "virtual") (destructor . t) (prototype . t)) nil ((reparse-symbol . classsubparts)) [148 171]) ("play" function ("void") nil ((prototype . t)) nil ((reparse-symbol . classsubparts)) [175 187]) ("stop" function ("void") nil ((prototype . t)) nil ((reparse-symbol . classsubparts)) [190 202]) ("playing" function ("bool" type "class") nil ((prototype . t)) nil ((reparse-symbol . classsubparts)) [205 220]) ("set_looping" function ("void") (("looping" variable ("bool" type "class") nil nil nil nil [241 254])) ((prototype . t)) nil ((reparse-symbol . classsubparts)) [224 255]) ("set_volume" function ("void") (("volume" variable "float" nil nil nil nil [310 323])) ((prototype . t)) nil ((reparse-symbol . classsubparts)) [294 324]) ("set_position" function ("void") (("position" variable ("Vector" type "class") nil nil nil nil [345 361])) ((prototype . t)) nil ((reparse-symbol . classsubparts)) [327 362]) ("set_velocity" function ("void") (("position" variable ("Vector" type "class") nil nil nil nil [383 399])) ((prototype . t)) nil ((reparse-symbol . classsubparts)) [365 400]) ("protected" label ((reparse-symbol . classsubparts)) [402 412]) ("SoundManager" type "class" nil nil nil nil ((reparse-symbol . classsubparts)) [422 441]) ("source" variable ("ALuint" type "class") nil nil nil nil [447 461])) nil nil nil nil [101 464])) + :tokens '(("config.h" include t nil nil [1 20]) ("SDL.h" include t nil nil [22 38]) ("stream_sound_source.hpp" include nil nil nil [39 73]) ("sound_manager.hpp" include nil nil nil [74 102]) ("sound_file.hpp" include nil nil nil [103 128]) ("StreamSoundSource" function ("StreamSoundSource" type "class") (("file" variable ("SoundFile" type "class") nil ((pointer . 1)) nil nil [167 183])) ((parent . "StreamSoundSource") (constructor . t)) nil nil [130 539]) ("StreamSoundSource" function "void" nil ((parent . "StreamSoundSource") (destructor . t)) nil nil [541 696]) ("update" function ("void") nil ((parent . "StreamSoundSource")) nil nil [698 1845]) ("setFading" function ("void") (("state" variable ("FadeState" type "class") nil nil nil nil [1881 1897]) ("fade_time" variable "float" nil nil nil nil [1898 1914])) ((parent . "StreamSoundSource")) nil nil [1847 2020]) ("fillBufferAndQueue" function ("void") (("buffer" variable ("ALuint" type "class") nil nil nil nil [2065 2079])) ((parent . "StreamSoundSource")) nil nil [2022 2664])) ) - (semanticdb-table "sound_file.cpp" + (semanticdb-table "sound_file.cpp" :file "sound_file.cpp" :pointmax 7443 :major-mode 'c++-mode :tokens '(("config.h" include t nil nil [53 72]) ("sound_file.h" include nil nil nil [74 97]) ("stdio.h" include t nil nil [99 117]) ("stdint.h" include t nil nil [118 137]) ("algorithm" include t nil nil [138 158]) ("stdexcept" include t nil nil [159 179]) ("sstream" include t nil nil [180 198]) ("physfs.h" include t nil nil [199 218]) ("vorbis/codec.h" include t nil nil [219 244]) ("vorbis/vorbisfile.h" include t nil nil [245 275]) ("WavSoundFile" type "class" (("public" label ((reparse-symbol . classsubparts)) [317 324]) ("WavSoundFile" function ("WavSoundFile" type "class") (("file" variable ("PHYSFS_file" type "class") nil ((pointer . 1)) nil nil [340 358])) ((constructor . t) (prototype . t)) nil ((reparse-symbol . classsubparts)) [327 359]) ("WavSoundFile" function "void" nil ((destructor . t) (prototype . t)) nil ((reparse-symbol . classsubparts)) [362 378]) ("read" function ("size_t" type "class") (("buffer" variable "void" nil ((pointer . 1)) nil nil [394 407]) ("buffer_size" variable ("size_t" type "class") nil nil nil nil [408 427])) ((prototype . t)) nil ((reparse-symbol . classsubparts)) [382 428]) ("reset" function ("void") nil ((prototype . t)) nil ((reparse-symbol . classsubparts)) [431 444]) ("private" label ((reparse-symbol . classsubparts)) [446 454]) ("file" variable ("PHYSFS_file" type "class") nil ((pointer . 1)) nil nil [457 475]) ("datastart" variable ("PHYSFS_sint64" type "class") nil nil nil nil [481 505])) (("SoundFile")) nil nil nil [277 508]) ("read32LE" function ("uint32_t" type "class") (("file" variable ("PHYSFS_file" type "class") nil ((pointer . 1)) nil nil [542 560])) ((typemodifiers "static" "inline")) nil nil [510 692]) ("read16LE" function ("uint16_t" type "class") (("file" variable ("PHYSFS_file" type "class") nil ((pointer . 1)) nil nil [726 744])) ((typemodifiers "static" "inline")) nil nil [694 876]) ("WavSoundFile" function ("WavSoundFile" type "class") (("file" variable ("PHYSFS_file" type "class") nil ((pointer . 1)) nil nil [905 923])) ((parent . "WavSoundFile") (constructor . t)) nil nil [878 3302]) ("WavSoundFile" function "void" nil ((parent . "WavSoundFile") (destructor . t)) nil nil [3304 3359]) ("reset" function ("void") nil ((parent . "WavSoundFile")) nil nil [3361 3492]) ("read" function ("size_t" type "class") (("buffer" variable "void" nil ((pointer . 1)) nil nil [3520 3533]) ("buffer_size" variable ("size_t" type "class") nil nil nil nil [3534 3553])) ((parent . "WavSoundFile")) nil nil [3494 3884]) ("OggSoundFile" type "class" (("public" label ((reparse-symbol . classsubparts)) [4005 4012]) ("OggSoundFile" function ("OggSoundFile" type "class") (("file" variable ("PHYSFS_file" type "class") nil ((pointer . 1)) nil nil [4028 4046])) ((constructor . t) (prototype . t)) nil ((reparse-symbol . classsubparts)) [4015 4047]) ("OggSoundFile" function "void" nil ((destructor . t) (prototype . t)) nil ((reparse-symbol . classsubparts)) [4050 4066]) ("read" function ("size_t" type "class") (("buffer" variable "void" nil ((pointer . 1)) nil nil [4082 4095]) ("buffer_size" variable ("size_t" type "class") nil nil nil nil [4096 4115])) ((prototype . t)) nil ((reparse-symbol . classsubparts)) [4070 4116]) ("private" label ((reparse-symbol . classsubparts)) [4118 4126]) ("cb_read" function ("size_t" type "class") (("ptr" variable "void" nil ((pointer . 1)) nil nil [4151 4161]) ("size" variable ("size_t" type "class") nil nil nil nil [4162 4174]) ("nmemb" variable ("size_t" type "class") nil nil nil nil [4175 4188]) ("source" variable "void" nil ((pointer . 1)) nil nil [4189 4202])) ((typemodifiers "static") (prototype . t)) nil ((reparse-symbol . classsubparts)) [4129 4203]) ("cb_seek" function ("int") (("source" variable "void" nil ((pointer . 1)) nil nil [4225 4238]) ("offset" variable ("ogg_int64_t" type "class") nil nil nil nil [4239 4258]) ("whence" variable "int" nil nil nil nil [4259 4270])) ((typemodifiers "static") (prototype . t)) nil ((reparse-symbol . classsubparts)) [4206 4271]) ("cb_close" function ("int") (("source" variable "void" nil ((pointer . 1)) nil nil [4294 4307])) ((typemodifiers "static") (prototype . t)) nil ((reparse-symbol . classsubparts)) [4274 4308]) ("cb_tell" function ("long") (("source" variable "void" nil ((pointer . 1)) nil nil [4331 4344])) ((typemodifiers "static") (prototype . t)) nil ((reparse-symbol . classsubparts)) [4311 4345]) ("file" variable ("PHYSFS_file" type "class") nil ((pointer . 1)) nil nil [4351 4369]) ("vorbis_file" variable ("OggVorbis_File" type "class") nil nil nil nil [4372 4399])) (("SoundFile")) nil nil nil [3965 4402]) ("OggSoundFile" function ("OggSoundFile" type "class") (("file" variable ("PHYSFS_file" type "class") nil ((pointer . 1)) nil nil [4431 4449])) ((parent . "OggSoundFile") (constructor . t)) nil nil [4404 4786]) ("OggSoundFile" function "void" nil ((parent . "OggSoundFile") (destructor . t)) nil nil [4788 4847]) ("read" function ("size_t" type "class") (("_buffer" variable "void" nil ((pointer . 1)) nil nil [4875 4889]) ("buffer_size" variable ("size_t" type "class") nil nil nil nil [4890 4909])) ((parent . "OggSoundFile")) nil nil [4849 5318]) ("cb_read" function ("size_t" type "class") (("ptr" variable "void" nil ((pointer . 1)) nil nil [5349 5359]) ("size" variable ("size_t" type "class") nil nil nil nil [5360 5372]) ("nmemb" variable ("size_t" type "class") nil nil nil nil [5373 5386]) ("source" variable "void" nil ((pointer . 1)) nil nil [5387 5400])) ((parent . "OggSoundFile")) nil nil [5320 5666]) ("cb_seek" function ("int") (("source" variable "void" nil ((pointer . 1)) nil nil [5694 5707]) ("offset" variable ("ogg_int64_t" type "class") nil nil nil nil [5708 5727]) ("whence" variable "int" nil nil nil nil [5728 5739])) ((parent . "OggSoundFile")) nil nil [5668 6270]) ("cb_close" function ("int") (("source" variable "void" nil ((pointer . 1)) nil nil [6301 6314])) ((parent . "OggSoundFile")) nil nil [6274 6415]) ("cb_tell" function ("long") (("source" variable "void" nil ((pointer . 1)) nil nil [6444 6457])) ((parent . "OggSoundFile")) nil nil [6417 6572]) ("fstream" include t nil nil [6653 6671]) ("load_sound_file" function ("SoundFile" type "class") (("filename" variable ("std::string" type "class") nil ((const . t)) nil nil [6699 6727])) ((pointer . 1)) nil nil [6672 7441])) :unmatched-syntax 'nil ) + (semanticdb-table "stream_sound_source.hpp" + :file "stream_sound_source.hpp" + :pointmax 789 + :major-mode 'c++-mode + :tokens '(("__STREAM_SOUND_SOURCE_H__" variable nil nil ((const . t)) nil nil [35 71]) ("stdio.h" include t nil nil [70 88]) ("SDL.h" include t nil nil [89 105]) ("sound_source.hpp" include nil nil nil [106 133]) ("SoundFile" type "class" nil nil nil nil nil [135 151]) ("StreamSoundSource" type "class" (("public" label ((reparse-symbol . classsubparts)) [200 207]) ("StreamSoundSource" function ("StreamSoundSource" type "class") (("file" variable ("SoundFile" type "class") nil ((pointer . 1)) nil nil [228 244])) ((constructor . t) (prototype . t)) nil ((reparse-symbol . classsubparts)) [210 245]) ("StreamSoundSource" function "void" nil ((typemodifiers "virtual") (destructor . t) (prototype . t)) nil ((reparse-symbol . classsubparts)) [248 277]) ("FadeState" type "enum" (("NoFading" variable "int" nil ((const . t)) nil ((reparse-symbol . enumsubparts)) [298 307]) ("FadingOn" variable "int" nil ((const . t)) nil ((reparse-symbol . enumsubparts)) [308 317]) ("FadingOff" variable "int" nil ((const . t)) nil ((reparse-symbol . enumsubparts)) [318 329])) nil nil nil ((reparse-symbol . classsubparts)) [281 330]) ("setFading" function ("void") (("state" variable ("FadeState" type "class") nil nil nil nil [349 365]) ("fadetime" variable "float" nil nil nil nil [366 381])) ((prototype . t)) nil ((reparse-symbol . classsubparts)) [334 382]) ("update" function ("void") nil ((prototype . t)) nil ((reparse-symbol . classsubparts)) [385 399]) ("private" label ((reparse-symbol . classsubparts)) [403 411]) ("STREAMFRAGMENTS" variable ("size_t" type "class") "5" ((const . t) (typemodifiers "static")) nil nil [467 507]) ("STREAMFRAGMENTS" variable "int" nil nil nil nil [575 591]) ("fillBufferAndQueue" function ("void") (("buffer" variable ("ALuint" type "class") nil nil nil nil [619 633])) ((prototype . t)) nil ((reparse-symbol . classsubparts)) [595 634]) ("file" variable ("SoundFile" type "class") nil ((pointer . 1)) nil nil [637 653]) ("buffers" variable ("ALuint" type "class") nil ((dereference . 1)) nil nil [656 688]) ("format" variable ("ALenum" type "class") nil nil nil nil [691 705]) ("fade_state" variable ("FadeState" type "class") nil nil nil nil [709 730]) ("fade_start_ticks" variable ("Uint32" type "class") nil nil nil nil [733 757]) ("fade_time" variable "float" nil nil nil nil [760 776])) (("SoundSource")) nil nil nil [153 779])) + :unmatched-syntax '((punctuation 573 . 574) (symbol 556 . 572) (punctuation 554 . 555) (symbol 530 . 548) (symbol 523 . 529) (CONST 517 . 522) (STATIC 510 . 516) (punctuation 463 . 464) (number 460 . 463) (punctuation 458 . 459) (number 453 . 457) (punctuation 451 . 452) (symbol 434 . 450) (symbol 427 . 433) (CONST 421 . 426) (STATIC 414 . 420)) + ) + (semanticdb-table "sound_source.hpp" + :file "sound_source.hpp" + :pointmax 531 + :major-mode 'c++-mode + :tokens '(("__SOUND_SOURCE_H__" variable nil nil ((const . t)) nil nil [28 57]) ("AL/al.h" include t nil nil [56 74]) ("math/vector.hpp" include nil nil nil [75 101]) ("SoundSource" type "class" (("public" label ((reparse-symbol . classsubparts)) [123 130]) ("SoundSource" function ("SoundSource" type "class") nil ((constructor . t) (prototype . t)) nil ((reparse-symbol . classsubparts)) [133 147]) ("SoundSource" function "void" nil ((typemodifiers "virtual") (destructor . t) (prototype . t)) nil ((reparse-symbol . classsubparts)) [150 173]) ("play" function ("void") nil ((prototype . t)) nil ((reparse-symbol . classsubparts)) [177 189]) ("stop" function ("void") nil ((prototype . t)) nil ((reparse-symbol . classsubparts)) [192 204]) ("playing" function ("bool" type "class") nil ((prototype . t)) nil ((reparse-symbol . classsubparts)) [207 222]) ("set_looping" function ("void") (("looping" variable ("bool" type "class") nil nil nil nil [243 256])) ((prototype . t)) nil ((reparse-symbol . classsubparts)) [226 257]) ("set_gain" function ("void") (("gain" variable "float" nil nil nil nil [322 333])) ((prototype . t)) nil ((reparse-symbol . classsubparts)) [308 334]) ("set_position" function ("void") (("position" variable ("Vector" type "class") nil nil nil nil [355 371])) ((prototype . t)) nil ((reparse-symbol . classsubparts)) [337 372]) ("set_velocity" function ("void") (("position" variable ("Vector" type "class") nil nil nil nil [393 409])) ((prototype . t)) nil ((reparse-symbol . classsubparts)) [375 410]) ("set_reference_distance" function ("void") (("distance" variable "float" nil nil nil nil [441 456])) ((prototype . t)) nil ((reparse-symbol . classsubparts)) [413 457]) ("protected" label ((reparse-symbol . classsubparts)) [459 469]) ("SoundManager" type "class" nil nil nil nil ((reparse-symbol . classsubparts)) [479 498]) ("source" variable ("ALuint" type "class") nil nil nil nil [504 518])) nil nil nil nil [103 521])) + ) ) ) diff --git a/src/audio/sound_manager.cpp b/src/audio/sound_manager.cpp index d5ade6ffd..933ddcffb 100644 --- a/src/audio/sound_manager.cpp +++ b/src/audio/sound_manager.cpp @@ -10,7 +10,8 @@ #include "stream_sound_source.hpp" SoundManager::SoundManager() - : device(0), context(0), sound_enabled(false), music_source(0) + : device(0), context(0), sound_enabled(false), music_source(0), + next_music_source(0) { try { device = alcOpenDevice(0); @@ -38,6 +39,7 @@ SoundManager::SoundManager() SoundManager::~SoundManager() { delete music_source; + delete next_music_source; for(SoundSources::iterator i = sources.begin(); i != sources.end(); ++i) { delete *i; @@ -149,7 +151,7 @@ SoundManager::enable_music(bool enable) } void -SoundManager::play_music(const std::string& filename) +SoundManager::play_music(const std::string& filename, bool fade) { if(filename == current_music) return; @@ -162,10 +164,18 @@ SoundManager::play_music(const std::string& filename) = new StreamSoundSource(load_sound_file(filename)); alSourcef(newmusic->source, AL_ROLLOFF_FACTOR, 0); - newmusic->play(); - delete music_source; - music_source = newmusic; + if(fade) { + if(music_source) + music_source->setFading(StreamSoundSource::FadingOff, .25f); + delete next_music_source; + next_music_source = newmusic; + } else { + delete music_source; + music_source = newmusic; + music_source->play(); + next_music_source = 0; + } } catch(std::exception& e) { std::cerr << "Couldn't play music file '" << filename << "': " << e.what() << "\n"; @@ -198,8 +208,17 @@ SoundManager::update() } } // check streaming sounds - if(music_source) + if(music_source) { music_source->update(); + } + + if(next_music_source && !music_source || !music_source->playing()) { + delete music_source; + music_source = next_music_source; + //music_source->setFading(StreamSoundSource::FadingOn, 1.0f); + music_source->play(); + next_music_source = 0; + } alcProcessContext(context); check_alc_error("Error while processing audio context: "); diff --git a/src/audio/sound_manager.hpp b/src/audio/sound_manager.hpp index f385f49c7..3b3959e26 100644 --- a/src/audio/sound_manager.hpp +++ b/src/audio/sound_manager.hpp @@ -39,7 +39,7 @@ public: void set_listener_velocity(Vector velocity); void enable_music(bool music_enabled); - void play_music(const std::string& filename); + void play_music(const std::string& filename, bool fade = true); void update(); @@ -64,6 +64,7 @@ private: SoundSources sources; StreamSoundSource* music_source; + StreamSoundSource* next_music_source; bool music_enabled; std::string current_music; diff --git a/src/audio/stream_sound_source.cpp b/src/audio/stream_sound_source.cpp index 88e67c015..4074a7021 100644 --- a/src/audio/stream_sound_source.cpp +++ b/src/audio/stream_sound_source.cpp @@ -1,5 +1,6 @@ #include +#include #include "stream_sound_source.hpp" #include "sound_manager.hpp" #include "sound_file.hpp" @@ -50,7 +51,33 @@ StreamSoundSource::update() SoundManager::check_al_error("Couldn't restart audio source: "); } - // TODO handle fading + if(fade_state == FadingOn) { + Uint32 ticks = SDL_GetTicks(); + float time = (ticks - fade_start_ticks) / 1000.0; + if(time >= fade_time) { + set_gain(1.0); + fade_state = NoFading; + } else { + set_gain(time / fade_time); + } + } else if(fade_state == FadingOff) { + Uint32 ticks = SDL_GetTicks(); + float time = (ticks - fade_start_ticks) / 1000.0; + if(time >= fade_time) { + stop(); + fade_state = NoFading; + } else { + set_gain( (fade_time-time) / fade_time); + } + } +} + +void +StreamSoundSource::setFading(FadeState state, float fade_time) +{ + this->fade_state = state; + this->fade_time = fade_time; + this->fade_start_ticks = SDL_GetTicks(); } void diff --git a/src/audio/stream_sound_source.hpp b/src/audio/stream_sound_source.hpp index 5fe4e462e..29e930422 100644 --- a/src/audio/stream_sound_source.hpp +++ b/src/audio/stream_sound_source.hpp @@ -2,6 +2,7 @@ #define __STREAM_SOUND_SOURCE_H__ #include +#include #include "sound_source.hpp" class SoundFile; @@ -12,6 +13,9 @@ public: StreamSoundSource(SoundFile* file); virtual ~StreamSoundSource(); + enum FadeState { NoFading, FadingOn, FadingOff }; + + void setFading(FadeState state, float fadetime); void update(); private: @@ -25,9 +29,9 @@ private: ALuint buffers[STREAMFRAGMENTS]; ALenum format; - enum FadeState { NoFading, FadingOn, FadingOff }; FadeState fade_state; - // TODO + Uint32 fade_start_ticks; + float fade_time; }; #endif diff --git a/src/game_session.cpp b/src/game_session.cpp index d6d10d3f0..1b7bc41dd 100644 --- a/src/game_session.cpp +++ b/src/game_session.cpp @@ -79,6 +79,7 @@ GameSession::GameSession(const std::string& levelfile_, GameSessionMode mode, capture_demo_stream(0), playback_demo_stream(0), demo_controller(0) { current_ = this; + currentsector = 0; game_pause = false; music_playing = false; @@ -698,7 +699,7 @@ GameSession::start_sequence(const std::string& sequencename) end_sequence = ENDSEQUENCE_RUNNING; endsequence_timer.start(7.0); // 7 seconds until we finish the map last_x_pos = -1; - sound_manager->play_music("music/leveldone.ogg"); + sound_manager->play_music("music/leveldone.ogg", false); currentsector->player->invincible_timer.start(7.0); if(sequencename == "fireworks") { -- 2.11.0