From: hgn Date: Sat, 23 Oct 2021 16:55:31 +0000 (+0100) Subject: update audio randomizer X-Git-Url: https://harrygodden.com/git/?p=fishladder.git;a=commitdiff_plain;h=def3a94bd35b2f134ecedb4149eae0bb6821ecd8 update audio randomizer --- diff --git a/fishladder.c b/fishladder.c index 6d6486b..b8fbb2a 100644 --- a/fishladder.c +++ b/fishladder.c @@ -193,10 +193,12 @@ sfx_system_t audio_system_sfx = sfx_set_t audio_tile_mod = { .sources = "\ -sound/mod00.ogg\0\ -sound/mod01.ogg\0\ -sound/mod02.ogg\0\ -sound/mod03.ogg\0", +sound/mod_01.ogg\0\ +sound/mod_02.ogg\0\ +sound/mod_03.ogg\0\ +sound/mod_04.ogg\0\ +sound/mod_05.ogg\0\ +sound/mod_06.ogg\0", .flags = 0 }; @@ -728,7 +730,11 @@ void vg_update(void) if( vg_get_button_down("primary") ) { world.data[ world.selected ].state ^= FLAG_CANAL; - sfx_set_playrnd( &audio_tile_mod, &audio_system_sfx ); + + if( world.data[ world.selected ].state & FLAG_CANAL ) + sfx_set_playrnd( &audio_tile_mod, &audio_system_sfx, 3, 6 ); + else + sfx_set_playrnd( &audio_tile_mod, &audio_system_sfx, 0, 3 ); } } else diff --git a/sound/mod00.ogg b/sound/mod00.ogg deleted file mode 100644 index 0e98c8a..0000000 Binary files a/sound/mod00.ogg and /dev/null differ diff --git a/sound/mod01.ogg b/sound/mod01.ogg deleted file mode 100644 index 07cbae6..0000000 Binary files a/sound/mod01.ogg and /dev/null differ diff --git a/sound/mod02.ogg b/sound/mod02.ogg deleted file mode 100644 index 43d1bc0..0000000 Binary files a/sound/mod02.ogg and /dev/null differ diff --git a/sound/mod03.ogg b/sound/mod03.ogg deleted file mode 100644 index f0866d0..0000000 Binary files a/sound/mod03.ogg and /dev/null differ diff --git a/sound/mod04.ogg b/sound/mod04.ogg deleted file mode 100644 index 0ecf86c..0000000 Binary files a/sound/mod04.ogg and /dev/null differ diff --git a/sound/mod_01.ogg b/sound/mod_01.ogg new file mode 100644 index 0000000..7c4b24e Binary files /dev/null and b/sound/mod_01.ogg differ diff --git a/sound/mod_02.ogg b/sound/mod_02.ogg new file mode 100644 index 0000000..a340f18 Binary files /dev/null and b/sound/mod_02.ogg differ diff --git a/sound/mod_03.ogg b/sound/mod_03.ogg new file mode 100644 index 0000000..7314564 Binary files /dev/null and b/sound/mod_03.ogg differ diff --git a/sound/mod_04.ogg b/sound/mod_04.ogg new file mode 100644 index 0000000..01ff4ba Binary files /dev/null and b/sound/mod_04.ogg differ diff --git a/sound/mod_05.ogg b/sound/mod_05.ogg new file mode 100644 index 0000000..f48c52d Binary files /dev/null and b/sound/mod_05.ogg differ diff --git a/sound/mod_06.ogg b/sound/mod_06.ogg new file mode 100644 index 0000000..f8b67a4 Binary files /dev/null and b/sound/mod_06.ogg differ diff --git a/vg/vg_audio.h b/vg/vg_audio.h index 330be30..6d79771 100644 --- a/vg/vg_audio.h +++ b/vg/vg_audio.h @@ -668,15 +668,15 @@ void sfx_set_init( sfx_set_t *dest, char *sources ) } // Pick a random sound from the buffer and play it into system -void sfx_set_playrnd( sfx_set_t *source, sfx_system_t *sys ) +void sfx_set_playrnd( sfx_set_t *source, sfx_system_t *sys, int min_id, int max_id ) { if( !source->numsegments ) { return; } - int pick = rand() % source->numsegments; - + int pick = (rand() % (max_id-min_id)) + min_id; + sys->source = source->main; sys->cur = source->segments[ pick*2 + 0 ]; sys->end = source->segments[ pick*2 + 1 ];