Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
public.h File Reference

Go to the source code of this file.

Functions

void snd_notify_engine_ready (ALHeap *heap)
 
void snd_legacy_sound_dispatch (u32 id)
 Unused Seems to be an early function that accepts a command to play any kind of audio asset,.
 
void snd_bgm_enqueue_legacy_command (u32 cmd)
 Unused Part of an unused system for inter-thread communication with a BGM player using commands.
 
void snd_start_sound (s32 soundID, u8 volume, u8 pan)
 
void snd_start_sound_with_shift (s32 soundID, u8 volume, u8 pan, s16 pitchShift)
 
void snd_adjust_sound (s32 soundID, u8 volume, u8 pan)
 
void snd_adjust_sound_with_shift (s32 soundID, u8 volume, u8 pan, s16 pitchShift)
 
void snd_stop_sound (s32 soundID)
 
void snd_reset (void)
 
void snd_start_sound_raw (s32 soundID, s16 volume, s16 pitchShift, s32 pan)
 
AuResult snd_load_ambient (s32 arg0)
 
AuResult snd_ambient_play (s32 arg0, s32 arg1)
 
AuResult snd_ambient_stop_quick (s32 arg0)
 
AuResult snd_ambient_stop_slow (s32 arg0, s32 arg1)
 
AuResult snd_ambient_pause (s32 arg0, s32 arg1)
 
AuResult snd_ambient_resume (s32 arg0, s32 arg1)
 
AuResult snd_ambient_is_stopped (s32 arg0)
 
AuResult snd_ambient_fade_out (s32 arg0, s32 arg1)
 
AuResult snd_ambient_set_volume (s32 arg0, s32 arg1, s32 arg2)
 
AuResult snd_ambient_disable (s32 arg0)
 
AuResult snd_ambient_enable (s32 arg0)
 
void snd_ambient_radio_setup (s32 arg0)
 
AuResult snd_ambient_radio_stop (s32 arg0)
 
AuResult snd_ambient_radio_select (s32 arg0)
 
AuResult snd_song_load (s32 songID, s32 playerIndex)
 return value may be either an AuResult error code OR a valid songName
 
AuResult snd_song_request_play_default (s32 songName)
 Unused – snd_song_request_play but always uses BGM_VARIATION_0.
 
AuResult snd_song_request_play (s32 songName, s32 variation)
 Called from bgm_control to start playing a particular song + variation.
 
AuResult snd_song_stop (s32 songName)
 
void snd_song_stop_all (void)
 
AuResult snd_song_is_playing (s32 songName)
 
AuResult snd_song_request_fade_in (s32 songName, s32 variation, s32 fadeInTime, s32 startVolume, s32 endVolume)
 Called from bgm_control to fade in a particular song + variation.
 
AuResult snd_song_request_fade_in_default (s32 songName, s32 fadeInTime, s32 startVolume, s32 endVolume)
 Unused.
 
AuResult snd_song_request_fade_out (s32 songName, s32 fadeTime, AuCallback callback)
 
AuResult snd_song_push_stop (s32 songName)
 
AuResult snd_song_request_pop (s32 songName)
 
AuResult snd_song_request_snapshot (s32 songName)
 
AuResult snd_song_request_push_fade_out (s32 songName, s32 fadeTime)
 
AuResult snd_song_request_pause (s32 songName)
 
AuResult snd_song_request_unpause (s32 songName)
 
AuResult snd_song_set_volume_quiet (s32 songName)
 
AuResult snd_song_set_volume_full (s32 songName)
 
AuResult snd_song_set_linked_mode (s32 songName, b32 mode)
 
AuResult snd_song_set_playback_rate (s32 songName, f32 arg1)
 
void snd_song_poll_music_events (u32 **arg0, s32 *arg1)
 
void snd_song_flush_music_events (void)
 
void snd_song_trigger_music_event (s32 playerID, s32 trackIndex, s32 eventInfo)
 
void snd_song_clear_music_events (void)
 
void snd_set_stereo (void)
 
void snd_set_mono (void)
 
void snd_set_bgm_volume (VolumeLevels volume)
 
void snd_set_sfx_volume (VolumeLevels volume)
 
void snd_set_sfx_reverb_type (s32 arg0)
 
void snd_enable_sfx (void)
 
void snd_disable_sfx (void)
 
AuResult bgm_set_track_volumes (s32 playerIndex, s16 trackVolSet)
 
AuResult bgm_clear_track_volumes (s32 playerIndex, s16 trackVolSet)
 
AuResult bgm_set_linked_mode (s32 playerIndex, b16 mode)
 
void bgm_quiet_max_volume (void)
 
void bgm_reset_max_volume (void)
 
void bgm_reset_volume (void)
 
s32 bgm_init_music_players (void)
 
s32 bgm_set_song (s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime, s16 volume)
 
void bgm_set_battle_song (s32, s32)
 
void bgm_push_battle_song (void)
 
s32 bgm_adjust_proximity (s32 playerIndex, s32 arg1, s16 arg2)
 
b32 bgm_fade_in_song (s32 playerIndex, s32 songID, s32 variation, s32 fadeInTime, s16 arg4, s16 arg5)
 
void bgm_update_music_control (void)
 
b32 bgm_is_any_song_playing (void)
 
void bgm_reset_sequence_players (void)
 
void bgm_pop_song (void)
 
void bgm_push_song (s32 songID, s32 variation)
 
void bgm_pop_battle_song (void)
 
void sfx_reset_door_sounds (void)
 
void sfx_clear_sounds (void)
 
void sfx_clear_env_sounds (s16 playSounds)
 
void sfx_update_env_sound_params (void)
 
void sfx_set_reverb_mode (s32 arg0)
 
s32 sfx_get_reverb_mode (void)
 
void sfx_stop_env_sounds (void)
 
void sfx_play_sound_looping (s32 soundID, u8 volume, u8 pan, s16 pitchShift)
 
void sfx_register_looping_sound_at_position (s32 soundID, s32 flags, f32 x, f32 y, f32 z)
 
s32 sfx_adjust_env_sound_pos (s32 soundID, s32 sourceFlags, f32 x, f32 y, f32 z)
 
void sfx_stop_tracking_env_sound_pos (s32 soundID, s32 keepPlaying)
 
void sfx_play_sound_with_params (s32 soundID, u8 volume, u8 pan, s16 pitchShift)
 
void sfx_adjust_env_sound_params (s32 soundID, u8 volume, u8 pan, s16 pitchShift)
 
void sfx_stop_sound (s32 soundID)
 
void sfx_play_sound (s32 soundID)
 
void sfx_play_sound_at_player (s32 soundID, s32 arg1)
 
void sfx_play_sound_at_npc (s32 soundID, s32 arg1, s32 npcID)
 
void sfx_play_sound_at_position (s32 soundID, s32 flags, f32 posX, f32 posY, f32 posZ)
 
void sfx_get_spatialized_sound_params (f32 x, f32 y, f32 z, s16 *volume, s16 *pan, s32 flags)
 
void sfx_compute_spatialized_sound_params_ignore_depth (f32 x, f32 y, f32 z, s16 *volume, s16 *pan)
 
void sfx_compute_spatialized_sound_params_with_depth (f32 x, f32 y, f32 z, s16 *volume, s16 *pan)
 
void sfx_compute_spatialized_sound_params_full (f32 x, f32 y, f32 z, s16 *volume, s16 *pan, s32 flags)
 

Function Documentation

◆ snd_notify_engine_ready()

void snd_notify_engine_ready ( ALHeap * heap)

Definition at line 108 of file snd_interface.c.

108 {
111}
BSS s32 PopupMenu_SelectedIndex
s32 PreventBGMPlayerUpdate
While TRUE, the audio thread skips BGM player updates.
u16 SoundEngineReady

Referenced by au_engine_init().

◆ snd_legacy_sound_dispatch()

void snd_legacy_sound_dispatch ( u32 id)

Unused Seems to be an early function that accepts a command to play any kind of audio asset,.

Definition at line 116 of file snd_interface.c.

116 {
118 u32 type = id & 0xF;
119
120 if (ready == 1) {
121 switch (type) {
122 case 2:
123 case 3:
124 break;
125 case 4:
126 snd_start_sound_with_shift(id >> 4, 0, 0, 0);
127 break;
128 case 1:
129 if (type == 1) {
130 s32 filename = snd_song_load((id >> 4) & 0xFF, 0);
131
132 if (filename > ASCII_TO_U32('0', ' ', ' ', '\0')) {
133 snd_song_request_play(filename, (id >> 0xC) & 3);
134 }
135 }
136 break;
137 }
138 }
139}
#define ASCII_TO_U32(a, b, c, d)
Definition macros.h:191
void snd_start_sound_with_shift(s32 soundID, u8 volume, u8 pan, s16 pitchShift)
AuResult snd_song_request_play(s32 songName, s32 variation)
Called from bgm_control to start playing a particular song + variation.
AuResult snd_song_load(s32 songID, s32 playerIndex)
return value may be either an AuResult error code OR a valid songName

◆ snd_bgm_enqueue_legacy_command()

void snd_bgm_enqueue_legacy_command ( u32 cmd)

Unused Part of an unused system for inter-thread communication with a BGM player using commands.

