Data Structures | Macros | Functions | Variables
sound-core.c File Reference

core sound support More...

#include "angband.h"
#include "init.h"
#include "sound.h"
#include "main.h"
#include "ui-prefs.h"

Data Structures

struct  sound_module
struct  msg_snd_data




static struct sound_datagrow_sound_list (void)
static void load_sound (struct sound_data *sound_data)
 Iterate through all the sound types supporting by the platform's sound module. More...
void message_sound_define (u16b message_id, const char *sounds_str)
 Parse a string of sound names provided by the preferences parser and: More...
enum parser_error parse_prefs_sound (struct parser *p)
errr register_sound_pref_parser (struct parser *p)
static void play_sound (game_event_type type, game_event_data *data, void *user)
 Play a sound of type "event". More...
static void close_audio (void)
errr init_sound (const char *soundstr, int argc, char **argv)
 Init the sound "module". More...
void print_sound_help (void)
 Print out the 'help' information for the sound module. More...


static struct msg_snd_data message_sounds [MSG_MAX]
static const struct sound_module sound_modules []
 List of sound modules in the order they should be tried. More...
static u16b next_sound_id
static struct sound_datasounds
static struct sound_hooks hooks
static bool preload_sounds = false

Detailed Description

core sound support

Copyright (c) 2016 Graeme Russ

This work is free software; you can redistribute it and/or modify it under the terms of either:

a) the GNU General Public License as published by the Free Software Foundation, version 2, or

b) the "Angband licence": This software may be copied and distributed for educational, research, and not for profit purposes provided that this copyright and statement are included in all such copies. Other copyrights may also apply.

Macro Definition Documentation



Referenced by message_sound_define().



Referenced by grow_sound_list().

Function Documentation

◆ close_audio()

static void close_audio ( void  )

◆ grow_sound_list()

static struct sound_data* grow_sound_list ( void  )

◆ init_sound()

errr init_sound ( const char *  soundstr,
int  argc,
char **  argv 

◆ load_sound()

static void load_sound ( struct sound_data sound_data)

Iterate through all the sound types supporting by the platform's sound module.

Call the platform's sound modules 'load sound' function for each supported file type until the platform's sound module tell us that it could load the sound. NOTE: The platform's sound module does not have to load the sound into memory, it merely has to let us know that it can play the sound when asked to.

References ANGBAND_DIR_SOUNDS, sound_file_type::extension, file_exists(), hooks, i, sound_hooks::load_sound_hook, mem_free(), mem_zalloc(), my_strcpy(), sound_data::name, path, path_build(), plog_fmt(), string_append(), sound_hooks::supported_files_hook, supported_sound_files, and type.

Referenced by message_sound_define(), and play_sound().

◆ message_sound_define()

void message_sound_define ( u16b  message_id,
const char *  sounds_str 

Parse a string of sound names provided by the preferences parser and:

  • Allocate a unique 'sound id' to any new sounds and add them to the 'sounds' array.
  • Add each sound assigned to a message type to that message types 'sound map

References djb2_hash(), grow_sound_list(), sound_data::hash, i, load_sound(), MAX_SOUNDS_PER_MESSAGE, message_sounds, sound_data::name, next_sound_id, msg_snd_data::num_sounds, preload_sounds, search(), msg_snd_data::sound_ids, string_free(), and string_make().

Referenced by parse_prefs_sound().

◆ parse_prefs_sound()

enum parser_error parse_prefs_sound ( struct parser p)

◆ play_sound()

static void play_sound ( game_event_type  type,
game_event_data data,
void user 

◆ print_sound_help()

void print_sound_help ( void  )

Print out the 'help' information for the sound module.

References sound_module::help, i, int, and N_ELEMENTS.

Referenced by main().

◆ register_sound_pref_parser()

errr register_sound_pref_parser ( struct parser p)

Variable Documentation

◆ hooks

struct sound_hooks hooks

◆ message_sounds

struct msg_snd_data message_sounds[MSG_MAX]

Referenced by message_sound_define(), and play_sound().

◆ next_sound_id

u16b next_sound_id

◆ preload_sounds

bool preload_sounds = false

Referenced by message_sound_define().

◆ sound_modules

const struct sound_module sound_modules[]
Initial value:
{ "", "", NULL },

List of sound modules in the order they should be tried.

◆ sounds

struct sound_data* sounds

Referenced by grow_sound_list().