29 #pragma optimize("", off)
32 #define DEFAULT_MASTER_EVENT_MUSIC_VOLUME 0.5f
34 #define HULL_VALUE_TO_PLAY_INTENSE_BATTLE_MUSIC 0.75f
61 #define PATTERN_DELAY 1000 // in ms
68 static int Num_enemy_arrivals;
69 static int Num_friendly_arrivals;
71 #define ARRIVAL_INTERVAL_TIMESTAMP 5000
72 #define BATTLE_CHECK_INTERVAL 15000
73 static int Battle_over_timestamp;
74 static int Mission_over_timestamp;
75 static int Victory2_music_played;
76 static int Next_arrival_timestamp;
77 static int Check_for_battle_music;
110 {
"DEAD_1",
"Dead 1",
TRUE, 1, -1, -1 },
238 static int Event_music_inited =
FALSE;
239 static int Event_music_level_inited =
FALSE;
240 static int Event_music_begun =
FALSE;
266 Event_music_enabled =
FALSE;
274 if ( Event_music_inited ==
TRUE )
290 strcpy_s(Soundtracks[i].pattern_fnames[j],
NOX(
"none.wav"));
311 Event_music_inited =
TRUE;
312 Event_music_begun =
FALSE;
322 if ( Event_music_inited ==
FALSE )
325 Event_music_inited =
FALSE;
385 if ( Event_music_enabled ==
FALSE )
388 if ( Event_music_level_inited ==
FALSE )
395 if ( new_pattern == -1 ) {
399 if ( Patterns[new_pattern].num_measures == 0 )
407 nprintf((
"EVENTMUSIC",
"EVENTMUSIC => switching to %s from %s\n", Pattern_info[new_pattern].pattern_name, Pattern_info[
Current_pattern].pattern_name));
421 if ( Event_music_level_inited ==
FALSE ) {
425 if ( Event_music_enabled ==
FALSE ) {
432 Event_music_begun =
TRUE;
441 if ( Event_music_begun ==
FALSE ) {
469 if ( measures_played < pat->num_measures ) {
479 Check_for_battle_music =
timestamp(1000);
521 if ( !Victory2_music_played ) {
527 Victory2_music_played = 1;
554 if (Event_music_level_inited ==
TRUE)
560 if (Event_music_inited ==
FALSE)
564 if (force_soundtrack != -1)
583 if (Current_soundtrack_num < 0 || Current_soundtrack_num >
Num_soundtracks)
604 if (Patterns[i].handle >= 0)
606 Event_music_level_inited =
TRUE;
607 Event_music_enabled =
TRUE;
627 Num_enemy_arrivals = 0;
628 Num_friendly_arrivals = 0;
632 Victory2_music_played = 0;
633 Check_for_battle_music = 0;
635 if (Event_music_level_inited)
637 if (force_soundtrack >= 0)
650 if ( Event_music_inited ==
FALSE ) {
654 if ( Event_music_enabled ==
FALSE ) {
658 if ( Event_music_level_inited ==
FALSE ) {
662 if ( Event_music_level_inited ==
FALSE ) {
666 if ( Event_music_begun ==
TRUE ) {
677 Event_music_begun =
FALSE;
695 if ( Event_music_level_inited ==
FALSE )
721 Event_music_level_inited =
FALSE;
723 Event_music_enabled = 0;
724 Event_music_begun =
FALSE;
747 if ( Event_music_enabled ==
FALSE )
750 if ( Event_music_level_inited ==
FALSE )
777 if ( Event_music_enabled ==
FALSE ) {
781 if ( Event_music_level_inited ==
FALSE ) {
808 Num_enemy_arrivals++;
816 if ( Num_enemy_arrivals & 1 ) {
829 bool play_intense_battle_music =
false;
835 play_intense_battle_music =
true;
838 if (play_intense_battle_music ==
true) {
872 if ( Event_music_enabled ==
FALSE )
875 if ( Event_music_level_inited ==
FALSE )
902 if(Current_pattern < 0 || Current_pattern >=
MAX_PATTERNS)
909 Num_friendly_arrivals++;
981 if ( Event_music_enabled ==
FALSE )
984 if ( Event_music_level_inited ==
FALSE )
1023 if ( Event_music_enabled ==
FALSE )
1026 if ( Event_music_level_inited ==
FALSE )
1047 Victory2_music_played = 1;
1066 if ( Event_music_enabled ==
FALSE )
1069 if ( Event_music_level_inited ==
FALSE )
1091 if ( Event_music_enabled ==
FALSE )
1094 if ( Event_music_level_inited ==
FALSE )
1113 if ( Event_music_enabled ==
FALSE )
1116 if ( Event_music_level_inited ==
FALSE )
1141 Warning(
LOCATION,
"Too many $Name: entries for soundtrack %s", Soundtracks[strack_idx].
name);
1146 token = strtok( line_buf,
NOX(
" ,\t"));
1148 while ( token != NULL )
1150 token = strtok( NULL,
NOX(
" ,\t") );
1152 if ( token == NULL && count != 2)
1154 Warning(
LOCATION,
"Missing or additional field for soundtrack %s, pattern %s", Soundtracks[strack_idx].
name, Pattern_info[pattern_idx].pattern_desc);
1161 }
else if(count == 1) {
1168 strcpy_s(Soundtracks[strack_idx].pattern_fnames[pattern_idx], fname);
1175 int i, strack_idx = -1;
1176 bool nocreate =
false;
1203 else if(strack_idx < 0)
1237 int old_pattern_num = 0;
1246 if(New_pattern_order[i] == old_pattern_num)
1251 if(i+1 > Soundtracks[strack_idx].num_patterns) {
1261 if(i == Num_pattern_types)
1263 Warning(
LOCATION,
"Could not find new index for pattern %d of soundtrack '%s'", old_pattern_num, Soundtracks[strack_idx].
name);
1278 sprintf(tagbuf,
"$%s:", Pattern_info[i].pattern_desc);
1285 if(i+1 > Soundtracks[strack_idx].num_patterns) {
1299 for (i = 0; i < Soundtracks[strack_idx].
num_patterns; i++)
1302 if (!strlen(Soundtracks[strack_idx].pattern_fnames[i]) || !
strnicmp(Soundtracks[strack_idx].pattern_fnames[i],
"none", 4))
1318 bool nocreate =
false;
1332 Warning(
LOCATION,
"Could not load spooled music file after '%s' as maximum number of spooled music was reached (Max is %d)", Spooled_music[Num_music_files - 1].
name,
MAX_SPOOLED_MUSIC);
1336 Error(
LOCATION,
"Couldn't find $Name or #Menu Music End. Music.tbl or -mus.tbm is invalid.\n");
1401 mprintf((
"TABLES: Unable to parse '%s'! Error message = %s.\n", filename, e.what()));
1412 if ( Event_music_enabled ==
FALSE ) {
1413 nprintf((
"EVENTMUSIC",
"EVENTMUSIC ==> Requested a song switch when event music is not enabled\n"));
1417 if ( Event_music_level_inited ==
FALSE ) {
1418 nprintf((
"EVENTMUSIC",
"EVENTMUSIC ==> Event music is not enabled\n"));
1451 if ( Event_music_level_inited ==
FALSE )
1454 if ( Event_music_enabled ==
FALSE )
1465 Event_music_begun =
FALSE;
1466 Event_music_enabled =
FALSE;
1478 if ( Event_music_enabled ==
TRUE )
1481 Event_music_enabled =
TRUE;
1483 if ( Event_music_level_inited ==
FALSE ) {
1492 Event_music_begun =
FALSE;
1540 if ( Event_music_enabled ==
FALSE ) {
1541 nprintf((
"EVENTMUSIC",
"EVENTMUSIC ==> Requested a song switch when event music is not enabled\n"));
1545 if ( Event_music_level_inited ==
FALSE ) {
1546 nprintf((
"EVENTMUSIC",
"EVENTMUSIC ==> Event music is not enabled\n"));
1566 if ( Event_music_enabled ==
FALSE ) {
1567 nprintf((
"EVENTMUSIC",
"EVENTMUSIC ==> Requested a song switch when event music is not enabled\n"));
1571 if ( Event_music_level_inited ==
FALSE ) {
1572 nprintf((
"EVENTMUSIC",
"EVENTMUSIC ==> Event music is not enabled\n"));
1676 strcpy(outbuf,
XSTR(
"Event music is not playing", 213));
1694 if ( Event_music_enabled ==
FALSE || Event_music_level_inited ==
FALSE ) {
1713 int i, new_soundtrack = -1;
1716 if ( !
stricmp(name, Soundtracks[i].name) ) {
1738 if ( Event_music_enabled ==
FALSE || Event_music_level_inited ==
FALSE ) {
1739 strcpy(outbuf,
XSTR(
"Event music is not playing", 213));
1752 mprintf((
"Current soundtrack set to -1 in event_music_set_soundtrack\n"));
1760 if ( !
stricmp(name, Soundtracks[
i].name) ) {
1772 if ( !
stricmp(name, Spooled_music[
i].name) ) {
1798 mprintf((
"Current soundtrack set to -1 in event_music_reset_choices\n"));
1816 #pragma optimize("", on)
int timestamp(int delta_ms)
void audiostream_set_volume_all(float volume, int type)
void event_music_unpause()
int Cmdline_freespace_no_music
int check_for_string(const char *pstr)
int Mission_music[NUM_SCORES]
SNDPATTERN Patterns[MAX_PATTERNS]
int Current_soundtrack_num
bool parse_soundtrack_line(int strack_idx, int pattern_idx)
const char * audio_ext_list[]
struct pattern_info pattern_info
void audiostream_close_all(int fade)
void _cdecl void void _cdecl void _cdecl Warning(char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
void stuff_boolean_flag(int *i, int flag, bool a_to_eol)
int event_music_next_soundtrack(int delta)
void event_music_enable()
void event_music_arrival(int team)
int Pattern_samples_per_measure[MAX_SOUNDTRACKS][MAX_PATTERNS]
#define Assertion(expr, msg,...)
#define END_OF_LIST(head)
void event_music_get_info(char *outbuf)
#define SCORE_FICTION_VIEWER
void event_music_do_frame()
void event_music_start_default()
std::basic_string< char, std::char_traits< char >, std::allocator< char > > SCP_string
SOUNDTRACK_INFO Soundtracks[MAX_SOUNDTRACKS]
int required_string_either(char *str1, char *str2)
Checks for one of two required strings.
void event_music_set_score(int score_index, char *name)
int audiostream_is_inited()
int audiostream_is_playing(int i)
#define SCORE_DEBRIEF_FAIL
uint audiostream_get_samples_committed(int i)
#define SCORE_DEBRIEF_AVERAGE
float Pattern_num_measures[MAX_SOUNDTRACKS][MAX_PATTERNS]
#define MAX_SPOOLED_MUSIC
float ship_max_hull_strength
void event_music_get_soundtrack_name(char *outbuf)
void audiostream_stop(int i, int rewind, int paused)
int cf_exists_full(const char *filename, int dir_type)
int ship_subsys_disrupted(ship_subsys *ss)
#define strnicmp(s1, s2, n)
#define ARRIVAL_INTERVAL_TIMESTAMP
void stuff_string(char *outstr, int type, int len, char *terminators)
sprintf(buf,"(%f,%f,%f)", v3->xyz.x, v3->xyz.y, v3->xyz.z)
void event_music_reset_choices()
void event_music_hostile_ship_destroyed()
int required_string(const char *pstr)
#define P_SF_CANNOT_ARRIVE
int event_music_player_death()
int optional_string(const char *pstr)
#define DEFAULT_MASTER_EVENT_MUSIC_VOLUME
void read_file_text(const char *filename, int mode, char *processed_text, char *raw_text)
int skip_to_start_of_string_either(char *pstr1, char *pstr2, char *end)
pattern_info Pattern_info[]
void event_sexp_change_soundtrack(char *name)
int iff_x_attacks_y(int team_x, int team_y)
int event_music_player_respawn_as_observer()
object Objects[MAX_OBJECTS]
void event_music_set_soundtrack(char *name)
const char * XSTR(const char *str, int index)
struct tagSNDPATTERN SNDPATTERN
int pattern_default_next_fs2
void _cdecl void void _cdecl Error(const char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
menu_music Spooled_music[MAX_SPOOLED_MUSIC]
void reset_parse(char *text)
GLuint const GLchar * name
int hostile_ships_present()
#define BATTLE_CHECK_INTERVAL
void event_music_force_switch()
#define MISSION_TYPE_TRAINING
int event_music_player_respawn()
void audiostream_close_file(int i, int fade)
void event_music_set_volume_all(float volume)
typedef float(SCP_EXT_CALLCONV *SCPTRACKIR_PFFLOATVOID)()
int Event_Music_battle_started
int event_music_cycle_pattern()
int audiostream_is_paused(int i)
void event_music_parse_musictbl(const char *filename)
int event_music_primary_goal_failed()
void event_music_level_init(int force_soundtrack)
int event_music_get_soundtrack_index(char *name)
char substitute_briefing_music_name[NAME_LENGTH]
int event_music_friendly_arrival()
char pattern_fnames[MAX_PATTERNS][MAX_FILENAME_LEN]
SCP_vector< ship_info > Ship_info
float Master_event_music_volume
#define timestamp_elapsed(stamp)
void audiostream_play(int i, float volume, int looping)
void event_music_level_close()
int parse_modular_table(const char *name_check, void(*parse_callback)(const char *filename), int path_type, int sort_type)
p_object Ship_arrival_list
#define SCORE_DEBRIEF_SUCCESS
int pattern_default_next_fs1
void audiostream_set_sample_cutoff(int i, uint cutoff)
#define EMF_ALLIED_ARRIVAL_OVERLAY
int event_music_get_spooled_music_index(const char *name)
int audiostream_open(const char *filename, int type)
int event_music_return_current_pattern()
int event_music_enemy_arrival()
#define HULL_VALUE_TO_PLAY_INTENSE_BATTLE_MUSIC
void event_music_change_pattern(int new_pattern)
int event_music_primary_goals_met()
int skip_to_string(char *pstr, char *end)
void event_music_first_pattern()
void event_music_disable()
int audiostream_done_reading(int i)
int cf_exists_full_ext(const char *filename, int dir_type, const int num_ext, const char **ext_list)
int event_music_battle_start()
int hud_target_invalid_awacs(object *objp)
char substitute_event_music_name[NAME_LENGTH]
int hostile_ships_to_arrive()