Use functions in bgm_control to manipualte gMusicControlData instead.

Definition at line 159 of file snd_interface.c.

159 {
160 BGMPlayer* player = NULL;
161 u32 playerID = cmd & 0xF;
162
163 if (playerID == 0) {
164 return;
165 } else if (playerID == 1) {
166 player = gBGMPlayerA;
167 } else if (playerID == 2) {
168 player = gBGMPlayerB;
169 }
170
171 if (player != NULL) {
172 u32 pos;
173
174 if (player->cmdBufPending < ARRAY_COUNT(player->cmdBufData)) {
175 pos = player->cmdBufWritePos;
176
177 player->cmdBufData[pos] = cmd >> 4;
178
179 pos++;
180 if (pos >= 8) {
181 pos = 0;
182 }
183 player->cmdBufWritePos = pos;
184
185 player->cmdBufPending++;
186 } else {
187 pos = player->cmdBufOverflows + 1;
188
189 if (pos > 99) {
190 pos = 99;
191 }
192 player->cmdBufOverflows = pos;
193 }
194 }
195}
u8 cmdBufPending
Buffer for an unused (legacy) system for controlling the BGMPlayer from the main thread.
Definition audio.h:1213
BGMPlayer * gBGMPlayerB
Definition engine.c:7
BGMPlayer * gBGMPlayerA
Definition engine.c:6
s32 cmdBufData[8]
Definition audio.h:1212
u8 cmdBufWritePos
Definition audio.h:1215
u8 cmdBufOverflows
Definition audio.h:1216
Vec3s pos
Definition demo_api.c:17
#define ARRAY_COUNT(arr)
Definition macros.h:40

◆ snd_start_sound()

void snd_start_sound ( s32 soundID,
u8 volume,
u8 pan )

Definition at line 197 of file snd_interface.c.

197 {
198 SoundManager* soundManager = gSoundManager;
199 s16 vol = volume << 8;
200
201 if (vol != 0) {
202 vol |= 0xFF;
203 }
204
205 if (pan > AU_PAN_MAX) {
206 pan = AU_PAN_MAX;
207 }
208
209 au_sfx_enqueue_event(soundManager, soundID, vol, 0, pan);
210}
SoundManager * gSoundManager
Definition engine.c:9
#define AU_PAN_MAX
Definition audio.h:67
void au_sfx_enqueue_event(SoundManager *manager, u32 soundID, s16 volume, s16 pitchShift, u8 pan)
Definition sfx_player.c:590

◆ snd_start_sound_with_shift()

void snd_start_sound_with_shift ( s32 soundID,
u8 volume,
u8 pan,
s16 pitchShift )

Definition at line 212 of file snd_interface.c.

212 {
213 SoundManager* soundManager = gSoundManager;
214 s16 vol = volume << 8;
215
216 if (vol != 0) {
217 vol |= 0xFF;
218 }
219
220 if (pan > AU_PAN_MAX) {
221 pan = AU_PAN_MAX;
222 }
223
224 if (pitchShift > 2 * AU_OCTAVE_CENTS) {
225 pitchShift = 2 * AU_OCTAVE_CENTS;
226 } else if (pitchShift < -2 * AU_OCTAVE_CENTS) {
227 pitchShift = -2 * AU_OCTAVE_CENTS;
228 }
229
230 au_sfx_enqueue_event(soundManager, soundID, vol, pitchShift, pan);
231}
#define AU_OCTAVE_CENTS
Definition audio.h:114

Referenced by sfx_clear_env_sounds(), sfx_play_sound_looping(), sfx_play_sound_with_params(), and snd_legacy_sound_dispatch().

◆ snd_adjust_sound()

void snd_adjust_sound ( s32 soundID,
u8 volume,
u8 pan )

Definition at line 233 of file snd_interface.c.

233 {
234 SoundManager* soundManager = gSoundManager;
235 s16 vol = volume << 8;
236
237 if (vol != 0) {
238 vol |= 0xFF;
239 }
240
241 if (pan > AU_PAN_MAX) {
242 pan = AU_PAN_MAX;
243 }
244
245 au_sfx_enqueue_event(soundManager, soundID | SOUND_ID_ADJUST, vol, 0, pan);
246}
@ SOUND_ID_ADJUST
Definition enums.h:529

◆ snd_adjust_sound_with_shift()

void snd_adjust_sound_with_shift ( s32 soundID,
u8 volume,
u8 pan,
s16 pitchShift )

Definition at line 248 of file snd_interface.c.

248 {
249 SoundManager* soundManager = gSoundManager;
250 s16 vol = volume << 8;
251
252 if (vol != 0) {
253 vol |= 0xFF;
254 }
255
256 if (pan > AU_PAN_MAX) {
257 pan = AU_PAN_MAX;
258 }
259
260 if (pitchShift > 2 * AU_OCTAVE_CENTS) {
261 pitchShift = 2 * AU_OCTAVE_CENTS;
262 } else if (pitchShift < -2 * AU_OCTAVE_CENTS) {
263 pitchShift = -2 * AU_OCTAVE_CENTS;
264 }
265
266 au_sfx_enqueue_event(soundManager, soundID | SOUND_ID_ADJUST, vol, pitchShift, pan);
267}

Referenced by sfx_adjust_env_sound_params(), and sfx_update_env_sound_params().

◆ snd_stop_sound()

void snd_stop_sound ( s32 soundID)

Definition at line 269 of file snd_interface.c.

269 {
270 SoundManager* soundManager = gSoundManager;
271
272 au_sfx_enqueue_event(soundManager, soundID | SOUND_ID_STOP, 0, 0, 0);
273}
@ SOUND_ID_STOP
Definition enums.h:526

Referenced by action_update_sliding(), sfx_stop_env_sounds(), sfx_stop_sound(), and sfx_stop_tracking_env_sound_pos().

◆ snd_reset()

void snd_reset ( void )

Definition at line 275 of file snd_interface.c.

275 {
277}
s32 resetPending
Definition audio.h:816

◆ snd_start_sound_raw()

void snd_start_sound_raw ( s32 soundID,
s16 volume,
s16 pitchShift,
s32 pan )

Definition at line 279 of file snd_interface.c.

279 {
280 SoundManager* soundManager = gSoundManager;
281
282 au_sfx_enqueue_event(soundManager, soundID, volume, pitchShift, pan);
283}

◆ snd_load_ambient()

AuResult snd_load_ambient ( s32 arg0)

Definition at line 285 of file snd_interface.c.

285 {
287}
AuResult au_ambient_load(u32 arg0)
Definition engine.c:665

Referenced by update_ambient_sounds().

◆ snd_ambient_play()

AuResult snd_ambient_play ( s32 arg0,
s32 arg1 )

Definition at line 289 of file snd_interface.c.

289 {
290 AuResult status = au_mseq_check_player_index(index);
291
292 if (status != AU_RESULT_OK) {
293 return status;
294 }
295 return au_mseq_start(index, fadeInTime);
296}
AuResult
Definition enums.h:1758
@ AU_RESULT_OK
Definition enums.h:1759
AuResult au_mseq_start(s32 index, s32 time)
Definition mseq_player.c:88
AuResult au_mseq_check_player_index(u32 index)
Definition mseq_player.c:65

Referenced by snd_ambient_radio_setup(), and update_ambient_sounds().

◆ snd_ambient_stop_quick()

AuResult snd_ambient_stop_quick ( s32 arg0)

Definition at line 298 of file snd_interface.c.

298 {
299 AuResult status = au_mseq_check_player_index(index);
300
301 if (status == AU_RESULT_OK) {
302 au_mseq_stop_quick(index);
303 }
304
305 return status;
306}
void au_mseq_stop_quick(s32 index)

Referenced by play_ambient_sounds(), snd_ambient_radio_stop(), and update_ambient_sounds().

◆ snd_ambient_stop_slow()

AuResult snd_ambient_stop_slow ( s32 arg0,
s32 arg1 )

Definition at line 308 of file snd_interface.c.

308 {
309 AuResult status = au_mseq_check_player_index(index);
310
311 if (status == AU_RESULT_OK) {
312 au_mseq_stop_slow(index, fadeOutTime);
313 }
314
315 return status;
316}
void au_mseq_stop_slow(s32 index, s32 time)

Referenced by snd_ambient_radio_stop(), and update_ambient_sounds().

◆ snd_ambient_pause()

AuResult snd_ambient_pause ( s32 arg0,
s32 arg1 )

Definition at line 318 of file snd_interface.c.

318 {
319 AuResult status = au_mseq_check_player_index(index);
320
321 if (status == AU_RESULT_OK) {
322 au_mseq_pause(index, fadeOutTime);
323 }
324
325 return status;
326}
void au_mseq_pause(s32 index, s32 time)

Referenced by bgm_push_battle_song().

◆ snd_ambient_resume()

AuResult snd_ambient_resume ( s32 arg0,
s32 arg1 )

Definition at line 328 of file snd_interface.c.

328 {
329 AuResult status = au_mseq_check_player_index(index);
330
331 if (status == AU_RESULT_OK) {
332 au_mseq_resume(index, fadeInTime);
333 }
334
335 return status;
336}
void au_mseq_resume(s32 index, s32 time)

Referenced by bgm_pop_battle_song().

