}
channels[ AUDIO_CHANNELS ];
- int debug_ui, debug_ui_3d, debug_dsp;
+ int debug_ui, debug_ui_3d, debug_dsp, dsp_enabled;
v3f internal_listener_pos,
internal_listener_ears,
float internal_global_volume,
external_global_volume;
}
-static vg_audio = { .external_global_volume = 1.0f };
+static vg_audio = { .external_global_volume = 1.0f, .dsp_enabled = 1 };
#include "vg/vg_audio_dsp.h"
k_var_dtype_f32, VG_VAR_PERSISTENT );
vg_console_reg_var( "vg_audio_device", &vg_audio.device_choice,
k_var_dtype_str, VG_VAR_PERSISTENT );
+ vg_console_reg_var( "vg_dsp", &vg_audio.dsp_enabled,
+ k_var_dtype_i32, VG_VAR_PERSISTENT );
}
static void vg_audio_init(void){
vg_profile_end( &_vg_prof_audio_mix );
}
-static void audio_mixer_callback( void *user, u8 *stream, int byte_count )
-{
+static void audio_mixer_callback( void *user, u8 *stream, int byte_count ){
/*
* Copy data and move edit flags to commit flags
* ------------------------------------------------------------- */
audio_lock();
+ int use_dsp = vg_audio.dsp_enabled;
v3_copy( vg_audio.external_listener_pos, vg_audio.internal_listener_pos );
v3_copy( vg_audio.external_listener_ears, vg_audio.internal_listener_ears );
}
}
- vg_profile_begin( &_vg_prof_dsp );
-
- for( int i=0; i<frame_count; i++ )
- vg_dsp_process( pOut32F + i*2, pOut32F + i*2 );
-
- vg_profile_end( &_vg_prof_dsp );
+ if( use_dsp ){
+ vg_profile_begin( &_vg_prof_dsp );
+ for( int i=0; i<frame_count; i++ )
+ vg_dsp_process( pOut32F + i*2, pOut32F + i*2 );
+ vg_profile_end( &_vg_prof_dsp );
+ }
audio_lock();
#include "vg.h"
#include "vg_imgui.h"
+#ifdef VG_GAME_SETTINGS
+static void vg_game_settings_gui( ui_rect panel ) ;
+static void vg_game_settings_init(void);
+#endif
+
struct ui_enum_opt vg_settings_vsync_enum[] = {
{ 0, "None" },
{ 1, "On" },
{ 2, "Floating Window" }
};
+struct ui_enum_opt vg_settings_dsp_enum[] = {
+ { 1, "Enabled" },
+ { 0, "Disabled" },
+};
+
struct {
struct vg_setting_ranged_i32{
i32 new_value, *actual_value, min, max;
u32 option_count;
const char *label;
}
- vsync, quality, screenmode, audio_devices;
+ vsync, quality, screenmode, audio_devices, dsp;
i32 temp_audio_choice;
int windowed_before[4];
.options = vg_settings_screen_mode_enum, .option_count=3 },
.audio_devices = { .label = "Audio Device",
.actual_value = &vg_settings.temp_audio_choice,
- .options = NULL, .option_count = 0 }
+ .options = NULL, .option_count = 0 },
+ .dsp = { .label = "Audio effects (reverb etc.)",
+ .actual_value = &vg_audio.dsp_enabled,
+ .options = vg_settings_dsp_enum, .option_count=2 },
};
static void vg_settings_ui_draw_diff( ui_rect orig ){
ui_text( rect, name, 1, k_ui_align_middle_center, ui_colour(k_ui_fg+3) );
}
+
+static bool vg_settings_apply_button( ui_rect inout_panel, bool validated ){
+ ui_rect last_row;
+ ui_px height = (vg_ui.font->glyph_height + 18) * k_ui_scale;
+ ui_split( inout_panel, k_ui_axis_h, -height, k_ui_padding,
+ inout_panel, last_row );
+
+ const char *string = "Apply";
+ if( validated ){
+ if( ui_button( last_row, string ) == 1 )
+ return 1;
+ }
+ else{
+ ui_rect rect;
+ ui_standard_widget( last_row, rect, 1 );
+ ui_fill( rect, ui_colour( k_ui_bg+1 ) );
+ ui_outline( rect, -1, ui_colour( k_ui_red ), 0 );
+
+ ui_rect t = { 0,0, ui_text_line_width( string ), 14 };
+ ui_rect_center( rect, t );
+ ui_text( t, string, 1, k_ui_align_left, ui_colour(k_ui_fg+3) );
+ }
+
+ return 0;
+}
+
static void vg_settings_video_apply(void){
if( vg_settings_enum_diff( &vg_settings.screenmode ) ){
vg.screen_mode = vg_settings.screenmode.new_value;
ui_standard_widget( panel, duo, 1 );
vg_settings_enum( &vg_settings.screenmode, duo );
- /* apply */
- ui_rect last_row;
- ui_px height = (vg_ui.font->glyph_height + 18) * k_ui_scale;
- ui_split( panel, k_ui_axis_h, -height, k_ui_padding,
- panel, last_row );
-
- const char *string = "Apply";
- if( validated ){
- if( ui_button( last_row, string ) == 1 )
- vg_settings_video_apply();
- }
- else{
- ui_rect rect;
- ui_standard_widget( last_row, rect, 1 );
- ui_fill( rect, ui_colour( k_ui_bg+1 ) );
- ui_outline( rect, -1, ui_colour( k_ui_red ), 0 );
-
- ui_rect t = { 0,0, ui_text_line_width( string ), 14 };
- ui_rect_center( rect, t );
- ui_text( t, string, 1, k_ui_align_left, ui_colour(k_ui_fg+3) );
- }
+ if( vg_settings_apply_button( panel, validated ) )
+ vg_settings_video_apply();
}
static void vg_settings_audio_apply(void){
*vg_settings.audio_devices.actual_value =
vg_settings.audio_devices.new_value;
}
+
+ audio_lock();
+ if( vg_settings_enum_diff( &vg_settings.dsp ) ){
+ *vg_settings.dsp.actual_value =
+ vg_settings.dsp.new_value;
+ }
+
+ audio_unlock();
}
static void vg_settings_audio_gui( ui_rect panel ){
ui_rect rq;
ui_standard_widget( panel, rq, 1 );
vg_settings_enum( &vg_settings.audio_devices, rq );
+
+ ui_standard_widget( panel, rq, 1 );
+ vg_settings_enum( &vg_settings.dsp, rq );
- const char *string = "Apply";
-
- ui_rect last_row;
- ui_px height = (vg_ui.font->glyph_height + 18) * k_ui_scale;
- ui_split( panel, k_ui_axis_h, -height, k_ui_padding,
- panel, last_row );
-
- if( ui_button( last_row, string ) == 1 )
+ if( vg_settings_apply_button( panel, 1 ) )
vg_settings_audio_apply();
}
}
ui_settings_enum_init( &vg_settings.audio_devices );
+ ui_settings_enum_init( &vg_settings.dsp );
+
+#ifdef VG_GAME_SETTINGS
+ vg_game_settings_init();
+#endif
}
static void vg_settings_close(void){
ui_rect_pad( panel, (ui_px[2]){ 8, 8 } );
+ const char *opts[] = { "video", "audio",
+#ifdef VG_GAME_SETTINGS
+ "game"
+#endif
+ };
+
static i32 page = 0;
- ui_tabs( panel, panel, (const char *[]){ "video", "audio", "game" },
- 3, &page );
+ ui_tabs( panel, panel, opts, vg_list_size(opts), &page );
if( page == 0 ){
vg_settings_video_gui( panel );
}
else if( page == 1 )
vg_settings_audio_gui( panel );
+
+#ifdef VG_GAME_SETTINGS
+ else if( page == 2 )
+ vg_game_settings_gui( panel );
+#endif
}
static int cmd_vg_settings_toggle( int argc, const char *argv[] ){