channel->clip = NULL;
channel->ui_volume = 0;
channel->ui_pan = 0;
+ channel->ui_spacial_volume = 0;
+ channel->ui_spacial_pan = 0;
channel->ui_activity = k_channel_activity_wake;
struct audio_channel_controls *controls = get_audio_channel_controls( id );
return new_id;
}
+bool vg_audio_is_channel_using_clip( audio_channel_id id, audio_clip *clip )
+{
+ vg_audio_assert_lock();
+ audio_channel *channel = get_audio_channel( id );
+
+ if( channel->clip == clip ) return 1;
+ else return 0;
+}
+
void vg_audio_fadeout_flagged_audio( u32 flag, f32 length )
{
vg_audio_lock();
vg_audio_set_channel_clip( id, clip );
vg_audio_set_channel_group( id, group );
vg_audio_set_channel_volume( id, volume, 1 );
- vg_audio_set_channel_pan( id, volume, 1 );
+ vg_audio_set_channel_pan( id, pan, 1 );
vg_audio_add_channel_flags( id, AUDIO_FLAG_RELINQUISHED );
vg_audio_start_channel( id );
}
channel->ui_activity = state->activity;
channel->ui_volume = state->volume;
channel->ui_pan = state->pan;
+ channel->ui_spacial_volume = state->spacial_volume;
+ channel->ui_spacial_pan = state->spacial_pan;
if( controls->flags & AUDIO_FLAG_RELINQUISHED )
{
vg_strcatch( &str, (flags & AUDIO_FLAG_WORLD)? 'W': '_' );
vg_strcatch( &str, (flags & AUDIO_FLAG_NO_DOPPLER)? '_':'D' );
vg_strcatch( &str, (flags & AUDIO_FLAG_NO_DSP)? '_':'E' );
+ vg_strcatch( &str, (flags & AUDIO_FLAG_LOOP)? 'L':'_' );
const char *formats[] =
{
vg_strcat( &str, activties[channel->ui_activity] );
vg_strcat( &str, " " );
- f32 volume = audio_volume_integer_to_float( channel->ui_volume );
+ f32 volume = (f32)channel->ui_volume / (f32)AUDIO_VOLUME_100;
vg_strcati32r( &str, volume * 100.0f, 3, ' ' );
vg_strcatch( &str, '%' );
ui_rect row_l, row_r;
ui_split( row, k_ui_axis_v, 32, 2, row_l, row_r );
- //ui_rect indicator_l, indicator_r;
- //ui_split_ratio( row, k_ui_axis_v, 0.5f, 1, indicator_l, indicator_r );
+ ui_rect indicator_l, indicator_r;
+ ui_split_ratio( row_l, k_ui_axis_v, 0.5f, 1, indicator_l, indicator_r );
+
+ ui_fill( ctx, indicator_l, 0xff000000 );
+ if( volume > 0.01f )
+ {
+ f32 h = volume * (f32)indicator_l[3];
+ ui_rect vol_bar = { indicator_l[0], indicator_l[1] + indicator_l[3] - h, indicator_l[2], h };
+ ui_fill( ctx, vol_bar, 0xff00ff00 );
+
+ if( flags & AUDIO_FLAG_SPACIAL_3D )
+ {
+ f32 h = ((f32)channel->ui_spacial_volume / (f32)AUDIO_VOLUME_100) * (f32)indicator_l[3];
+ ui_rect space_bar = { indicator_l[0], indicator_l[1] + indicator_l[3] - h, indicator_l[2], 1 };
+ ui_fill( ctx, space_bar, 0xffffffff );
+ }
+ }
- //f32 volume = audio_volume_integer_to_float( channel->ui_volume );
- //ui_rect vol_bar;
- //ui_split_ratio( indicator_l, k_ui_axis_h, -volume, 0, vol_bar, indicator_l );
- //ui_fill( ctx, indicator_l, 0xff000000 );
- //ui_fill( ctx, vol_bar, 0xff00ff00 );
+ f32 pan = (f32)channel->ui_pan / (f32)AUDIO_PAN_RIGHT_100;
+ ui_fill( ctx, indicator_r, 0xff111111 );
+ f32 midpoint = (f32)indicator_r[0] + (f32)indicator_r[2] * 0.5f;
+
+ f32 pan_abs = fabsf(pan);
+ if( pan_abs > 0.01f )
+ {
+ ui_rect bar = { midpoint,indicator_r[1], pan_abs * (f32)indicator_r[2] * 0.5f, indicator_r[3] };
+
+ if( pan < 0.0f )
+ bar[0] -= (f32)bar[2];
- //ui_fill( ctx, indicator_r, 0xff111111 );
+ ui_fill( ctx, bar, 0xff00aaff );
+ }
+
+ if( flags & AUDIO_FLAG_SPACIAL_3D )
+ {
+ f32 w = ((f32)channel->ui_spacial_pan / (f32)AUDIO_PAN_RIGHT_100) * (f32)indicator_r[2] * 0.5f;
+ ui_rect space_bar = { midpoint+w, indicator_r[1], 1, indicator_r[3] };
+ ui_fill( ctx, space_bar, 0xffffffff );
+ }
ui_fill( ctx, row_r, 0xa0000000 | channel->ui_colour );
ui_text( ctx, row_r, buf, 1, k_ui_align_middle_left, 0 );