| 1 | |
| 2 | /** |
| 3 | * |
| 4 | * @file sound.h |
| 5 | * |
| 6 | * Part of the OpenJazz project |
| 7 | * |
| 8 | * @par History: |
| 9 | * - 23rd August 2005: Created OpenJazz.h |
| 10 | * - 2nd June 2009: Created sound.h from parts of OpenJazz.h |
| 11 | * |
| 12 | * @par Licence: |
| 13 | * Copyright (c) 2005-2010 AJ Thomson |
| 14 | * |
| 15 | * OpenJazz is distributed under the terms of |
| 16 | * the GNU General Public License, version 2.0 |
| 17 | * |
| 18 | */ |
| 19 | |
| 20 | #ifndef OJ_SOUND_H |
| 21 | #define OJ_SOUND_H |
| 22 | |
| 23 | #include "OpenJazz.h" |
| 24 | |
| 25 | // Constants |
| 26 | |
| 27 | // Sound effects |
| 28 | |
| 29 | namespace SE { |
| 30 | enum Type : int { |
| 31 | NONE = 0, |
| 32 | INVULN, |
| 33 | MACHGUN, |
| 34 | BOOM, |
| 35 | OW, |
| 36 | YUM, |
| 37 | FIRE, |
| 38 | UPLOOP, |
| 39 | ONEUP, |
| 40 | PHOTON, |
| 41 | WAIT, |
| 42 | ORB, |
| 43 | JUMPA, |
| 44 | GODLIKE, |
| 45 | YEAHOO, |
| 46 | BIRDY, |
| 47 | FLAMER, |
| 48 | ELECTR, |
| 49 | SPRING, |
| 50 | ROCKET, |
| 51 | STOP, |
| 52 | BLOCK, |
| 53 | CUSTOM_22, |
| 54 | CUSTOM_23, |
| 55 | CUSTOM_24, |
| 56 | CUSTOM_25, |
| 57 | CUSTOM_26, |
| 58 | CUSTOM_27, |
| 59 | CUSTOM_28, |
| 60 | CUSTOM_29, |
| 61 | CUSTOM_30, |
| 62 | CUSTOM_31, |
| 63 | CUSTOM_32, |
| 64 | MAX |
| 65 | }; |
| 66 | }; |
| 67 | |
| 68 | #define MAX_VOLUME 100 |
| 69 | enum class MusicTempo { NORMAL = 128, FAST = 80 }; |
| 70 | |
| 71 | |
| 72 | // Variables |
| 73 | |
| 74 | #if defined(WIZ) || defined(GP2X) |
| 75 | EXTERN int volume; |
| 76 | EXTERN int volume_direction; |
| 77 | #endif |
| 78 | |
| 79 | |
| 80 | // Functions |
| 81 | |
| 82 | void openAudio(); |
| 83 | void closeAudio(); |
| 84 | void playMusic(const char *fileName, bool restart = false); |
| 85 | void pauseMusic(bool pause); |
| 86 | void stopMusic(); |
| 87 | int getMusicVolume(); |
| 88 | void setMusicVolume(int volume); |
| 89 | MusicTempo getMusicTempo(); |
| 90 | void setMusicTempo(MusicTempo tempo); |
| 91 | bool loadSounds(const char *fileName); |
| 92 | void resampleSound(int index, const char* name, int rate); |
| 93 | void resampleSounds(); |
| 94 | void freeSounds(); |
| 95 | void playSound(SE::Type se); |
| 96 | bool isSoundPlaying(SE::Type se); |
| 97 | int getSoundVolume(); |
| 98 | void setSoundVolume(int volume); |
| 99 | |
| 100 | inline void playConfirmSound() { playSound(SE::ORB); } |
| 101 | inline bool isValidSoundIndex(SE::Type index) { return (index >= SE::NONE && index < SE::MAX); } |
| 102 | |
| 103 | #endif |