more comprehensive audio visualizer
[fishladder.git] / vg / vg_audio.h
index 249bedc8f390452ba9a98adab4d6cbaecee7d535..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;
@@ -36,8 +38,6 @@ struct sfx_system
        u32 ch, end, cur;
        u32 flags;
        
-       int is_queued;
-       
        // Effects
        u32 fadeout, fadeout_current;
        
@@ -229,29 +229,19 @@ static int sfx_begin_edit( sfx_system *sys )
 {
        MUTEX_LOCK( sfx_mux_t01 );
        
-       if( sys->is_queued )
+       if( sfx_q_len >= SFX_MAX_SYSTEMS )
        {
                MUTEX_UNLOCK( sfx_mux_t01 );
-               
-               vg_warn( "Sfx system locked for writing.. Spam is being created!\n" );
+               vg_warn( "Warning: No free space in sound queue\n" );           
                return 0;
        }
        
-       sys->is_queued = 1;
        return 1;
 }
 
 // Mark change to be uploaded to queue system
 static int sfx_save( sfx_system *sys )
 {
-       if( sfx_q_len >= SFX_MAX_SYSTEMS )
-       {
-               vg_error( "Warning: No free space in sound queue\n" );
-               
-               MUTEX_UNLOCK( sfx_mux_t01 );
-               return 0;
-       }
-       
        // Mark change in queue
        sfx_q[ sfx_q_len ++ ] = sys;
        
@@ -383,8 +373,6 @@ void audio_mixer_callback( ma_device *pDevice, void *pOutBuf, const void *pInput
        while( sfx_q_len --> 0 )
        {
                sfx_system *src = sfx_q[sfx_q_len];
-               src->is_queued = 0;
-               
                sfx_system *clone;
                
                // This is a 'new' sound if thread_clone not set.
@@ -653,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 );
        }
 }