sound tweaks
authorhgn <hgodden00@gmail.com>
Sun, 12 Dec 2021 05:15:03 +0000 (05:15 +0000)
committerhgn <hgodden00@gmail.com>
Sun, 12 Dec 2021 05:15:03 +0000 (05:15 +0000)
fishladder.c
fishladder_resources.h
sound/click_a.ogg [new file with mode: 0644]
sound/click_b.ogg [new file with mode: 0644]
sound/click_c.ogg [new file with mode: 0644]
sound/rolling_01.ogg
sound/splitter_01.ogg
vg/vg_audio.h

index e344844a9dbef28b4799ecf53c62cadbca2b0a57..18332b5dd23f38621fbdce76a0d41d225118f81a 100644 (file)
@@ -1330,7 +1330,7 @@ void vg_update(void)
                
                while( world.sim_frame < world.sim_target )
                {
-                       sfx_set_playrnd( &audio_random, &audio_system_balls_switching, 0, 9 );
+                       sfx_set_playrnd( &audio_random, &audio_system_balls_switching, 0, 8 );
 
                        // Update splitter deltas
                        for( int i = 0; i < world.h*world.w; i ++ )
@@ -1964,6 +1964,8 @@ static void wbutton_run( enum e_world_button btn_name )
                {
                        btn->pressed ^= 0x1;
                }
+               
+               sfx_set_play( &audio_clicks, &audio_system_ui, btn->pressed?1:0 );
        }
        
        // Drawing
index 1a56f549739cf6512013423898378cc2b32533e5..29e7f3eebb448474b95960faceb812a10e625a3a 100644 (file)
@@ -64,6 +64,14 @@ sound/random_07.ogg\0\
 sound/random_08.ogg\0"
 };
 
+sfx_set audio_clicks =
+{
+ .sources = "\
+sound/click_a.ogg\0\
+sound/click_b.ogg\0\
+sound/click_c.ogg\0"
+};
+
 // One two or three layers of rolling noise
 sfx_system audio_system_balls_rolling =
 {
@@ -92,6 +100,12 @@ sfx_system audio_system_balls_extra =
        .name = "Balls Extra"
 };
 
+sfx_system audio_system_ui = 
+{
+       .vol = 1.f, .ch = 1, .vol_src = &audio_volume_sfx,
+       .name = "UI"
+};
+
 ui_colourset ui_fl_colours = {
        .main = 0xff807373,
        .hover = 0xff918484,
@@ -119,6 +133,7 @@ static void resource_load_main(void)
        sfx_set_init( &audio_splitter, NULL );
        sfx_set_init( &audio_rolls, NULL );
        sfx_set_init( &audio_random, NULL );
+       sfx_set_init( &audio_clicks, NULL );
 }
 
 static void resource_free_main(void)
@@ -129,6 +144,7 @@ static void resource_free_main(void)
        sfx_set_free( &audio_splitter );
        sfx_set_free( &audio_rolls );
        sfx_set_free( &audio_random );
+       sfx_set_free( &audio_clicks );
 }
 
 // SHADERS
diff --git a/sound/click_a.ogg b/sound/click_a.ogg
new file mode 100644 (file)
index 0000000..9ed767a
Binary files /dev/null and b/sound/click_a.ogg differ
diff --git a/sound/click_b.ogg b/sound/click_b.ogg
new file mode 100644 (file)
index 0000000..174be87
Binary files /dev/null and b/sound/click_b.ogg differ
diff --git a/sound/click_c.ogg b/sound/click_c.ogg
new file mode 100644 (file)
index 0000000..4c8d73e
Binary files /dev/null and b/sound/click_c.ogg differ
index 6a79597a91613f1cf170335440daeca69e6fda67..7243b8bf7ffb01859fd4e1cacb72c8bd6f706a1c 100644 (file)
Binary files a/sound/rolling_01.ogg and b/sound/rolling_01.ogg differ
index a145fbd109907a77e5648823f9fd6e48377f1ed6..934a353c1b472bea0799d66bff0767d64408ed8e 100644 (file)
Binary files a/sound/splitter_01.ogg and b/sound/splitter_01.ogg differ
index 0c9a666691e64f62f4926041d41f4fc0679e33cf..aefc0fc81cd0693688a125304877a15ae354be39 100644 (file)
@@ -625,20 +625,14 @@ static void sfx_set_init( sfx_set *dest, char *sources )
                sfx_set_strings( dest, sources, dest->flags, 0 );
 }
 
-// Pick a random sound from the buffer and play it into system
-static void sfx_set_playrnd( sfx_set *source, sfx_system *sys, int min_id, int max_id )
+static void sfx_set_play( sfx_set *source, sfx_system *sys, int id )
 {
-       if( !source->numsegments )
-               return;
-
-       int pick = (rand() % (max_id-min_id)) + min_id;
-
        if( sfx_begin_edit( sys ) )
        {
                sys->fadeout = 0;
                sys->source = source->main;
-               sys->cur        = source->segments[ pick*2 + 0 ];
-               sys->end        = source->segments[ pick*2 + 1 ];
+               sys->cur        = source->segments[ id*2 + 0 ];
+               sys->end        = source->segments[ id*2 + 1 ];
                sys->ch                 = source->ch;
                
                // Diagnostics
@@ -650,6 +644,23 @@ static void sfx_set_playrnd( sfx_set *source, sfx_system *sys, int min_id, int m
        }
 }
 
+// Pick a random sound from the buffer and play it into system
+static void sfx_set_playrnd( sfx_set *source, sfx_system *sys, int min_id, int max_id )
+{
+       if( !source->numsegments )
+               return;
+
+       if( max_id > source->numsegments )
+       {
+               vg_error( "Max ID out of range for playrnd\n" );
+               return; 
+       }
+
+       int pick = (rand() % (max_id-min_id)) + min_id;
+       
+       sfx_set_play( source, sys, pick );
+}
+
 static void sfx_system_fadeout( sfx_system *sys, u32 length_samples )
 {
        if( sfx_begin_edit( sys ) )