more comprehensive audio visualizer
authorhgn <hgodden00@gmail.com>
Wed, 27 Oct 2021 22:27:57 +0000 (23:27 +0100)
committerhgn <hgodden00@gmail.com>
Wed, 27 Oct 2021 22:27:57 +0000 (23:27 +0100)
16 files changed:
fishladder.c
sound/random_01.ogg
sound/random_02.ogg
sound/random_03.ogg
sound/random_04.ogg
sound/random_05.ogg
sound/random_06.ogg
sound/random_07.ogg
sound/random_08.ogg
sound/random_09.ogg
sound/rolling_01.ogg
sound/rolling_02.ogg
sound/rolling_03.ogg
sound/splitter_01.ogg
vg/vg_audio.h
vg/vg_debug.h

index e8a8a3fad09286aead57c21cc1099c71be6cebb3..e024fca71987265a050db88d2a0be6b4f99317de 100644 (file)
@@ -639,10 +639,10 @@ void vg_update(void)
        // Fish ticks
        if( world.simulating )
        {
-               while( world.sim_frame < (int)((vg_time-world.sim_start)*200.0f) )
+               while( world.sim_frame < (int)((vg_time-world.sim_start)*2.0f) )
                {
                        //vg_info( "frame: %u\n", world.sim_frame );
-                       sfx_set_playrnd( &audio_random, &audio_system_balls_switching, 0, 5 );
+                       sfx_set_playrnd( &audio_random, &audio_system_balls_switching, 0, 9 );
                        
                        for( int i = 0; i < arrlen( world.io ); i ++ )
                        {
index 193d24c563f26ea66fd9f5d76ee7a0ddbd5287d3..48e3813a4512b4d2f20680422b1d2040394b26a4 100644 (file)
Binary files a/sound/random_01.ogg and b/sound/random_01.ogg differ
index f1a46f4e1d3e2cd8f201a3cbfa6eea324055f865..79e26be19f24e0eab3a6362d57f7ccb07c55dec2 100644 (file)
Binary files a/sound/random_02.ogg and b/sound/random_02.ogg differ
index 07aee2f613d3969f2f4c33d68342c38081605cee..e3b80abe8b87230c07545418aa0debc86e80fc83 100644 (file)
Binary files a/sound/random_03.ogg and b/sound/random_03.ogg differ
index 307a71430958bc0107090a068f112ed40d714efe..0dcf0206a78990736d73754a6c3fec26bc390528 100644 (file)
Binary files a/sound/random_04.ogg and b/sound/random_04.ogg differ
index dbdbc02cc11377ba8553a3fe69943bfb5d675177..fdcd57d12e5e897b59f1e22381606ae163288229 100644 (file)
Binary files a/sound/random_05.ogg and b/sound/random_05.ogg differ
index 65b35c6fa45d84d0de36afda45bd231afee52a40..cc29f866d4b3f10e656c62363314f57b5729492b 100644 (file)
Binary files a/sound/random_06.ogg and b/sound/random_06.ogg differ
index 401dc2523c23365f1ca958ce4c66fac82661e007..bf2818eac2f9250da0bfcd9d74cd2fbb02210c58 100644 (file)
Binary files a/sound/random_07.ogg and b/sound/random_07.ogg differ
index c190b34ee7e85fc3e22fe27e40c26053548fd993..844c772e27c68f5068998b85ec20bf3dadba445b 100644 (file)
Binary files a/sound/random_08.ogg and b/sound/random_08.ogg differ
index 1b5588406be711b1fe3691ca0a826f9b592a2afe..33c95fea54ef07ce2c8d31c7a5676bae5f941c75 100644 (file)
Binary files a/sound/random_09.ogg and b/sound/random_09.ogg differ
index b0f41ac17a3c5809d595074e12104dc121c6113e..6a79597a91613f1cf170335440daeca69e6fda67 100644 (file)
Binary files a/sound/rolling_01.ogg and b/sound/rolling_01.ogg differ
index 95c3b3dbede2390406c481c58b32d824d1f6059f..e6bc69567f7e90250b31849c22a33314febbd77a 100644 (file)
Binary files a/sound/rolling_02.ogg and b/sound/rolling_02.ogg differ
index c408d3e108b096846fe7379f6e4894574cc2bbf7..3ffbbb7c257d837e93e8916d72b40d3668770d0a 100644 (file)
Binary files a/sound/rolling_03.ogg and b/sound/rolling_03.ogg differ
index 2d524fdef8c46352730cf03ac3b7e78394b69aff..a145fbd109907a77e5648823f9fd6e48377f1ed6 100644 (file)
Binary files a/sound/splitter_01.ogg and b/sound/splitter_01.ogg differ
index e375a5bf087159f74bd0a4dabdc0b5275a965326..c0a3720e898e4f8c98748f65b133a8f3e1fbb391 100644 (file)
@@ -28,6 +28,8 @@ struct sfx_system
        // Source buffer start
        float *source, *replacement;
        
+       u32 clip_start, clip_end, buffer_length;
+       
        // Modifiers
        sfx_vol_control *vol_src;
        float   vol;
@@ -639,6 +641,11 @@ static void sfx_set_playrnd( sfx_set *source, sfx_system *sys, int min_id, int m
                sys->end        = source->segments[ pick*2 + 1 ];
                sys->ch                 = source->ch;
                
+               // Diagnostics
+               sys->clip_start = sys->cur;
+               sys->clip_end = sys->end;
+               sys->buffer_length = source->segments[ (source->numsegments-1)*2 + 1 ];
+               
                sfx_save( sys );
        }
 }
index ba61dd21a120e8685c247a828f58cc3077192c24..333aed82ddc819b694a28315312e183962912903 100644 (file)
@@ -5,7 +5,9 @@ static void sfx_internal_debug_overlay(void)
        {
                float signal;
                const char *name;
-               u32 length, cursor, flags;
+               u32 cursor, flags;
+               
+               u32 buffer_length, clip_start, clip_end;
        }
        infos[ SFX_MAX_SYSTEMS ];
        int num_systems;
@@ -21,9 +23,21 @@ static void sfx_internal_debug_overlay(void)
                
                snd->signal = sys->signal_average;
                snd->name = sys->name;
-               snd->length = sys->end;
                snd->cursor = sys->cur;
-               snd->flags = sys->flags;                
+               snd->flags = sys->flags;
+               
+               if( sys->thread_clone )
+               {
+                       snd->clip_start = sys->thread_clone->clip_start;
+                       snd->clip_end = sys->thread_clone->clip_end;
+                       snd->buffer_length = sys->thread_clone->buffer_length;
+               }
+               else
+               {
+                       snd->clip_start = 0;
+                       snd->clip_end = sys->end;
+                       snd->buffer_length = sys->end;
+               }
        }
        
        MUTEX_UNLOCK( sfx_mux_t01 );
@@ -50,13 +64,28 @@ static void sfx_internal_debug_overlay(void)
                u32 alpha = (infos[i].flags & SFX_FLAG_GHOST)? 0x44000000: 0xff000000;
 
                ui_new_node( &ui_global_ctx );
-               {
+               {               
                        ui_fill_rect( &ui_global_ctx, ui_global_ctx.cursor, 0x00333333 | alpha );
                        
-                       ui_rect_pad( ui_global_ctx.cursor, 2 );
-                       ui_global_ctx.cursor[2] = (int)(((float)infos[i].cursor / (float)infos[i].length) * 150.0f);
+                       ui_px baseline = ui_global_ctx.cursor[0];
+                       ui_px width_block_1 = (ui_px)(((float)infos[i].clip_start / (float)infos[i].buffer_length) * 150.0f);
+                       ui_px width_block_2 = (ui_px)(((float)(infos[i].buffer_length-infos[i].clip_end) / (float)infos[i].buffer_length) * 150.0f );
+                       
+                       ui_global_ctx.cursor[2] = width_block_1;
+                       ui_fill_rect( &ui_global_ctx, ui_global_ctx.cursor, 0x77ffffff );
+                       
+                       ui_global_ctx.cursor[2] = width_block_2;
+                       ui_align_right( &ui_global_ctx );
                        ui_fill_rect( &ui_global_ctx, ui_global_ctx.cursor, 0x77ffffff );
                        
+                       // Cursor
+                       
+                       ui_global_ctx.cursor[2] = 2;
+                       ui_global_ctx.cursor[0] = baseline + (ui_px)(((float)infos[i].cursor / (float)infos[i].buffer_length) * 150.0f);
+                       ui_fill_rect( &ui_global_ctx, ui_global_ctx.cursor, 0xffffffff );
+                       
+                       ui_global_ctx.cursor[0] = baseline + 2;
+                       ui_global_ctx.cursor[1] += 2;
                        ui_text( &ui_global_ctx, infos[i].name, 1, 0 );
                }
                ui_end_down( &ui_global_ctx );