◆ snd_ambient_is_stopped()

AuResult snd_ambient_is_stopped ( s32 arg0)

Definition at line 338 of file snd_interface.c.

338 {
339 AuResult status = au_mseq_check_player_index(index);
340
341 if (status != AU_RESULT_OK) {
342 return status;
343 }
344 return au_mseq_check_stopped(index);
345}
AuResult au_mseq_check_stopped(s32 index)

Referenced by update_ambient_sounds().

◆ snd_ambient_fade_out()

AuResult snd_ambient_fade_out ( s32 arg0,
s32 arg1 )

Definition at line 347 of file snd_interface.c.

347 {
348 AuResult status = au_mseq_check_player_index(index);
349
350 if (status == AU_RESULT_OK) {
351 au_mseq_load_tracks_fade(index, arg1);
352 }
353
354 return status;
355}
void au_mseq_load_tracks_fade(s32 arg0, s32 arg1)
Definition mseq_player.c:73

◆ snd_ambient_set_volume()

AuResult snd_ambient_set_volume ( s32 arg0,
s32 arg1,
s32 arg2 )

Definition at line 357 of file snd_interface.c.

357 {
358 AuResult status = au_mseq_check_player_index(index);
359
360 if (status == AU_RESULT_OK) {
361 au_mseq_set_volume(index, time, volume);
362 }
363
364 return status;
365}
void au_mseq_set_volume(s32 index, s32 time, s32 volume)

◆ snd_ambient_disable()

AuResult snd_ambient_disable ( s32 arg0)

Definition at line 367 of file snd_interface.c.

367 {
368 AuResult status = au_mseq_check_player_index(index);
369
370 if (status == AU_RESULT_OK) {
372 }
373
374 return status;
375}
void au_mseq_set_disabled(s32 index, s32 disable)
Definition mseq_player.c:77

Referenced by snd_ambient_radio_select().

◆ snd_ambient_enable()

AuResult snd_ambient_enable ( s32 arg0)

Definition at line 377 of file snd_interface.c.

377 {
378 AuResult status = au_mseq_check_player_index(index);
379
380 if (status == AU_RESULT_OK) {
382 }
383
384 return status;
385}

Referenced by snd_ambient_radio_select().

◆ snd_ambient_radio_setup()

void snd_ambient_radio_setup ( s32 arg0)

Definition at line 387 of file snd_interface.c.

387 {
388 s32 radioChannels = 4;
389 u32 i;
390
392
393 for (i = 0; i < radioChannels; i++) {
394 if (snd_ambient_play(i, 0) != AU_RESULT_OK) {
395 return;
396 }
397 }
398
400}
u16 AmbienceRadioChannel
AuResult snd_ambient_play(s32 index, s32 fadeInTime)
AuResult snd_ambient_radio_select(s32 index)

◆ snd_ambient_radio_stop()

AuResult snd_ambient_radio_stop ( s32 arg0)

Definition at line 402 of file snd_interface.c.

402 {
403 AuResult status = AU_RESULT_OK;
404 s32 radioChannels = 4;
405 u32 i;
406
407 for (i = 0; i < radioChannels; i++) {
408 if (i == AmbienceRadioChannel) {
409 status = snd_ambient_stop_slow(i, time);
410 } else {
411 status = snd_ambient_stop_quick(i);
412 }
413 if (status != AU_RESULT_OK) {
414 break;
415 }
416 }
417 return status;
418}
AuResult snd_ambient_stop_slow(s32 index, s32 fadeOutTime)
AuResult snd_ambient_stop_quick(s32 index)

◆ snd_ambient_radio_select()

AuResult snd_ambient_radio_select ( s32 arg0)

Definition at line 420 of file snd_interface.c.

420 {
421 AuResult status = AU_RESULT_OK;
422 s32 radioChannels = 4;
423
424 if (index != AmbienceRadioChannel) {
425 u32 i;
426
427 for (i = 0; i < radioChannels; i++) {
428 if (i == index) {
429 status = snd_ambient_enable(i);
430 } else {
431 status = snd_ambient_disable(i); // mute
432 }
433
434 if (status != AU_RESULT_OK) {
435 break;
436 }
437 }
438
439 if (status == AU_RESULT_OK) {
440 AmbienceRadioChannel = index;
441 }
442 }
443
444 return status;
445}
AuResult snd_ambient_disable(s32 index)
AuResult snd_ambient_enable(s32 index)

Referenced by snd_ambient_radio_setup().

◆ snd_song_load()

AuResult snd_song_load ( s32 songID,
s32 playerIndex )

return value may be either an AuResult error code OR a valid songName

Definition at line 447 of file snd_interface.c.

447 {
448 BGMHeader* bgmFile;
449 BGMPlayer* player;
450
451 au_get_bgm_player_and_file(playerIndex, &bgmFile, &player);
452
453 if (bgmFile != NULL) {
454 return au_load_song_files(songID, bgmFile, player);
455 } else {
457 }
458}
AuResult au_load_song_files(u32 arg0, BGMHeader *arg1, BGMPlayer *arg2)
Definition engine.c:558
void au_get_bgm_player_and_file(u32 playerIndex, BGMHeader **outCurrentTrackData, BGMPlayer **outPlayer)
Definition engine.c:518
@ AU_ERROR_NULL_SONG_NAME
Definition enums.h:1766

Referenced by bgm_update_music_control(), and snd_legacy_sound_dispatch().

◆ snd_song_request_play_default()

AuResult snd_song_request_play_default ( s32 songName)

Unused – snd_song_request_play but always uses BGM_VARIATION_0.

Definition at line 461 of file snd_interface.c.

461 {
462 AuResult status;
464
466 s.songName = songName;
467 s.duration = 0;
471 s.unused_14 = 0;
472 status = au_bgm_process_init_song(&s);
474
475 return status;
476}
#define AU_MAX_VOLUME_8
Definition audio.h:61
AuResult au_bgm_process_init_song(SongStartRequest *request)
Definition bgm_player.c:135
@ BGM_VARIATION_0
Definition enums.h:1805

◆ snd_song_request_play()

AuResult snd_song_request_play ( s32 songName,
s32 variation )

Called from bgm_control to start playing a particular song + variation.

Definition at line 479 of file snd_interface.c.

479 {
480 AuResult status;
482
484 s.songName = songName;
485 s.duration = 0;
488 s.variation = variation;
489 s.unused_14 = 0;
490 status = au_bgm_process_init_song(&s);
492
493 return status;
494}

Referenced by bgm_update_music_control(), and snd_legacy_sound_dispatch().

◆ snd_song_stop()

AuResult snd_song_stop ( s32 songName)

Definition at line 496 of file snd_interface.c.

496 {
497 return au_bgm_stop_song(songName);
498}
AuResult au_bgm_stop_song(s32 songName)
Definition bgm_player.c:227

Referenced by _bgm_set_song(), bgm_fade_in_song(), and bgm_update_music_control().

◆ snd_song_stop_all()

void snd_song_stop_all ( void )

Definition at line 500 of file snd_interface.c.

500 {
502}
void au_bgm_stop_all(void)
Definition bgm_player.c:247

◆ snd_song_is_playing()

AuResult snd_song_is_playing ( s32 songName)

Definition at line 504 of file snd_interface.c.

504 {
505 return au_bgm_is_song_playing(songName);
506}
AuResult au_bgm_is_song_playing(s32 songName)
Definition bgm_player.c:261

Referenced by bgm_is_any_song_playing(), and bgm_update_music_control().

◆ snd_song_request_fade_in()

AuResult snd_song_request_fade_in ( s32 songName,
s32 variation,
s32 fadeInTime,
s32 startVolume,
s32 endVolume )

Called from bgm_control to fade in a particular song + variation.

Definition at line 509 of file snd_interface.c.

509 {
510 AuResult status;
512
514 s.songName = songName;
515 s.duration = fadeInTime;
516 s.startVolume = startVolume;
518 s.variation = variation;
519 s.unused_14 = 0;
520 status = au_bgm_process_init_song(&s);
522
523 return status;
524}

Referenced by bgm_update_music_control().

◆ snd_song_request_fade_in_default()

AuResult snd_song_request_fade_in_default ( s32 songName,
s32 fadeInTime,
s32 startVolume,
s32 endVolume )

Unused.

Definition at line 527 of file snd_interface.c.

527 {
528 AuResult status;
530
532 s.songName = songName;
533 s.duration = fadeInTime;
534 s.startVolume = startVolume;
536 s.variation = 0;
537 s.unused_14 = 0;
538 status = au_bgm_process_init_song(&s);
540
541 return status;
542}

◆ snd_song_request_fade_out()

AuResult snd_song_request_fade_out ( s32 songName,
s32 fadeTime,
AuCallback callback )

Definition at line 544 of file snd_interface.c.

544 {
546
547 s.songName = songName;
548 s.duration = fadeTime;
549 s.unused_08 = 0;
550 s.finalVolume = 0;
551 s.doneCallback = callback;
552 s.onPush = FALSE;
553
554 return au_bgm_process_fade_out(&s);
555}
AuCallback doneCallback
Definition audio.h:1239
AuResult au_bgm_process_fade_out(SongFadeOutRequest *request)
Definition bgm_player.c:287

Referenced by bgm_update_music_control().

