From: hgn Date: Wed, 27 Oct 2021 22:27:57 +0000 (+0100) Subject: more comprehensive audio visualizer X-Git-Url: https://harrygodden.com/git/?p=fishladder.git;a=commitdiff_plain;h=f8e80fde4a84a6b990ec17c067b2a95847ae744c more comprehensive audio visualizer --- diff --git a/fishladder.c b/fishladder.c index e8a8a3f..e024fca 100644 --- a/fishladder.c +++ b/fishladder.c @@ -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 ++ ) { diff --git a/sound/random_01.ogg b/sound/random_01.ogg index 193d24c..48e3813 100644 Binary files a/sound/random_01.ogg and b/sound/random_01.ogg differ diff --git a/sound/random_02.ogg b/sound/random_02.ogg index f1a46f4..79e26be 100644 Binary files a/sound/random_02.ogg and b/sound/random_02.ogg differ diff --git a/sound/random_03.ogg b/sound/random_03.ogg index 07aee2f..e3b80ab 100644 Binary files a/sound/random_03.ogg and b/sound/random_03.ogg differ diff --git a/sound/random_04.ogg b/sound/random_04.ogg index 307a714..0dcf020 100644 Binary files a/sound/random_04.ogg and b/sound/random_04.ogg differ diff --git a/sound/random_05.ogg b/sound/random_05.ogg index dbdbc02..fdcd57d 100644 Binary files a/sound/random_05.ogg and b/sound/random_05.ogg differ diff --git a/sound/random_06.ogg b/sound/random_06.ogg index 65b35c6..cc29f86 100644 Binary files a/sound/random_06.ogg and b/sound/random_06.ogg differ diff --git a/sound/random_07.ogg b/sound/random_07.ogg index 401dc25..bf2818e 100644 Binary files a/sound/random_07.ogg and b/sound/random_07.ogg differ diff --git a/sound/random_08.ogg b/sound/random_08.ogg index c190b34..844c772 100644 Binary files a/sound/random_08.ogg and b/sound/random_08.ogg differ diff --git a/sound/random_09.ogg b/sound/random_09.ogg index 1b55884..33c95fe 100644 Binary files a/sound/random_09.ogg and b/sound/random_09.ogg differ diff --git a/sound/rolling_01.ogg b/sound/rolling_01.ogg index b0f41ac..6a79597 100644 Binary files a/sound/rolling_01.ogg and b/sound/rolling_01.ogg differ diff --git a/sound/rolling_02.ogg b/sound/rolling_02.ogg index 95c3b3d..e6bc695 100644 Binary files a/sound/rolling_02.ogg and b/sound/rolling_02.ogg differ diff --git a/sound/rolling_03.ogg b/sound/rolling_03.ogg index c408d3e..3ffbbb7 100644 Binary files a/sound/rolling_03.ogg and b/sound/rolling_03.ogg differ diff --git a/sound/splitter_01.ogg b/sound/splitter_01.ogg index 2d524fd..a145fbd 100644 Binary files a/sound/splitter_01.ogg and b/sound/splitter_01.ogg differ diff --git a/vg/vg_audio.h b/vg/vg_audio.h index e375a5b..c0a3720 100644 --- a/vg/vg_audio.h +++ b/vg/vg_audio.h @@ -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 ); } } diff --git a/vg/vg_debug.h b/vg/vg_debug.h index ba61dd2..333aed8 100644 --- a/vg/vg_debug.h +++ b/vg/vg_debug.h @@ -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 );