| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #ifndef __LINUX_DD_SOUND_H_ |
| 20 | #define __LINUX_DD_SOUND_H_cxx . . $ `sndlib/sdlsound.h:20:9`! |
| 21 | |
| 22 | #include <SDL_audio.h> |
| 23 | |
| 24 | #include "ssl_lib.h"cxx . . $ `<file>/sndlib/ssl_lib.h`/ |
| 25 | #include "mixer.h"cxx . . $ `<file>/sndlib/mixer.h`/ |
| 26 | |
| 27 | class sound_buffer_infocxx . . $ sound_buffer_info#; |
| 28 | |
| 29 | void lnxsound_SetErrorcxx . . $ lnxsound_SetError(d4f767463ce0a6b3).(int code); |
| 30 | void lnxsound_ErrorTextcxx . . $ lnxsound_ErrorText(326aeb464d16410c).(const char *fmt, ...); |
| 31 | inline void sb_adjust_properties_2dcxx . . $ sb_adjust_properties_2d(daef1a49d234ca4c).(sound_buffer_infocxx . . $ sound_buffer_info# *sb, float f_volume, float f_pan, uint16_tcxx . . $ uint16_t# frequency); |
| 32 | |
| 33 | class emulated_listenercxx . . $ emulated_listener# { |
| 34 | public: |
| 35 | matrixcxx . . $ matrix# orientcxx . . $ emulated_listener#orient.; |
| 36 | vectorcxx . . $ vector# positioncxx . . $ emulated_listener#position.; |
| 37 | vectorcxx . . $ vector# velocitycxx . . $ emulated_listener#velocity.; |
| 38 | }; |
| 39 | |
| 40 | class lnxsoundcxx . . $ lnxsound# : public llsSystemcxx . . $ llsSystem# { |
| 41 | // Public functions |
| 42 | public: |
| 43 | lnxsoundcxx . . $ lnxsound#lnxsound(49f6e7a06ebc5aa8).(); |
| 44 | ~cxx . . $ lnxsound#`~lnxsound`(ced63f7c635d850d).lnxsoundcxx . . $ lnxsound#(); |
| 45 | |
| 46 | // may be called before init (must be to be valid, the card passed here will be initialized in InitSoundLib) |
| 47 | void SetSoundCardcxx . . $ lnxsound#SetSoundCard(85c52e162fed56f9).(const char *name) override; |
| 48 | void PauseSoundcxx . . $ lnxsound#PauseSound(d4f767463ce0a6b3).(int sound_uid) override; |
| 49 | void ResumeSoundcxx . . $ lnxsound#ResumeSound(d4f767463ce0a6b3).(int sound_uid) override; |
| 50 | // set special parameters for the 3d environment. |
| 51 | // of strcuture passed, you must set the appropriate 'flags' value for values you wish to modify |
| 52 | void SetEnvironmentValuescxx . . $ lnxsound#SetEnvironmentValues(9789f8e644620ab0).(const t3dEnvironmentValuescxx . . $ t3dEnvironmentValues# *env) override; |
| 53 | |
| 54 | // get special parameters for the 3d environment. |
| 55 | // of strcuture passed, you must set the appropriate 'flags' value for values you wish to modify |
| 56 | void GetEnvironmentValuescxx . . $ lnxsound#GetEnvironmentValues(f6503759d22bce78).(t3dEnvironmentValuescxx . . $ t3dEnvironmentValues# *env) override; |
| 57 | |
| 58 | // enable special parameters for the 3d environment. |
| 59 | // of strcuture passed, you must set the appropriate 'flags' value for values you wish to modify |
| 60 | void SetEnvironmentTogglescxx . . $ lnxsound#SetEnvironmentToggles(4f564680f5be55d7).(const t3dEnvironmentTogglescxx . . $ t3dEnvironmentToggles# *env) override; |
| 61 | |
| 62 | // get states of special parameters for the 3d environment. |
| 63 | // of strcuture passed, you must set the appropriate 'flags' value for values you wish to modify |
| 64 | void GetEnvironmentTogglescxx . . $ lnxsound#GetEnvironmentToggles(3d0214c48b4fff80).(t3dEnvironmentTogglescxx . . $ t3dEnvironmentToggles# *env) override; |
| 65 | |
| 66 | // Starts the sound library, maybe have it send back some information -- 3d support? |
| 67 | int InitSoundLibcxx . . $ lnxsound#InitSoundLib(964874524976ed1).(char mixer_type, oeApplicationcxx . . $ oeApplication# *sos, uint8_tcxx . . $ uint8_t# max_sounds_played) override; |
| 68 | // Cleans up after the Sound Library |
| 69 | void DestroySoundLibcxx . . $ lnxsound#DestroySoundLib(49f6e7a06ebc5aa8).() override; |
| 70 | |
| 71 | // Locks and unlocks sounds (used when changing play_info data) |
| 72 | bool LockSoundcxx . . $ lnxsound#LockSound(83c267b20bac841a).(int sound_uid) override; |
| 73 | bool UnlockSoundcxx . . $ lnxsound#UnlockSound(83c267b20bac841a).(int sound_uid) override; |
| 74 | |
| 75 | bool SetSoundQualitycxx . . $ lnxsound#SetSoundQuality(b5fd09639b7a0261).(char quality) override; |
| 76 | char GetSoundQualitycxx . . $ lnxsound#GetSoundQuality(6e9c618e4dd2eafc).() override; |
| 77 | bool SetSoundMixercxx . . $ lnxsound#SetSoundMixer(b5fd09639b7a0261).(char mixer_type) override; |
| 78 | char GetSoundMixercxx . . $ lnxsound#GetSoundMixer(6e9c618e4dd2eafc).() override; |
| 79 | |
| 80 | // Plays a 2d sound |
| 81 | int PlaySound2dcxx . . $ lnxsound#PlaySound2d(8751acdd249a09c0).(play_informationcxx . . $ play_information# *play_info, int sound_index, float volume, float pan, bool f_looped) override; |
| 82 | int PlayStreamcxx . . $ lnxsound#PlayStream(c3f562479373c168).(play_informationcxx . . $ play_information# *play_info) override; |
| 83 | |
| 84 | void SetListenercxx . . $ lnxsound#SetListener(c7791b6699e1fa9e).(pos_statecxx . . $ pos_state# *cur_pos) override; |
| 85 | int PlaySound3dcxx . . $ lnxsound#PlaySound3d(112e06fe9f197cc1).(play_informationcxx . . $ play_information# *play_info, int sound_index, pos_statecxx . . $ pos_state# *cur_pos, float master_volume, |
| 86 | bool f_looped, float reverb = 0.5f) override; |
| 87 | void AdjustSoundcxx . . $ lnxsound#AdjustSound(96ebaef3518743f8).(int sound_uid, float f_volume, float f_pan, uint16_tcxx . . $ uint16_t# frequency) override; |
| 88 | void AdjustSoundcxx . . $ lnxsound#AdjustSound(f041466fe69f6310).(int sound_uid, pos_statecxx . . $ pos_state# *cur_pos, float adjusted_volume, float reverb = 0.5f) override; |
| 89 | |
| 90 | void StopAllSoundscxx . . $ lnxsound#StopAllSounds(49f6e7a06ebc5aa8).() override; |
| 91 | |
| 92 | // Checks if a sound is playing (removes finished sound); |
| 93 | bool IsSoundInstancePlayingcxx . . $ lnxsound#IsSoundInstancePlaying(83c267b20bac841a).(int sound_uid) override; |
| 94 | int IsSoundPlayingcxx . . $ lnxsound#IsSoundPlaying(7864480464b09eea).(int sound_index) override; |
| 95 | |
| 96 | // virtual void AdjustSound(int sound_uid, play_information *play_info) = 0; |
| 97 | |
| 98 | // Stops 2d and 3d sounds |
| 99 | void StopSoundcxx . . $ lnxsound#StopSound(9633529ce3c4ff50).(int sound_uid, uint8_tcxx . . $ uint8_t# f_immediately = SKT_STOP_IMMEDIATELYcxx . . $ `sndlib/ssl_lib.h:406:9`!) override; |
| 100 | |
| 101 | // Pause all sounds/resume all sounds |
| 102 | void PauseSoundscxx . . $ lnxsound#PauseSounds(49f6e7a06ebc5aa8).() override; |
| 103 | void ResumeSoundscxx . . $ lnxsound#ResumeSounds(49f6e7a06ebc5aa8).() override; |
| 104 | bool CheckAndForceSoundDataAlloccxx . . $ lnxsound#CheckAndForceSoundDataAlloc(83c267b20bac841a).(int sound_file_index) override; |
| 105 | |
| 106 | // Begin sound frame |
| 107 | void SoundStartFramecxx . . $ lnxsound#SoundStartFrame(49f6e7a06ebc5aa8).() override; |
| 108 | |
| 109 | // End sound frame |
| 110 | void SoundEndFramecxx . . $ lnxsound#SoundEndFrame(49f6e7a06ebc5aa8).() override; |
| 111 | |
| 112 | // returns the error string. |
| 113 | virtual const char *GetErrorStrcxx . . $ lnxsound#GetErrorStr(a9f41ea0e82d88cf).() const; |
| 114 | |
| 115 | // environmental sound interface |
| 116 | // volume modifier (0-1), damping(0-1), 1 = complete, 0 = none |
| 117 | // decay 0.1 to 100 seconds, how long it takes for a sound to die. |
| 118 | bool SetGlobalReverbPropertiescxx . . $ lnxsound#SetGlobalReverbProperties(5f279dd7f821a414).(float volume, float damping, float decay) override; |
| 119 | |
| 120 | bool GetDeviceSettingscxx . . $ lnxsound#GetDeviceSettings(23ffcdbfb576de00).(SDL_AudioDeviceID *sound_device, uint32_tcxx . . $ uint32_t# *freq, uint32_tcxx . . $ uint32_t# *bit_depth, |
| 121 | uint32_tcxx . . $ uint32_t# *channels) const; |
| 122 | |
| 123 | friend void lnxsound_SetErrorcxx . . $ lnxsound_SetError(d4f767463ce0a6b3).(int code); |
| 124 | friend void lnxsound_ErrorTextcxx . . $ lnxsound_ErrorText(326aeb464d16410c).(const char *fmt, ...); |
| 125 | friend inline void sb_adjust_properties_2dcxx . . $ sb_adjust_properties_2d(daef1a49d234ca4c).(sound_buffer_infocxx . . $ sound_buffer_info# *sb, float f_volume, float f_pan, uint16_tcxx . . $ uint16_t# frequency); |
| 126 | |
| 127 | protected: |
| 128 | #ifdef _DEBUGcxx . . $ `<built-in>:480:9`! |
| 129 | int16_t FindFreeSoundSlotcxx . . $ lnxsound#FindFreeSoundSlot(1685579755b59590).(int sound_index, float volume, int priority); |
| 130 | #else |
| 131 | int16_t FindFreeSoundSlot(float volume, int priority); |
| 132 | #endif |
| 133 | // This function limits the number of sounds cached to 255(8bits) and 256 bit is for invalid channel |
| 134 | // The purpose is to create unique signatures for each sound played (and allow for |
| 135 | // the slot_number to be quickly determined) |
| 136 | inline int MakeUniqueIdcxx . . $ lnxsound#MakeUniqueId(7ccb52b1bfe01045).(int sound_slot) const; |
| 137 | static inline int ValidateUniqueIdcxx . . $ lnxsound#ValidateUniqueId(7864480464b09eea).(int sound_uid); |
| 138 | |
| 139 | // Sound System Error Handler. |
| 140 | void CheckForErrorscxx . . $ lnxsound#CheckForErrors(49f6e7a06ebc5aa8).() override; |
| 141 | |
| 142 | void StartStreamingcxx . . $ lnxsound#StartStreaming(49f6e7a06ebc5aa8).(); |
| 143 | void EndStreamingcxx . . $ lnxsound#EndStreaming(49f6e7a06ebc5aa8).(); |
| 144 | |
| 145 | int m_primary_frequencycxx . . $ lnxsound#m_primary_frequency.; // Set to the primary buffers frequency -- cmphack |
| 146 | int m_primary_alignmentcxx . . $ lnxsound#m_primary_alignment.; |
| 147 | |
| 148 | SDL_AudioDeviceID sound_devicecxx . . $ lnxsound#sound_device.; |
| 149 | bool in_at_exitcxx . . $ lnxsound#in_at_exit.; |
| 150 | bool m_in_sound_framecxx . . $ lnxsound#m_in_sound_frame.; |
| 151 | bool m_pending_actionscxx . . $ lnxsound#m_pending_actions.; |
| 152 | char m_sound_qualitycxx . . $ lnxsound#m_sound_quality.; |
| 153 | float m_cache_stress_timercxx . . $ lnxsound#m_cache_stress_timer.; |
| 154 | float m_timer_last_frametimecxx . . $ lnxsound#m_timer_last_frametime.; |
| 155 | |
| 156 | int m_total_sounds_playedcxx . . $ lnxsound#m_total_sounds_played.; |
| 157 | int m_cur_sounds_playedcxx . . $ lnxsound#m_cur_sounds_played.; |
| 158 | |
| 159 | emulated_listenercxx . . $ emulated_listener# m_emulated_listenercxx . . $ lnxsound#m_emulated_listener.; |
| 160 | |
| 161 | // Sam 6/29 - Added support for SDL |
| 162 | software_mixercxx . . $ software_mixer# m_mixercxx . . $ lnxsound#m_mixer.; |
| 163 | }; |
| 164 | |
| 165 | #endif |