| 1 | /* |
| 2 | * OpenTyrian: A modern cross-platform port of Tyrian |
| 3 | * Copyright (C) 2007-2009 The OpenTyrian Development Team |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License |
| 7 | * as published by the Free Software Foundation; either version 2 |
| 8 | * of the License, or (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, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 18 | */ |
| 19 | #include "loudness.h"cxx . . $ `<file>/src/loudness.h`/ |
| 20 | |
| 21 | #include "file.h"cxx . . $ `<file>/src/file.h`/ |
| 22 | #include "lds_play.h"cxx . . $ `<file>/src/lds_play.h`/ |
| 23 | #include "nortsong.h"cxx . . $ `<file>/src/nortsong.h`/ |
| 24 | #include "opentyr.h"cxx . . $ `<file>/src/opentyr.h`/ |
| 25 | #include "params.h"cxx . . $ `<file>/src/params.h`/ |
| 26 | |
| 27 | #include <assert.h> |
| 28 | #include <stdlib.h> |
| 29 | #include <string.h> |
| 30 | |
| 31 | #define OUTPUT_QUALITYcxx . . $ `src/loudness.c:31:9`! 4 // 44.1 kHz |
| 32 | |
| 33 | int audioSampleRatecxx . . $ audioSampleRate. = 0; |
| 34 | |
| 35 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! music_stoppedcxx . . $ music_stopped. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 36 | unsigned int song_playingcxx . . $ song_playing. = 0; |
| 37 | |
| 38 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! audio_disabledcxx . . $ audio_disabled. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!, music_disabledcxx . . $ music_disabled. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!, samples_disabledcxx . . $ samples_disabled. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 39 | |
| 40 | static SDL_AudioDeviceIDcxx . . $ SDL_AudioDeviceID# audioDevicecxx . . $ audioDevice. = 0; |
| 41 | |
| 42 | static Uint8cxx . . $ Uint8# musicVolumecxx . . $ musicVolume. = 255; |
| 43 | static Uint8cxx . . $ Uint8# sampleVolumecxx . . $ sampleVolume. = 255; |
| 44 | |
| 45 | static const float volumeRangecxx . . $ volumeRange. = 30.0f; // dB |
| 46 | |
| 47 | // Fixed point Q20.12; needs to be able to store (10 * INT16_MIN/MAX) |
| 48 | static Sint32cxx . . $ Sint32# volumeFactorTablecxx . . $ volumeFactorTable.[256]; |
| 49 | #define TO_FIXEDcxx . . $ `src/loudness.c:49:9`!(x) ((Sint32)((x) * (1 << 12))) |
| 50 | #define FIXED_TO_INTcxx . . $ `src/loudness.c:50:9`!(x) ((Sint32)((x) >> 12)) |
| 51 | |
| 52 | // Twice the Loudness update rate (in updates/second). In Tyrian, Loudness |
| 53 | // updates were performed at the same rate as the game timer, which varied |
| 54 | // depending on the game speed (~69.57 Hz at most game speeds). We don't have |
| 55 | // the same limitations, so we'll keep the update rate constant, but we do want |
| 56 | // to stick to integer math, so we'll update at 69.5 Hz. |
| 57 | static const int ldsUpdate2Ratecxx . . $ ldsUpdate2Rate. = 139; // 69.5 * 2 |
| 58 | |
| 59 | static int samplesPerLdsUpdatecxx . . $ samplesPerLdsUpdate.; |
| 60 | static int samplesPerLdsUpdateFraccxx . . $ samplesPerLdsUpdateFrac.; |
| 61 | |
| 62 | static int samplesUntilLdsUpdatecxx . . $ samplesUntilLdsUpdate. = 0; |
| 63 | static int samplesUntilLdsUpdateFraccxx . . $ samplesUntilLdsUpdateFrac. = 0; |
| 64 | |
| 65 | static FILEcxx . . $ FILE# *music_filecxx . . $ music_file. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 66 | static Uint32cxx . . $ Uint32# *song_offsetcxx . . $ song_offset.; |
| 67 | static Uint16cxx . . $ Uint16# song_countcxx . . $ song_count. = 0; |
| 68 | |
| 69 | #define CHANNEL_COUNTcxx . . $ `src/loudness.c:69:9`! 8 |
| 70 | static const Sint16cxx . . $ Sint16# *channelSamplescxx . . $ channelSamples.[CHANNEL_COUNTcxx . . $ `src/loudness.c:69:9`!]; |
| 71 | static size_t channelSampleCountcxx . . $ channelSampleCount.[CHANNEL_COUNTcxx . . $ `src/loudness.c:69:9`!] = { 0 }; |
| 72 | static Uint8cxx . . $ Uint8# channelVolumecxx . . $ channelVolume.[CHANNEL_COUNTcxx . . $ `src/loudness.c:69:9`!]; |
| 73 | #define CHANNEL_VOLUME_LEVELScxx . . $ `src/loudness.c:73:9`! 8 |
| 74 | |
| 75 | static void audioCallbackcxx . . $ audioCallback(c52f2c8079c5ae6).(void *userdata, Uint8cxx . . $ Uint8# *stream, int size); |
| 76 | |
| 77 | static void load_songcxx . . $ load_song(cb2f890c2fdad230).(unsigned int song_num); |
| 78 | |
| 79 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! init_audiocxx . . $ init_audio(c9857a73d68e59ba).(void) |
| 80 | { |
| 81 | if (audio_disabledcxx . . $ audio_disabled.) |
| 82 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 83 | |
| 84 | SDL_AudioSpeccxx . . $ SDL_AudioSpec# ask, got; |
| 85 | |
| 86 | ask.freqcxx . . $ SDL_AudioSpec#freq. = 11025 * OUTPUT_QUALITYcxx . . $ `src/loudness.c:31:9`!; |
| 87 | ask.formatcxx . . $ SDL_AudioSpec#format. = AUDIO_S16SYScxx . . $ `<external>/178947386371380387/SDL_audio.h:125:9`!; |
| 88 | ask.channelscxx . . $ SDL_AudioSpec#channels. = 1; |
| 89 | ask.samplescxx . . $ SDL_AudioSpec#samples. = 256 * OUTPUT_QUALITYcxx . . $ `src/loudness.c:31:9`!; // ~23 ms |
| 90 | ask.callbackcxx . . $ SDL_AudioSpec#callback. = audioCallbackcxx . . $ audioCallback(c52f2c8079c5ae6).; |
| 91 | |
| 92 | if (SDL_InitSubSystemcxx . . $ SDL_InitSubSystem(4c679297bf94b9eb).(SDL_INIT_AUDIOcxx . . $ `<external>/13597568925221565411/SDL.h:84:9`!)) |
| 93 | { |
| 94 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "error: failed to initialize SDL audio: %s\n", SDL_GetErrorcxx . . $ SDL_GetError(33a1f659e94feb42).()); |
| 95 | audio_disabledcxx . . $ audio_disabled. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 96 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 97 | } |
| 98 | |
| 99 | int allowedChanges = SDL_AUDIO_ALLOW_FREQUENCY_CHANGEcxx . . $ `<external>/178947386371380387/SDL_audio.h:142:9`!; |
| 100 | #if SDL_VERSION_ATLEASTcxx . . $ `<external>/11196385350576350796/SDL_version.h:121:9`!(2, 0, 9) |
| 101 | allowedChanges |= SDL_AUDIO_ALLOW_SAMPLES_CHANGEcxx . . $ `<external>/178947386371380387/SDL_audio.h:145:9`!; |
| 102 | #endif |
| 103 | audioDevicecxx . . $ audioDevice. = SDL_OpenAudioDevicecxx . . $ SDL_OpenAudioDevice(8944c6df11d5148c).(/*device*/ NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, /*iscapture*/ 0, &ask, &got, allowedChanges); |
| 104 | |
| 105 | if (audioDevicecxx . . $ audioDevice. == 0) |
| 106 | { |
| 107 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "error: SDL failed to open audio device: %s\n", SDL_GetErrorcxx . . $ SDL_GetError(33a1f659e94feb42).()); |
| 108 | audio_disabledcxx . . $ audio_disabled. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 109 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 110 | } |
| 111 | |
| 112 | audioSampleRatecxx . . $ audioSampleRate. = got.freqcxx . . $ SDL_AudioSpec#freq.; |
| 113 | |
| 114 | samplesPerLdsUpdatecxx . . $ samplesPerLdsUpdate. = 2 * (audioSampleRatecxx . . $ audioSampleRate. / ldsUpdate2Ratecxx . . $ ldsUpdate2Rate.); |
| 115 | samplesPerLdsUpdateFraccxx . . $ samplesPerLdsUpdateFrac. = 2 * (audioSampleRatecxx . . $ audioSampleRate. % ldsUpdate2Ratecxx . . $ ldsUpdate2Rate.); |
| 116 | |
| 117 | volumeFactorTablecxx . . $ volumeFactorTable.[0] = 0; |
| 118 | for (size_t i = 1; i < 256; ++i) |
| 119 | volumeFactorTablecxx . . $ volumeFactorTable.[i] = TO_FIXEDcxx . . $ `src/loudness.c:49:9`!(powf(10, (255 - i) * (-volumeRange / (20.0f * 255)))); |
| 120 | |
| 121 | opl_initcxx . . $ `src/opl.h:47:9`!(); |
| 122 | |
| 123 | SDL_PauseAudioDevicecxx . . $ SDL_PauseAudioDevice(3d89109e85ced1be).(audioDevicecxx . . $ audioDevice., 0); // unpause |
| 124 | |
| 125 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 126 | } |
| 127 | |
| 128 | static void audioCallbackcxx . . $ audioCallback(c52f2c8079c5ae6).(void *userdata, Uint8cxx . . $ Uint8# *stream, int size) |
| 129 | { |
| 130 | (void)userdata; |
| 131 | |
| 132 | Sint16cxx . . $ Sint16# *const samples = (Sint16cxx . . $ Sint16# *)stream; |
| 133 | const int samplesCount = size / sizeof (Sint16cxx . . $ Sint16#); |
| 134 | |
| 135 | if (!music_disabledcxx . . $ music_disabled. && !music_stoppedcxx . . $ music_stopped.) |
| 136 | { |
| 137 | Sint16cxx . . $ Sint16# *remaining = samples; |
| 138 | int remainingCount = samplesCount; |
| 139 | while (remainingCount > 0) |
| 140 | { |
| 141 | if (samplesUntilLdsUpdatecxx . . $ samplesUntilLdsUpdate. == 0) |
| 142 | { |
| 143 | lds_updatecxx . . $ lds_update(b126dc7c1de90089).(); |
| 144 | |
| 145 | // The number of samples that should be produced per Loudness |
| 146 | // update is not an integer, but we can only produce an integer |
| 147 | // number of samples, so we accumulate the fractional samples |
| 148 | // until it amounts to a whole sample. |
| 149 | samplesUntilLdsUpdatecxx . . $ samplesUntilLdsUpdate. += samplesPerLdsUpdatecxx . . $ samplesPerLdsUpdate.; |
| 150 | samplesUntilLdsUpdateFraccxx . . $ samplesUntilLdsUpdateFrac. += samplesPerLdsUpdateFraccxx . . $ samplesPerLdsUpdateFrac.; |
| 151 | if (samplesUntilLdsUpdateFraccxx . . $ samplesUntilLdsUpdateFrac. >= ldsUpdate2Ratecxx . . $ ldsUpdate2Rate.) |
| 152 | { |
| 153 | samplesUntilLdsUpdatecxx . . $ samplesUntilLdsUpdate. += 1; |
| 154 | samplesUntilLdsUpdateFraccxx . . $ samplesUntilLdsUpdateFrac. -= ldsUpdate2Ratecxx . . $ ldsUpdate2Rate.; |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | int count = MINcxx . . $ `src/opentyr.h:28:9`!(samplesUntilLdsUpdate, remainingCount); |
| 159 | |
| 160 | opl_updatecxx . . $ `src/opl.h:49:9`!(remaining, count); |
| 161 | |
| 162 | remaining += count; |
| 163 | remainingCount -= count; |
| 164 | |
| 165 | samplesUntilLdsUpdatecxx . . $ samplesUntilLdsUpdate. -= count; |
| 166 | } |
| 167 | } |
| 168 | else |
| 169 | { |
| 170 | for (int i = 0; i < samplesCount; ++i) |
| 171 | samples[i] = 0; |
| 172 | } |
| 173 | |
| 174 | Sint32cxx . . $ Sint32# musicVolumeFactor = volumeFactorTablecxx . . $ volumeFactorTable.[musicVolumecxx . . $ musicVolume.]; |
| 175 | musicVolumeFactor *= 2; // OPL emulator is too quiet |
| 176 | |
| 177 | if (samples_disabledcxx . . $ samples_disabled. && !music_disabledcxx . . $ music_disabled.) |
| 178 | { |
| 179 | // Mix music |
| 180 | Sint16cxx . . $ Sint16# *remaining = samples; |
| 181 | int remainingCount = samplesCount; |
| 182 | while (remainingCount > 0) |
| 183 | { |
| 184 | Sint32cxx . . $ Sint32# sample = *remaining * musicVolumeFactor; |
| 185 | |
| 186 | sample = FIXED_TO_INTcxx . . $ `src/loudness.c:50:9`!(sample); |
| 187 | *remaining = MINcxx . . $ `src/opentyr.h:28:9`!(MAXcxx . . $ `src/opentyr.h:29:9`!(INT16_MINcxx . . $ `<external>/3415975807581488833/stdint.h:106:10`!, sample), INT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:111:10`!); |
| 188 | |
| 189 | remaining += 1; |
| 190 | remainingCount -= 1; |
| 191 | } |
| 192 | } |
| 193 | else if (!samples_disabledcxx . . $ samples_disabled.) |
| 194 | { |
| 195 | Sint32cxx . . $ Sint32# sampleVolumeFactor = volumeFactorTablecxx . . $ volumeFactorTable.[sampleVolumecxx . . $ sampleVolume.]; |
| 196 | Sint32cxx . . $ Sint32# sampleVolumeFactors[CHANNEL_VOLUME_LEVELScxx . . $ `src/loudness.c:73:9`!]; |
| 197 | for (int i = 0; i < CHANNEL_VOLUME_LEVELScxx . . $ `src/loudness.c:73:9`!; ++i) |
| 198 | sampleVolumeFactors[i] = sampleVolumeFactor * (i + 1) / CHANNEL_VOLUME_LEVELScxx . . $ `src/loudness.c:73:9`!; |
| 199 | |
| 200 | // Mix music and channels |
| 201 | Sint16cxx . . $ Sint16# *remaining = samples; |
| 202 | int remainingCount = samplesCount; |
| 203 | while (remainingCount > 0) |
| 204 | { |
| 205 | Sint32cxx . . $ Sint32# sample = *remaining * musicVolumeFactor; |
| 206 | |
| 207 | for (size_t i = 0; i < CHANNEL_COUNTcxx . . $ `src/loudness.c:69:9`!; ++i) |
| 208 | { |
| 209 | if (channelSampleCountcxx . . $ channelSampleCount.[i] > 0) |
| 210 | { |
| 211 | sample += *channelSamplescxx . . $ channelSamples.[i] * sampleVolumeFactors[channelVolumecxx . . $ channelVolume.[i]]; |
| 212 | |
| 213 | channelSamplescxx . . $ channelSamples.[i] += 1; |
| 214 | channelSampleCountcxx . . $ channelSampleCount.[i] -= 1; |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | sample = FIXED_TO_INTcxx . . $ `src/loudness.c:50:9`!(sample); |
| 219 | *remaining = MINcxx . . $ `src/opentyr.h:28:9`!(MAXcxx . . $ `src/opentyr.h:29:9`!(INT16_MINcxx . . $ `<external>/3415975807581488833/stdint.h:106:10`!, sample), INT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:111:10`!); |
| 220 | |
| 221 | remaining += 1; |
| 222 | remainingCount -= 1; |
| 223 | } |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | void deinit_audiocxx . . $ deinit_audio(49f6e7a06ebc5aa8).(void) |
| 228 | { |
| 229 | if (audio_disabledcxx . . $ audio_disabled.) |
| 230 | return; |
| 231 | |
| 232 | if (audioDevicecxx . . $ audioDevice. != 0) |
| 233 | { |
| 234 | SDL_PauseAudioDevicecxx . . $ SDL_PauseAudioDevice(3d89109e85ced1be).(audioDevicecxx . . $ audioDevice., 1); // pause |
| 235 | SDL_CloseAudioDevicecxx . . $ SDL_CloseAudioDevice(cb2f890c2fdad230).(audioDevicecxx . . $ audioDevice.); |
| 236 | audioDevicecxx . . $ audioDevice. = 0; |
| 237 | } |
| 238 | |
| 239 | SDL_QuitSubSystemcxx . . $ SDL_QuitSubSystem(cb2f890c2fdad230).(SDL_INIT_AUDIOcxx . . $ `<external>/13597568925221565411/SDL.h:84:9`!); |
| 240 | |
| 241 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(channelSampleCountcxx . . $ channelSampleCount., 0, sizeof channelSampleCountcxx . . $ channelSampleCount.); |
| 242 | |
| 243 | lds_freecxx . . $ lds_free(49f6e7a06ebc5aa8).(); |
| 244 | } |
| 245 | |
| 246 | void load_musiccxx . . $ load_music(49f6e7a06ebc5aa8).(void) // FKA NortSong.loadSong |
| 247 | { |
| 248 | if (music_filecxx . . $ music_file. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 249 | { |
| 250 | music_filecxx . . $ music_file. = dir_fopen_diecxx . . $ dir_fopen_die(2493aa730c89ee72).(data_dircxx . . $ data_dir(33a1f659e94feb42).(), "music.mus", "rb"); |
| 251 | |
| 252 | fread_u16_diecxx . . $ fread_u16_die(c6228d4965a46ad0).(&song_countcxx . . $ song_count., 1, music_filecxx . . $ music_file.); |
| 253 | |
| 254 | song_offsetcxx . . $ song_offset. = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).((song_countcxx . . $ song_count. + 1) * sizeof(*song_offsetcxx . . $ song_offset.)); |
| 255 | |
| 256 | fread_u32_diecxx . . $ fread_u32_die(503b8e976a020473).(song_offsetcxx . . $ song_offset., song_countcxx . . $ song_count., music_filecxx . . $ music_file.); |
| 257 | |
| 258 | song_offsetcxx . . $ song_offset.[song_countcxx . . $ song_count.] = ftell_eofcxx . . $ ftell_eof(1dcafcd8ef4c6e6c).(music_filecxx . . $ music_file.); |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | static void load_songcxx . . $ load_song(cb2f890c2fdad230).(unsigned int song_num) // FKA NortSong.loadSong |
| 263 | { |
| 264 | if (song_num < song_countcxx . . $ song_count.) |
| 265 | { |
| 266 | unsigned int song_size = song_offsetcxx . . $ song_offset.[song_num + 1] - song_offsetcxx . . $ song_offset.[song_num]; |
| 267 | lds_loadcxx . . $ lds_load(38255538a6a87b10).(music_filecxx . . $ music_file., song_offsetcxx . . $ song_offset.[song_num], song_size); |
| 268 | } |
| 269 | else |
| 270 | { |
| 271 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "warning: failed to load song %d\n", song_num + 1); |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | void play_songcxx . . $ play_song(cb2f890c2fdad230).(unsigned int song_num) // FKA NortSong.playSong |
| 276 | { |
| 277 | if (audio_disabledcxx . . $ audio_disabled.) |
| 278 | return; |
| 279 | |
| 280 | if (song_num != song_playingcxx . . $ song_playing.) |
| 281 | { |
| 282 | SDL_LockAudioDevicecxx . . $ SDL_LockAudioDevice(cb2f890c2fdad230).(audioDevicecxx . . $ audioDevice.); |
| 283 | |
| 284 | music_stoppedcxx . . $ music_stopped. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 285 | |
| 286 | SDL_UnlockAudioDevicecxx . . $ SDL_UnlockAudioDevice(cb2f890c2fdad230).(audioDevicecxx . . $ audioDevice.); |
| 287 | |
| 288 | load_songcxx . . $ load_song(cb2f890c2fdad230).(song_num); |
| 289 | |
| 290 | song_playingcxx . . $ song_playing. = song_num; |
| 291 | } |
| 292 | |
| 293 | SDL_LockAudioDevicecxx . . $ SDL_LockAudioDevice(cb2f890c2fdad230).(audioDevicecxx . . $ audioDevice.); |
| 294 | |
| 295 | music_stoppedcxx . . $ music_stopped. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 296 | |
| 297 | SDL_UnlockAudioDevicecxx . . $ SDL_UnlockAudioDevice(cb2f890c2fdad230).(audioDevicecxx . . $ audioDevice.); |
| 298 | } |
| 299 | |
| 300 | void restart_songcxx . . $ restart_song(49f6e7a06ebc5aa8).(void) // FKA Player.selectSong(1) |
| 301 | { |
| 302 | if (audio_disabledcxx . . $ audio_disabled.) |
| 303 | return; |
| 304 | |
| 305 | SDL_LockAudioDevicecxx . . $ SDL_LockAudioDevice(cb2f890c2fdad230).(audioDevicecxx . . $ audioDevice.); |
| 306 | |
| 307 | lds_rewindcxx . . $ lds_rewind(49f6e7a06ebc5aa8).(); |
| 308 | |
| 309 | music_stoppedcxx . . $ music_stopped. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 310 | |
| 311 | SDL_UnlockAudioDevicecxx . . $ SDL_UnlockAudioDevice(cb2f890c2fdad230).(audioDevicecxx . . $ audioDevice.); |
| 312 | } |
| 313 | |
| 314 | void stop_songcxx . . $ stop_song(49f6e7a06ebc5aa8).(void) // FKA Player.selectSong(0) |
| 315 | { |
| 316 | if (audio_disabledcxx . . $ audio_disabled.) |
| 317 | return; |
| 318 | |
| 319 | SDL_LockAudioDevicecxx . . $ SDL_LockAudioDevice(cb2f890c2fdad230).(audioDevicecxx . . $ audioDevice.); |
| 320 | |
| 321 | music_stoppedcxx . . $ music_stopped. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 322 | |
| 323 | SDL_UnlockAudioDevicecxx . . $ SDL_UnlockAudioDevice(cb2f890c2fdad230).(audioDevicecxx . . $ audioDevice.); |
| 324 | } |
| 325 | |
| 326 | void fade_songcxx . . $ fade_song(49f6e7a06ebc5aa8).(void) // FKA Player.selectSong($C001) |
| 327 | { |
| 328 | if (audio_disabledcxx . . $ audio_disabled.) |
| 329 | return; |
| 330 | |
| 331 | SDL_LockAudioDevicecxx . . $ SDL_LockAudioDevice(cb2f890c2fdad230).(audioDevicecxx . . $ audioDevice.); |
| 332 | |
| 333 | lds_fadecxx . . $ lds_fade(ac50b47256ae7414).(1); |
| 334 | |
| 335 | SDL_UnlockAudioDevicecxx . . $ SDL_UnlockAudioDevice(cb2f890c2fdad230).(audioDevicecxx . . $ audioDevice.); |
| 336 | } |
| 337 | |
| 338 | void set_volumecxx . . $ set_volume(8fbe6856f5410d23).(Uint8cxx . . $ Uint8# musicVolume_, Uint8cxx . . $ Uint8# sampleVolume_) // FKA NortSong.setVol and Player.setVol |
| 339 | { |
| 340 | if (audio_disabledcxx . . $ audio_disabled.) |
| 341 | return; |
| 342 | |
| 343 | SDL_LockAudioDevicecxx . . $ SDL_LockAudioDevice(cb2f890c2fdad230).(audioDevicecxx . . $ audioDevice.); |
| 344 | |
| 345 | musicVolumecxx . . $ musicVolume. = musicVolume_; |
| 346 | sampleVolumecxx . . $ sampleVolume. = sampleVolume_; |
| 347 | |
| 348 | SDL_UnlockAudioDevicecxx . . $ SDL_UnlockAudioDevice(cb2f890c2fdad230).(audioDevicecxx . . $ audioDevice.); |
| 349 | } |
| 350 | |
| 351 | void multiSamplePlaycxx . . $ multiSamplePlay(c50bd6ef3d54aac8).(const Sint16cxx . . $ Sint16# *samples, size_t sampleCount, Uint8cxx . . $ Uint8# chan, Uint8cxx . . $ Uint8# vol) // FKA Player.multiSamplePlay |
| 352 | { |
| 353 | assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(chan < CHANNEL_COUNT); |
| 354 | assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(vol < CHANNEL_VOLUME_LEVELS); |
| 355 | |
| 356 | if (audio_disabledcxx . . $ audio_disabled. || samples_disabledcxx . . $ samples_disabled.) |
| 357 | return; |
| 358 | |
| 359 | SDL_LockAudioDevicecxx . . $ SDL_LockAudioDevice(cb2f890c2fdad230).(audioDevicecxx . . $ audioDevice.); |
| 360 | |
| 361 | channelSamplescxx . . $ channelSamples.[chan] = samples; |
| 362 | channelSampleCountcxx . . $ channelSampleCount.[chan] = sampleCount; |
| 363 | channelVolumecxx . . $ channelVolume.[chan] = vol; |
| 364 | |
| 365 | SDL_UnlockAudioDevicecxx . . $ SDL_UnlockAudioDevice(cb2f890c2fdad230).(audioDevicecxx . . $ audioDevice.); |
| 366 | } |