◆ snd_song_push_stop()

AuResult snd_song_push_stop ( s32 songName)

Definition at line 557 of file snd_interface.c.

557 {
559
560 s.songName = songName;
561 s.duration = 0;
562 s.startVolume = 0;
563 s.finalVolume = 0;
565 s.pauseMode = FALSE;
566
567 return au_bgm_process_suspend(&s, FALSE); // force stop
568}
@ BGM_SNAPSHOT_0
Definition audio.h:192
AuResult au_bgm_process_suspend(SongSuspendRequest *request, b32 skipStop)
Definition bgm_player.c:337

Referenced by bgm_update_music_control().

◆ snd_song_request_pop()

AuResult snd_song_request_pop ( s32 songName)

Definition at line 570 of file snd_interface.c.

570 {
571 AuResult status;
573
575 s.songName = songName;
576 s.duration = 2000;
577 s.startVolume = 1;
580 s.pauseMode = FALSE;
581 status = au_bgm_process_resume(&s);
583
584 return status;
585}
AuResult au_bgm_process_resume(SongResumeRequest *request)
Definition bgm_player.c:395

Referenced by bgm_update_music_control().

◆ snd_song_request_snapshot()

AuResult snd_song_request_snapshot ( s32 songName)

Definition at line 587 of file snd_interface.c.

587 {
589
590 s.songName = songName;
591 s.duration = 0;
592 s.startVolume = 0;
593 s.finalVolume = 0;
595 s.pauseMode = FALSE;
596
597 return au_bgm_process_suspend(&s, TRUE); // no stop
598}

Referenced by _bgm_set_song().

◆ snd_song_request_push_fade_out()

AuResult snd_song_request_push_fade_out ( s32 songName,
s32 fadeTime )

Definition at line 600 of file snd_interface.c.

600 {
602
603 s.songName = songName;
604 s.duration = fadeTime;
605 s.unused_08 = 0;
606 s.finalVolume = 0;
607 s.doneCallback = NULL;
608 s.onPush = TRUE;
609
610 return au_bgm_process_fade_out(&s);
611}

Referenced by bgm_update_music_control().

◆ snd_song_request_pause()

AuResult snd_song_request_pause ( s32 songName)

Definition at line 613 of file snd_interface.c.

613 {
615
616 s.songName = songName;
617 s.duration = 0;
618 s.startVolume = 0;
619 s.finalVolume = 0;
621 s.pauseMode = TRUE;
622
623 return au_bgm_process_suspend(&s, FALSE); // force stop
624}

◆ snd_song_request_unpause()

AuResult snd_song_request_unpause ( s32 songName)

Definition at line 626 of file snd_interface.c.

626 {
628
629 s.songName = songName;
630 s.duration = 0;
631 s.startVolume = 0;
632 s.finalVolume = 0;
634 s.pauseMode = TRUE;
635
636 return au_bgm_process_resume(&s);
637}

◆ snd_song_set_volume_quiet()

AuResult snd_song_set_volume_quiet ( s32 songName)

Definition at line 639 of file snd_interface.c.

639 {
641
642 s.songName = songName;
643 s.duration = 500;
644 s.finalVolume = 0.25001 * AU_MAX_VOLUME_16;
645
646 return au_bgm_adjust_volume(&s);
647}
#define AU_MAX_VOLUME_16
Definition audio.h:62
AuResult au_bgm_adjust_volume(SongStartRequest *request)
Definition bgm_player.c:505

◆ snd_song_set_volume_full()

AuResult snd_song_set_volume_full ( s32 songName)

Definition at line 649 of file snd_interface.c.

649 {
651
652 s.songName = songName;
653 s.duration = 500;
655
656 return au_bgm_adjust_volume(&s);
657}

◆ snd_song_set_linked_mode()

AuResult snd_song_set_linked_mode ( s32 songName,
b32 mode )

Definition at line 659 of file snd_interface.c.

659 {
661
662 s.songName = songName;
663 s.enabled = mode;
664
665 return au_bgm_set_linked_tracks(&s);
666}
AuResult au_bgm_set_linked_tracks(SongSwapLinkedRequest *request)

Referenced by bgm_set_linked_mode().

◆ snd_song_set_playback_rate()

AuResult snd_song_set_playback_rate ( s32 songName,
f32 arg1 )

Definition at line 689 of file snd_interface.c.

689 {
690 BGMPlayer* bgmPlayer;
691 BGMHeader* bgmFile;
692 AuResult status;
693
694 status = snd_song_get_playing_info(songName, &bgmFile, &bgmPlayer);
695
696 if (status == AU_RESULT_OK) {
697 au_bgm_set_playback_rate(bgmPlayer, rate);
698 }
699
700 return status;
701}
void au_bgm_set_playback_rate(BGMPlayer *player, f32 rate)
AuResult snd_song_get_playing_info(s32 songName, BGMHeader **outFile, BGMPlayer **outPlayer)

◆ snd_song_poll_music_events()

void snd_song_poll_music_events ( u32 ** arg0,
s32 * arg1 )

Definition at line 832 of file snd_interface.c.

832 {
833 AuGlobals* globals = gSoundGlobals;
834
835 *musicEvents = globals->musicEventQueue;
836 *count = globals->musicEventQueueCount;
837}
MusicEventTrigger * musicEventQueue
Definition audio.h:1058
AuGlobals * gSoundGlobals
Definition engine.c:10
u32 musicEventQueueCount
Definition audio.h:1059

◆ snd_song_flush_music_events()

void snd_song_flush_music_events ( void )

Definition at line 839 of file snd_interface.c.

839 {
841}
s32 flushMusicEventQueue
Definition audio.h:1060

◆ snd_song_trigger_music_event()

void snd_song_trigger_music_event ( s32 playerID,
s32 trackIndex,
s32 eventInfo )

Definition at line 843 of file snd_interface.c.

843 {
844 AuGlobals* globals = gSoundGlobals;
845
846 if (globals->musicEventQueueCount < MUS_QUEUE_SIZE) {
847 *globals->musicEventQueuePos++ = ((playerID << 28) + ((trackIndex & 0xF) << 24) + eventInfo);
848 globals->musicEventQueueCount++;
849 }
850}
#define MUS_QUEUE_SIZE
Definition audio.h:107
MusicEventTrigger * musicEventQueuePos
Definition audio.h:1057

Referenced by au_BGMCmd_FD_EventTrigger().

◆ snd_song_clear_music_events()

void snd_song_clear_music_events ( void )

Definition at line 852 of file snd_interface.c.

852 {
853 AuGlobals* globals = gSoundGlobals;
854 s32* buf = globals->musicEventQueue;
855 s32 i = 15;
856
857 do {
858 *buf++ = 0;
859 } while (i-- != 0);
860
861 globals->musicEventQueueCount = 0;
862 globals->flushMusicEventQueue = FALSE;
863 globals->musicEventQueuePos = globals->musicEventQueue;
864}

Referenced by au_engine_init(), and au_update_clients_for_video_frame().

◆ snd_set_stereo()

void snd_set_stereo ( void )

Definition at line 872 of file snd_interface.c.

872 {
875}
void au_sync_channel_delay_enabled(u32 arg0)
Definition engine.c:1192
void au_set_stereo_enabled(b8 enabled)
Definition syn_driver.c:284

Referenced by filemenu_main_handle_input(), and state_step_startup().

◆ snd_set_mono()

void snd_set_mono ( void )

Definition at line 877 of file snd_interface.c.

Referenced by filemenu_main_handle_input(), and state_step_startup().

◆ snd_set_bgm_volume()

void snd_set_bgm_volume ( VolumeLevels volume)

Definition at line 882 of file snd_interface.c.

882 {
884}
@ AUDIO_TYPE_BGM
Definition audio.h:398
void au_set_bus_volume_level(s32 arg0, u32 idx)
Definition engine.c:1169

Referenced by bgm_reset_sequence_players(), and bgm_update_volume().

◆ snd_set_sfx_volume()

void snd_set_sfx_volume ( VolumeLevels volume)

Definition at line 886 of file snd_interface.c.

886 {
888}
@ AUDIO_TYPE_SFX
Definition audio.h:399

◆ snd_set_sfx_reverb_type()

void snd_set_sfx_reverb_type ( s32 arg0)

Definition at line 890 of file snd_interface.c.

890 {
892}
s32 au_set_reverb_type(s32 arg0, s32 arg1)
Definition engine.c:1185

Referenced by sfx_set_reverb_mode().

◆ snd_enable_sfx()

void snd_enable_sfx ( void )

Definition at line 894 of file snd_interface.c.

894 {
896}
@ SND_MANAGER_STATE_ENABLED
Definition audio.h:364
void au_sfx_set_state(SoundManager *manager, s32 arg1)
Definition sfx_player.c:739

Referenced by state_step_demo().

◆ snd_disable_sfx()

void snd_disable_sfx ( void )

Definition at line 898 of file snd_interface.c.

898 {
900}
@ SND_MANAGER_STATE_DISABLED
Definition audio.h:365

Referenced by state_init_demo().

◆ bgm_set_track_volumes()

AuResult bgm_set_track_volumes ( s32 playerIndex,
s16 trackVolSet )

Definition at line 294 of file bgm_control.c.

