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

static void close_audio ( void  )
static struct sound_data* grow_sound_list ( void  )
errr init_sound ( const char *  soundstr,
int  argc,
char **  argv 

Init the sound "module".

References close_audio(), event_add_handler(), EVENT_SOUND, hooks, i, NULL, sound_hooks::open_audio_hook, play_sound(), and streq.

Referenced by main().

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().

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, NULL, msg_snd_data::num_sounds, preload_sounds, search(), msg_snd_data::sound_ids, string_free(), and string_make().

Referenced by parse_prefs_sound().

enum parser_error parse_prefs_sound ( struct parser p)
static void play_sound ( game_event_type  type,
game_event_data data,
void user 
void print_sound_help ( void  )

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

References i, int, and N_ELEMENTS.

Referenced by main().

errr register_sound_pref_parser ( struct parser p)

Variable Documentation

struct sound_hooks hooks
struct msg_snd_data message_sounds[MSG_MAX]

Referenced by message_sound_define(), and play_sound().

u16b next_sound_id
bool preload_sounds = false

Referenced by message_sound_define().

const struct sound_module sound_modules[]
Initial value:
{ "", "", NULL },
Definition: list-summon-types.h:18

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

struct sound_data* sounds

Referenced by grow_sound_list().