294 {
296
297 if (!(music->flags & MUSIC_FLAG_PLAYING)) {
298 return AU_RESULT_OK;
299 }
300
302}
@ MUSIC_FLAG_PLAYING
Definition audio.h:183
MusicControlData gMusicControlData[2]
Definition bgm_control.c:13
AuResult snd_song_set_track_volumes(s32 songName, MusicTrackVols arg1)

◆ bgm_clear_track_volumes()

AuResult bgm_clear_track_volumes ( s32 playerIndex,
s16 trackVolSet )

Definition at line 304 of file bgm_control.c.

304 {
306
307 if (!(music->flags & MUSIC_FLAG_PLAYING)) {
308 return AU_RESULT_OK;
309 }
310
312}
AuResult snd_song_clear_track_volumes(s32 songName, MusicTrackVols arg1)

◆ bgm_set_linked_mode()

AuResult bgm_set_linked_mode ( s32 playerIndex,
b16 mode )

Definition at line 314 of file bgm_control.c.

314 {
316
317 if (!(music->flags & MUSIC_FLAG_PLAYING)) {
318 return AU_RESULT_OK;
319 }
320
321 return snd_song_set_linked_mode(music->songName, mode);
322}
AuResult snd_song_set_linked_mode(s32 songName, b32 mode)

◆ bgm_quiet_max_volume()

void bgm_quiet_max_volume ( void )

Definition at line 331 of file bgm_control.c.

331 {
333}
BSS s16 MusicMaxVolume
Definition bgm_control.c:10
@ VOL_LEVEL_4
Definition enums.h:1818

Referenced by state_step_pause().

◆ bgm_reset_max_volume()

void bgm_reset_max_volume ( void )

Definition at line 335 of file bgm_control.c.

335 {
337}
@ VOL_LEVEL_FULL
Definition enums.h:1822

Referenced by state_step_unpause().

◆ bgm_reset_volume()

void bgm_reset_volume ( void )

Definition at line 77 of file bgm_control.c.

77 {
80}
BSS s16 MusicTargetVolume
Definition bgm_control.c:9

Referenced by state_step_startup().

◆ bgm_init_music_players()

s32 bgm_init_music_players ( void )

Definition at line 324 of file bgm_control.c.

324 {
327
328 return 1;
329}
#define AU_SONG_NONE
Definition audio.h:105
s32 bgm_set_song(s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime, s16 volume)

Referenced by state_step_startup().

◆ bgm_set_song()

s32 bgm_set_song ( s32 playerIndex,
s32 songID,
s32 variation,
s32 fadeOutTime,
s16 volume )

Definition at line 230 of file bgm_control.c.

230 {
232
233 return _bgm_set_song(playerIndex, songID, variation, fadeOutTime, volume);
234}
s32 _bgm_set_song(s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime, s16 volume)

Referenced by bgm_init_music_players(), bgm_push_battle_song(), bgm_push_song(), btl_state_update_celebration(), btl_state_update_defeat(), btl_state_update_end_training_battle(), btl_state_update_run_away(), btl_state_update_victory(), state_init_exit_file_select(), state_init_title_screen(), and state_step_title_screen().

◆ bgm_set_battle_song()

void bgm_set_battle_song ( s32 songID,
s32 variation )

Definition at line 431 of file bgm_control.c.

431 {
433
434 music->battleSongID = songID;
435 music->battleVariation = variation;
436}
s32 battleSongID
name or handle of currently playing song

Referenced by update_encounters_pre_battle().

◆ bgm_push_battle_song()

void bgm_push_battle_song ( void )

Definition at line 416 of file bgm_control.c.

416 {
418
421 snd_ambient_pause(0, 250);
422 music->savedSongID = music->requestedSongID;
423 music->savedVariation = music->variation;
424 music->savedSongName = music->songName;
425 music->flags |= MUSIC_FLAG_PUSHING;
426 bgm_set_song(0, music->battleSongID, music->battleVariation, 500, VOL_LEVEL_FULL);
427 }
428 }
429}
@ MUSIC_FLAG_PUSHING
Definition audio.h:185
@ DEMO_STATE_NONE
Definition enums.h:3568
@ GLOBAL_OVERRIDES_DONT_RESUME_SONG_AFTER_BATTLE
Definition enums.h:3921
AuResult snd_ambient_pause(s32 arg0, s32 arg1)
s32 gOverrideFlags
Definition main_loop.c:10
GameStatus * gGameStatusPtr
Definition main_loop.c:31

Referenced by update_encounters_pre_battle().

◆ bgm_adjust_proximity()

s32 bgm_adjust_proximity ( s32 playerIndex,
s32 arg1,
s16 arg2 )

Definition at line 269 of file bgm_control.c.

269 {
271
272 if (!(music->flags & MUSIC_FLAG_PLAYING)) {
273 return FALSE;
274 }
275
276 if (!(music->flags & MUSIC_FLAG_ENABLE_PROX_MIX)) {
277 return FALSE;
278 }
279
280 switch (state) {
283 break;
286 break;
289 break;
290 }
291 return TRUE;
292}
@ MUSIC_FLAG_ENABLE_PROX_MIX
Definition audio.h:184
@ MUSIC_PROXIMITY_NEAR
Definition enums.h:1789
@ MUSIC_PROXIMITY_FULL
Definition enums.h:1790
@ MUSIC_PROXIMITY_FAR
Definition enums.h:1788
void snd_song_set_proximity_mix_far(s32 songName, s32 mix)
void snd_song_set_proximity_mix_near(s32 songName, s32 mix)
void snd_song_set_proximity_mix_full(s32 songName, s32 mix)

◆ bgm_fade_in_song()

b32 bgm_fade_in_song ( s32 playerIndex,
s32 songID,
s32 variation,
s32 fadeInTime,
s16 arg4,
s16 arg5 )

Definition at line 236 of file bgm_control.c.

236 {
239
241 return TRUE;
242 }
243
244 music = &gMusicControlData[playerIndex];
245
247 snd_song_stop(music->songName);
248 music->flags &= ~MUSIC_FLAG_PLAYING;
249 return TRUE;
250 }
251
253 if (mapSongVariation >= 0) {
254 variation = mapSongVariation;
255 }
256
257 music->fadeInTime = fadeInTime;
258 music->fadeStartVolume = fadeStartVolume;
259 music->fadeEndVolume = fadeEndVolume;
260 music->requestedSongID = songID;
261 music->variation = variation;
265
266 return TRUE;
267}
@ MUSIC_STATE_STOP_CURRENT
Definition audio.h:175
@ MUSIC_FLAG_FADE_IN_NEXT
Definition audio.h:188
s32 bgm_get_map_default_variation(s32 songID)
If the given song ID is present in SongsUsingVariationFlag, returns the current map's songVariation &...
Definition bgm_control.c:50
AuResult snd_song_stop(s32 songName)

◆ bgm_update_music_control()

void bgm_update_music_control ( void )
Bug
this is called even if we are trying to fade in, immediately overriding any fade parameters

Definition at line 83 of file bgm_control.c.

83 {
85 s32 i = 0;
88 s32 flags;
89
90 for (i; i < ARRAY_COUNT(gMusicControlData); i++, music++) {
91 switch (music->state) {
93 break;
95 if (music->flags & MUSIC_FLAG_PLAYING) {
96 if (music->fadeOutTime < 250) {
97 if (!(music->flags & MUSIC_FLAG_PUSHING)) {
98 if (snd_song_stop(music->songName) == AU_RESULT_OK) {
100 }
101 } else {
102 if (snd_song_push_stop(music->songName) == AU_RESULT_OK) {
103 music->state = stateFadeOut;
104 }
105 }
106 } else if (!(music->flags & MUSIC_FLAG_PUSHING)) {
107 if (snd_song_request_fade_out(music->songName, music->fadeOutTime, NULL) == AU_RESULT_OK) {
108 music->state = stateFadeOut;
109 }
110 } else {
111 if (snd_song_request_push_fade_out(music->songName, 250) == AU_RESULT_OK) {
112 music->state = stateFadeOut;
113 }
114 }
115 } else {
116 if (music->flags & MUSIC_FLAG_PUSHING) {
117 // nothing was playing in this case, so remember to skip the next pop
119 }
120 music->flags &= ~pushedFlag;
122 }
123 break;
125 flags = music->flags;
126 music->flags &= ~pushedFlag;
128 if (snd_song_is_playing(music->songName) == AU_RESULT_OK) {
129 music->flags &= ~MUSIC_FLAG_PLAYING;
130 music->state = MUSIC_STATE_DELAY_2;
131 }
132 } else {
134 }
135 break;
137 music->state = MUSIC_STATE_DELAY_1;
138 break;
141 break;
143 if (!(music->flags & MUSIC_FLAG_POPPING)) {
144 if (music->requestedSongID <= AU_SONG_NONE) {
145 // new song is AU_SONG_NONE, play nothing
146 music->state = MUSIC_STATE_IDLE;
147 } else {
148 music->songName = snd_song_load(music->requestedSongID, i);
149 // snd_song_lond may return either songName or an AuResult error code.
150 // since song names are 4-character big-endian identifiers packed into an s32, we require
151 // the upper half of the return value to be nonzero for songs which loaded without error.
152 // this reserves return values from 0 to 0xFFFF for AuResult codes.
153 if (music->songName > 0xFFFFU) {
154 if ((music->flags & MUSIC_FLAG_FADE_IN_NEXT)) {
155 snd_song_request_fade_in(music->songName, music->variation,
156 music->fadeInTime, music->fadeStartVolume, music->fadeEndVolume);
158 } else {
159 // if we aren't fading in, just start at the default volume level
161 }
163 if (snd_song_request_play(music->songName, music->variation) == AU_RESULT_OK) {
164 music->flags |= MUSIC_FLAG_PLAYING;
165 music->state = MUSIC_STATE_IDLE;
166 }
167 }
168 }
169 } else {
170 if (music->flags & MUSIC_FLAG_IGNORE_POP) {
171 music->state = MUSIC_STATE_IDLE;
173 } else if (snd_song_request_pop(music->savedSongName) == AU_RESULT_OK) {
174 music->requestedSongID = music->savedSongID;
175 music->variation = music->savedVariation;
176 music->songName = music->savedSongName;
177 music->state = MUSIC_STATE_IDLE;
178 music->flags |= MUSIC_FLAG_PLAYING;
179 music->flags &= ~MUSIC_FLAG_POPPING;
180 }
181 }
182 break;
183 }
184 }
186}
@ MUSIC_STATE_PLAY_NEXT
Definition audio.h:179
@ MUSIC_STATE_IDLE
Definition audio.h:174
@ MUSIC_STATE_AWAIT_FADEOUT
Definition audio.h:176
@ MUSIC_STATE_DELAY_2
Definition audio.h:177
@ MUSIC_STATE_DELAY_1
Definition audio.h:178
@ MUSIC_FLAG_POPPING
Definition audio.h:186
@ MUSIC_FLAG_IGNORE_POP
Definition audio.h:187
void bgm_update_volume(void)
void bgm_set_target_volume(s32 volume)
BSS s16 MusicDefaultVolume
Definition bgm_control.c:8
s8 flags
Definition demo_api.c:15
AuResult snd_song_push_stop(s32 songName)
AuResult snd_song_request_fade_out(s32 songName, s32 fadeTime, AuCallback callback)
AuResult snd_song_request_play(s32 songName, s32 variation)
Called from bgm_control to start playing a particular song + variation.
AuResult snd_song_request_push_fade_out(s32 songName, s32 fadeTime)
AuResult snd_song_load(s32 songID, s32 playerIndex)
return value may be either an AuResult error code OR a valid songName
AuResult snd_song_request_pop(s32 songName)
AuResult snd_song_request_fade_in(s32 songName, s32 variation, s32 fadeInTime, s32 startVolume, s32 endVolume)
Called from bgm_control to fade in a particular song + variation.
AuResult snd_song_is_playing(s32 songName)

◆ bgm_is_any_song_playing()

b32 bgm_is_any_song_playing ( void )

Definition at line 367 of file bgm_control.c.

367 {
369 s32 i;
370
371 for (i = 0; i < ARRAY_COUNT(gMusicControlData); i++, music++) {
372 if (music->flags & MUSIC_FLAG_PLAYING) {
373 if (snd_song_is_playing(music->songName)) {
374 return TRUE;
375 }
376 }
377 }
378 return FALSE;
379}

◆ bgm_reset_sequence_players()

void bgm_reset_sequence_players ( void )

Definition at line 64 of file bgm_control.c.

64 {
65 s32 i;
66
67 for (i = 0; i < ARRAY_COUNT(gMusicControlData); i++) {
69 }
70
75}
MusicControlData BlankMusicControlData
Definition bgm_control.c:15
BSS s16 MusicCurrentVolume
Definition bgm_control.c:11
void snd_set_bgm_volume(VolumeLevels volume)

◆ bgm_pop_song()

void bgm_pop_song ( void )

Definition at line 381 of file bgm_control.c.

381 {
383
386 _bgm_set_song(0, music->savedSongID, music->savedVariation, 0, VOL_LEVEL_FULL);
387 }
388}

◆ bgm_push_song()

void bgm_push_song ( s32 songID,
s32 variation )

Definition at line 390 of file bgm_control.c.

390 {
392
394 music->savedSongID = music->requestedSongID;
395 music->savedVariation = music->variation;
396 music->savedSongName = music->songName;
397 music->flags |= MUSIC_FLAG_PUSHING;
398 bgm_set_song(0, songID, variation, 500, VOL_LEVEL_FULL);
399 }
400}

◆ bgm_pop_battle_song()

void bgm_pop_battle_song ( void )

Definition at line 402 of file bgm_control.c.

402 {
404
408 } else {
410 _bgm_set_song(0, music->savedSongID, music->savedVariation, 0, VOL_LEVEL_FULL);
411 snd_ambient_resume(0, 250);
412 }
413 }
414}
AuResult snd_ambient_resume(s32 arg0, s32 arg1)

◆ sfx_reset_door_sounds()

void sfx_reset_door_sounds ( void )

Definition at line 299 of file sfx_control.c.

299 {
302}
@ DOOR_SOUNDS_BASIC
Definition enums.h:2393
u16 gCurrentDoorSounds
Definition sfx_control.c:6
u16 gCurrentRoomDoorSounds
Definition sfx_control.c:7

Referenced by load_map_by_IDs(), and sfx_clear_sounds().

◆ sfx_clear_sounds()

void sfx_clear_sounds ( void )

Definition at line 304 of file sfx_control.c.

304 {
305 bzero(&wEnvSounds, sizeof(wEnvSounds));
306 bzero(&bEnvSounds, sizeof(bEnvSounds));
310}
void sfx_set_reverb_mode(s32 mode)
void sfx_reset_door_sounds(void)
BSS SoundInstance wEnvSounds[10]
BSS SoundInstance bEnvSounds[10]
BSS SoundInstance * gCurrentEnvSounds

Referenced by load_engine_data(), and state_step_startup().

◆ sfx_clear_env_sounds()

void sfx_clear_env_sounds ( s16 playSounds)

Definition at line 313 of file sfx_control.c.

313 {
316 } else {
318 }
319
320 if (playSounds) {
322 s32 i;
323
324 for (i = 0; i < MAX_SOUND_INSTANCES; i++, sound++) {
325 if (sound->flags & SOUND_INSTANCE_FLAG_ACTIVE) {
326 snd_start_sound_with_shift(sound->soundID, sound->volume, sound->pan, sound->pitchShift);
327 }
328 }
329 } else {
331 }
332}
s16 pitchShift
Definition audio.h:826
@ SOUND_INSTANCE_FLAG_ACTIVE
Definition audio.h:369
s32 soundID
Definition audio.h:822
@ CONTEXT_WORLD
Definition enums.h:3562
void snd_start_sound_with_shift(s32 soundID, u8 volume, u8 pan, s16 pitchShift)
#define MAX_SOUND_INSTANCES
Definition sfx_control.c:4

Referenced by load_map_by_IDs(), state_step_battle(), state_step_end_battle(), state_step_pause(), and state_step_unpause().

◆ sfx_update_env_sound_params()

void sfx_update_env_sound_params ( void )

Definition at line 334 of file sfx_control.c.

334 {
336 u16 volume;
337 u16 pan;
338 s32 i;
339
340 for (i = 0; i < MAX_SOUND_INSTANCES; i++, sound++) {
341 if (sound->flags & SOUND_INSTANCE_FLAG_ACTIVE) {
343 sfx_get_spatialized_sound_params(sound->pos.x, sound->pos.y, sound->pos.z, &volume, &pan, sound->sourceFlags);
344 sound->volume = volume;
345 sound->pan = pan;
346 }
347 snd_adjust_sound_with_shift(sound->soundID, sound->volume, sound->pan, sound->pitchShift);
348 }
349 }
350}
s32 sourceFlags
Definition audio.h:823
@ SOUND_INSTANCE_FLAG_POSITION_CHANGED
Definition audio.h:370
Vec3f pos
Definition audio.h:827
void snd_adjust_sound_with_shift(s32 soundID, u8 volume, u8 pan, s16 pitchShift)
void sfx_get_spatialized_sound_params(f32 x, f32 y, f32 z, s16 *volume, s16 *pan, s32 flags)

Referenced by step_game_loop().

◆ sfx_set_reverb_mode()

void sfx_set_reverb_mode ( s32 arg0)

Definition at line 352 of file sfx_control.c.

352 {
354 SfxReverbMode = mode;
355}
void snd_set_sfx_reverb_type(s32 arg0)
BSS s32 SfxReverbMode

Referenced by load_map_by_IDs(), sfx_clear_sounds(), state_init_title_screen(), state_step_pause(), and state_step_unpause().

◆ sfx_get_reverb_mode()

s32 sfx_get_reverb_mode ( void )

Definition at line 357 of file sfx_control.c.

357 {
358 return SfxReverbMode;
359}

Referenced by state_step_pause().

◆ sfx_stop_env_sounds()

void sfx_stop_env_sounds ( void )

Definition at line 361 of file sfx_control.c.

361 {
362 SoundInstance* sound;
363 s32 i;
364
367 } else {
369 }
370
371 sound = gCurrentEnvSounds;
372 for (i = 0; i < MAX_SOUND_INSTANCES; i++, sound++) {
373 if (sound->flags & SOUND_INSTANCE_FLAG_ACTIVE) {
374 snd_stop_sound(sound->soundID);
375 }
376 }
377}
void snd_stop_sound(s32 soundID)

Referenced by load_map_by_IDs(), state_step_battle(), state_step_end_battle(), state_step_pause(), and step_game_loop().

◆ sfx_play_sound_looping()

void sfx_play_sound_looping ( s32 soundID,
u8 volume,
u8 pan,
s16 pitchShift )

Definition at line 392 of file sfx_control.c.

392 {
394 s32 i;
395
396 for (i = 0; i < MAX_SOUND_INSTANCES; i++, sound++) {
397 if (!(sound->flags & SOUND_INSTANCE_FLAG_ACTIVE)) {
398 break;
399 }
400 }
401
402 sound->pan = pan;
403 sound->soundID = soundID;
404 sound->volume = volume;
405 sound->pitchShift = pitchShift;
407
408 snd_start_sound_with_shift(soundID, volume, pan, pitchShift);
409}

Referenced by sfx_play_sound_with_params().

◆ sfx_register_looping_sound_at_position()

void sfx_register_looping_sound_at_position ( s32 soundID,
s32 flags,
f32 x,
f32 y,
f32 z )

Definition at line 411 of file sfx_control.c.

411 {
413 s32 i;
414
415 for (i = 0; i < MAX_SOUND_INSTANCES; i++, sound++) {
416 if (!(sound->flags & SOUND_INSTANCE_FLAG_ACTIVE)) {
417 break;
418 }
419 }
420
421 sound->sourceFlags = flags;
422 sound->pos.x = x;
423 sound->pos.y = y;
424 sound->pos.z = z;
425 sound->soundID = soundID;
427
428 sfx_play_sound_at_position(soundID, flags, x, y, z);
429}
#define sfx_play_sound_at_position

Referenced by sfx_play_sound_at_position().

◆ sfx_adjust_env_sound_pos()

s32 sfx_adjust_env_sound_pos ( s32 soundID,
s32 sourceFlags,
f32 x,
f32 y,
f32 z )

Definition at line 431 of file sfx_control.c.

431 {
433
434 if (sound == NULL) {
435 return FALSE;
436 }
437
438 sound->sourceFlags = sourceFlags;
439 sound->pos.x = x;
440 sound->pos.y = y;
441 sound->pos.z = z;
442 sound->soundID = soundID;
444 return TRUE;
445}
SoundInstance * sfx_get_env_sound_instance(s32 soundID)

Referenced by SentinelAI_Descend().

◆ sfx_stop_tracking_env_sound_pos()

void sfx_stop_tracking_env_sound_pos ( s32 soundID,
s32 keepPlaying )

Definition at line 447 of file sfx_control.c.

447 {
449
450 if (sound != NULL) {
452 if (!keepPlaying) {
453 snd_stop_sound(sound->soundID);
454 }
455 }
456}

Referenced by func_802BB34C_E2DC7C(), and sfx_stop_sound().

◆ sfx_play_sound_with_params()

void sfx_play_sound_with_params ( s32 soundID,
u8 volume,
u8 pan,
s16 pitchShift )

Definition at line 458 of file sfx_control.c.

458 {
460
462 return;
463 }
464
465 if (soundID & SOUND_ID_TYPE_FLAG) {
466 s32 soundIndex = soundID & 0xFF;
467 s32 soundType = (soundID & SOUND_ID_TYPE_MASK) >> 0x1C;
468 switch (soundType) {
470 sfx_play_sound_looping(LoopingSounds[soundIndex], volume, pan, pitchShift);
471 return;
473 soundID = OpenCloseSounds[gCurrentDoorSounds][soundIndex];
474 break;
476 soundID = OpenCloseSounds[gCurrentRoomDoorSounds][soundIndex];
477 break;
479 alternatingSet = &AlternatingSounds[soundIndex];
480 if (alternatingSet->curIndex >= alternatingSet->soundCount) {
482 }
483 soundID = alternatingSet->sounds[alternatingSet->curIndex++];
484 break;
485 }
486 }
487 snd_start_sound_with_shift(soundID, volume, pan, pitchShift);
488}
@ SOUND_ID_TYPE_FLAG
Definition enums.h:539
@ SOUND_ID_TYPE_MASK
Definition enums.h:538
@ SOUND_TYPE_ROOM_DOOR
Definition enums.h:545
@ SOUND_TYPE_LOOPING
Definition enums.h:543
@ SOUND_TYPE_EXIT_DOOR
Definition enums.h:544
@ SOUND_TYPE_ALTERNATING
Definition enums.h:546
s32 OpenCloseSounds[][2]
AlternatingSoundSet AlternatingSounds[]
s32 LoopingSounds[]
Definition sfx_control.c:12
void sfx_play_sound_looping(s32 soundID, u8 volume, u8 pan, s16 pitchShift)

Referenced by _update_message(), msg_copy_to_print_buffer(), msg_play_speech_sound(), sfx_play_sound(), sfx_play_sound_at_position(), update(), and update_riding_physics().

◆ sfx_adjust_env_sound_params()

void sfx_adjust_env_sound_params ( s32 soundID,
u8 volume,
u8 pan,
s16 pitchShift )

Definition at line 490 of file sfx_control.c.

490 {
491 SoundInstance* sound;
492
493 if (soundID & SOUND_ID_TYPE_FLAG) {
494 sound = sfx_get_env_sound_instance(LoopingSounds[soundID & 0xFFFF]);
495 if (sound != NULL) {
496 sound->volume = volume;
497 sound->pan = pan;
498 sound->pitchShift = pitchShift;
499 }
500 } else {
501 snd_adjust_sound_with_shift(soundID, volume, pan, pitchShift);
502 }
503}

Referenced by update().

◆ sfx_stop_sound()

void sfx_stop_sound ( s32 soundID)

Definition at line 505 of file sfx_control.c.

505 {
506 s32 sound = soundID;
507
508 if (sound & SOUND_ID_TYPE_FLAG) {
510 } else {
511 snd_stop_sound(sound);
512 }
513}
void sfx_stop_tracking_env_sound_pos(s32 soundID, s32 keepPlaying)

Referenced by action_update_spin(), free(), phys_update_action_state(), pre_battle(), pre_battle(), SentinelAI_LosePlayerInit(), set_action_state(), update(), and update_encounters_pre_battle().

◆ sfx_play_sound()

void sfx_play_sound ( s32 soundID)

Definition at line 515 of file sfx_control.c.

515 {
516 sfx_play_sound_with_params(soundID, 0, 0, 0);
517}
void sfx_play_sound_with_params(s32 soundID, u8 volume, u8 pan, s16 pitchShift)

Referenced by _use_partner_ability(), btl_main_menu_update(), btl_state_update_celebration(), btl_state_update_defeat(), btl_state_update_partner_menu(), btl_state_update_partner_move(), btl_state_update_player_menu(), btl_state_update_player_move(), btl_state_update_run_away(), btl_state_update_select_target(), btl_submenu_moves_update(), btl_submenu_strats_update(), btl_update_ko_status(), calc_player_damage_enemy(), can_open_world_menu(), check_input_open_menus(), check_input_status_bar(), coin_counter_draw_content(), entity_BlueWarpPipe_enter_pipe_init(), entity_Chest_begin_opening(), entity_CymbalPlant_idle(), entity_HeartBlockContent__anim_heal(), entity_HiddenPanel_flip_over(), entity_Padlock_idle(), entity_SaveBlock_show_result_message(), entity_StarBoxLauncher_launch(), entity_WoodenCrate_idle(), filemenu_choose_name_handle_input(), filemenu_main_handle_input(), filemenu_yesno_handle_input(), func_802BB34C_E2DC7C(), func_802BC3E4_E2ED14(), hud_element_update(), inflict_partner_ko(), partner_use_ability(), pause_badges_handle_input(), pause_handle_input(), pause_init(), pause_items_handle_input(), pause_map_handle_input(), pause_partners_handle_input(), pause_spirits_handle_input(), pause_stats_handle_input(), pause_tabs_handle_input(), pause_tutorial_input(), popup_menu_update(), remove_player_buffs(), should_cancel_open_world_menu(), show_popup_menu(), state_step_title_screen(), step_entity_commandlist(), update(), update_encounters_neutral(), update_item_entity_pickup(), update_status_bar(), update_status_damage(), and update_water_block().

◆ sfx_play_sound_at_player()

◆ sfx_play_sound_at_npc()

void sfx_play_sound_at_npc ( s32 soundID,
s32 arg1,
s32 npcID )

Definition at line 525 of file sfx_control.c.

525 {
526 Npc* npc = get_npc_safe(npcID);
527
528 if (npc != NULL) {
529 sfx_play_sound_at_position(soundID, flags, npc->pos.x, npc->pos.y, npc->pos.z);
530 }
531}
Npc * get_npc_safe(s32 npcID)
Definition npc.c:1008
Vec3f pos

Referenced by update_riding_physics().

◆ sfx_play_sound_at_position()

void sfx_play_sound_at_position ( s32 soundID,
s32 flags,
f32 posX,
f32 posY,
f32 posZ )

Definition at line 533 of file sfx_control.c.

533 {
535 s32 id = LoopingSounds[soundID & 0xFFFF];
536
537 sfx_register_looping_sound_at_position(id, flags, posX, posY, posZ);
538 } else {
539 s16 volume;
540 s16 pan;
541
542 sfx_get_spatialized_sound_params(posX, posY, posZ, &volume, &pan, flags);
543 if (volume >= 0) {
544 sfx_play_sound_with_params(soundID, volume, pan, 0);
545 }
546 }
547}
void sfx_register_looping_sound_at_position(s32 soundID, s32 flags, f32 x, f32 y, f32 z)

◆ sfx_get_spatialized_sound_params()

void sfx_get_spatialized_sound_params ( f32 x,
f32 y,
f32 z,
s16 * volume,
s16 * pan,
s32 flags )

Definition at line 549 of file sfx_control.c.

549 {
552
554
555 do {
557 } while (0); // required to match
558
559 switch (spaceMode) {
562 break;
565 break;
566 case SOUND_SPACE_FULL:
568 break;
569 }
570
572 *volume = 0;
573 } else if (paramFlags & SOUND_PARAM_QUIET) {
574 if (*volume < 80) {
575 *volume = 80;
576 }
577 } else if (paramFlags & SOUND_PARAM_MORE_QUIET) {
578 if (*volume < 60) {
579 *volume = 60;
580 }
581 } else if (paramFlags & SOUND_PARAM_MOST_QUIET) {
582 if (*volume < 40) {
583 *volume = 40;
584 }
585 }
586
587 if (*pan < 1) {
588 *pan = 1;
589 }
590 if (*pan > AU_PAN_MAX) {
591 *pan = AU_PAN_MAX;
592 }
593}
@ SOUND_SPACE_PARAMS_MASK
Definition enums.h:1743
@ SOUND_SPACE_MODE_MASK
Definition enums.h:1739
@ SOUND_SPACE_DEFAULT
Definition enums.h:1740
@ SOUND_SPACE_FULL
Definition enums.h:1742
@ SOUND_PARAM_QUIET
Definition enums.h:1750
@ SOUND_SPACE_WITH_DEPTH
Definition enums.h:1741
@ SOUND_PARAM_MUTE
Definition enums.h:1744
@ SOUND_PARAM_MORE_QUIET
Definition enums.h:1749
@ SOUND_PARAM_MOST_QUIET
Definition enums.h:1748
void sfx_compute_spatialized_sound_params_with_depth(f32 x, f32 y, f32 z, s16 *volume, s16 *pan)
void sfx_compute_spatialized_sound_params_ignore_depth(f32 x, f32 y, f32 z, s16 *volume, s16 *pan)
void sfx_compute_spatialized_sound_params_full(f32 x, f32 y, f32 z, s16 *volume, s16 *pan, s32 flags)

Referenced by sfx_play_sound_at_position(), and sfx_update_env_sound_params().

◆ sfx_compute_spatialized_sound_params_ignore_depth()

void sfx_compute_spatialized_sound_params_ignore_depth ( f32 x,
f32 y,
f32 z,
s16 * volume,
s16 * pan )

Definition at line 595 of file sfx_control.c.

595 {
597
599
600 if (screenX > 3000 || screenX < -3000 || screenY > 3000 || screenY < -3000) {
601 *volume = 1;
602 *pan = 0;
603 return;
604 }
605
606 *volume = 127;
607 if (screenX < 0) {
608 *volume = (screenX * 0.3f) + 127.0f;
609 screenX = 0;
610 }
611 if (screenX > SCREEN_WIDTH) {
612 *volume = 127.0f - ((screenX - SCREEN_WIDTH) * 0.3f);
614 }
615
616 if (*volume < 1) {
617 *volume = 1;
618 }
619
621 // 25/75 at screen edge
622 *pan = (screenX * 0.2f) + 32.0f;
623 } else {
624 f32 temp_f20 = ((screenX * 127.0) / SCREEN_WIDTH) - 64.0;
625 *pan = (s32) (temp_f20 * sin_rad(DEG_TO_RAD(fabs(temp_f20) * 90.0 / 64.0))) + 64;
626 }
627}
void get_screen_coords(s32 camID, f32 x, f32 y, f32 z, s32 *screenX, s32 *screenY, s32 *screenZ)
Definition cam_main.c:409
f64 fabs(f64 f)
f32 sin_rad(f32 x)
Definition 43F0.c:711
#define SCREEN_WIDTH
Definition macros.h:109
#define DEG_TO_RAD(deg)
Definition macros.h:146
s32 gCurrentCameraID
Definition cam_math.c:5

Referenced by sfx_get_spatialized_sound_params().

◆ sfx_compute_spatialized_sound_params_with_depth()

void sfx_compute_spatialized_sound_params_with_depth ( f32 x,
f32 y,
f32 z,
s16 * volume,
s16 * pan )

Definition at line 629 of file sfx_control.c.

629 {
632 f32 depth;
633
635
636 if (screenX > 3000 || screenX < -3000 || screenY > 3000 || screenY < -3000) {
637 *volume = 1;
638 *pan = 0;
639 return;
640 }
641
642 *volume = 127;
643 if (screenX < 0) {
644 *volume = (screenX * 0.3f) + 127.0f;
645 screenX = 0;
646 }
647 if (camera->viewportW < screenX) {
648 *volume = 127.0f - ((screenX - camera->viewportW) * 0.3f);
649 screenX = camera->viewportW;
650 }
651
652 depth = fabsf(5000 - screenZ);
653 if (depth > 1000.0f) {
654 depth = 1000.0f;
655 }
656
657 *volume = *volume * (1500.0f - depth) * 0.001f;
658 if (*volume > 127) {
659 *volume = 127;
660 }
661 if (*volume < 1) {
662 *volume = 1;
663 }
664
665 *pan = ((screenX * 64.0f) / camera->viewportW) + 32.0f;
666}
f32 fabsf(f32 f)
Camera gCameras[4]
Definition cam_main.c:16

Referenced by sfx_get_spatialized_sound_params().

◆ sfx_compute_spatialized_sound_params_full()

void sfx_compute_spatialized_sound_params_full ( f32 x,
f32 y,
f32 z,
s16 * volume,
s16 * pan,
s32 flags )

Definition at line 217 of file sfx_control.c.

217 {
220 f32 offsetX, offsetY, depth;
222 s32 phi_v0;
223
225
226 if (screenX > 5000 || screenX < -5000 || screenY > 5000 || screenY < -5000) {
227 *volume = -1;
228 *pan = 0;
229 return;
230 }
231
234 *volume = -1;
235 *pan = 0;
236 return;
237 }
238 } else if (flags & SOUND_PARAM_CLIP_OFFSCREEN_X) {
240 *volume = -1;
241 *pan = 0;
242 return;
243 }
244 } else if (flags & SOUND_PARAM_CLIP_OFFSCREEN_Y) {
246 *volume = -1;
247 *pan = 0;
248 return;
249 }
250 }
251
252 offsetX = abs((SCREEN_WIDTH / 2) - screenX) - 145;
253 if (offsetX < 0.0) {
254 offsetX = 0.0f;
255 }
256
257 volAmtOffsetX = update_lerp(EASING_LINEAR, 1.0f, 0.0f, offsetX, 200);
258 if (volAmtOffsetX < 0.0) {
259 volAmtOffsetX = 0.0f;
260 }
261
262 offsetY = abs((SCREEN_HEIGHT / 2) - screenY) - 105;
263 if (offsetY < 0.0) {
264 offsetY = 0.0f;
265 }
266
267 volAmtDeltaY = update_lerp(EASING_LINEAR, 1.0f, 0.0f, offsetY, 130);
268 if (volAmtDeltaY < 0.0) {
269 volAmtDeltaY = 0.0f;
270 }
271
272 depth = screenZ - 5550.0;
273 if (depth < 0.0) {
274 depth = 0.0f;
275 }
276
277 volAmtDepth = update_lerp(EASING_LINEAR, 1.0f, 0.0f, depth, 250);
278 if (volAmtDepth < 0.0) {
279 volAmtDepth = 0.0f;
280 }
281
283 if (volTemp < 15.0) {
284 volTemp = 15.0f;
285 } else if (volTemp > 127.0) {
286 volTemp = 127.0f;
287 }
288 *volume = volTemp;
289
290 panTemp = (((f32) screenX - (SCREEN_WIDTH / 2.0)) / 3.6) + 64.0;
291 if (panTemp < 1.0) {
292 panTemp = 1.0f;
293 } else if (panTemp > 127.0) {
294 panTemp = 127.0f;
295 }
296 *pan = panTemp;
297}
@ EASING_LINEAR
Definition enums.h:510
@ SOUND_PARAM_CLIP_OFFSCREEN_X
Definition enums.h:1746
@ SOUND_PARAM_CLIP_OFFSCREEN_ANY
Definition enums.h:1745
@ SOUND_PARAM_CLIP_OFFSCREEN_Y
Definition enums.h:1747
f32 update_lerp(s32 easing, f32 start, f32 end, s32 elapsed, s32 duration)
Definition 43F0.c:733
#define SCREEN_HEIGHT
Definition macros.h:110

Referenced by sfx_get_spatialized_sound_params().