2014-05-27 21:46:05 -04:00
/*
2014-04-29 01:07:37 -05:00
Copyright ( C ) 2014 Waves Audio Ltd .
2014-05-27 21:46:05 -04:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 2 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*/
# include <stdlib.h>
2014-05-15 06:53:24 -05:00
# include <string>
2014-05-27 21:46:05 -04:00
# include "tracks_control_panel.h"
# include "waves_button.h"
# include "pbd/unwind.h"
# include <gtkmm2ext/utils.h>
2014-05-13 07:47:00 -05:00
# include "engine_state_controller.h"
2014-04-16 04:41:22 -05:00
# include "ardour/rc_configuration.h"
2014-05-06 03:21:18 -05:00
# include "device_connection_control.h"
2014-05-27 21:46:05 -04:00
# include "ardour_ui.h"
# include "gui_thread.h"
# include "utils.h"
# include "i18n.h"
2014-05-01 06:06:16 -05:00
# include "pbd/convert.h"
2014-05-27 21:46:05 -04:00
2014-05-13 07:47:00 -05:00
using namespace ARDOUR ;
2014-05-27 21:46:05 -04:00
using namespace Gtk ;
using namespace Gtkmm2ext ;
using namespace PBD ;
using namespace Glib ;
# define dbg_msg(a) MessageDialog (a, PROGRAM_NAME).run();
void
TracksControlPanel : : init ( )
{
2014-05-01 06:06:16 -05:00
_ok_button . signal_clicked . connect ( sigc : : mem_fun ( * this , & TracksControlPanel : : on_ok ) ) ;
_cancel_button . signal_clicked . connect ( sigc : : mem_fun ( * this , & TracksControlPanel : : on_cancel ) ) ;
_apply_button . signal_clicked . connect ( sigc : : mem_fun ( * this , & TracksControlPanel : : on_apply ) ) ;
_audio_settings_tab_button . signal_clicked . connect ( sigc : : mem_fun ( * this , & TracksControlPanel : : on_audio_settings ) ) ;
_midi_settings_tab_button . signal_clicked . connect ( sigc : : mem_fun ( * this , & TracksControlPanel : : on_midi_settings ) ) ;
_session_settings_tab_button . signal_clicked . connect ( sigc : : mem_fun ( * this , & TracksControlPanel : : on_session_settings ) ) ;
_control_panel_button . signal_clicked . connect ( sigc : : mem_fun ( * this , & TracksControlPanel : : on_control_panel ) ) ;
2014-04-16 04:41:22 -05:00
2014-05-01 06:06:16 -05:00
_multi_out_button . signal_clicked . connect ( sigc : : mem_fun ( * this , & TracksControlPanel : : on_multi_out ) ) ;
_stereo_out_button . signal_clicked . connect ( sigc : : mem_fun ( * this , & TracksControlPanel : : on_stereo_out ) ) ;
2014-04-16 04:41:22 -05:00
2014-05-13 07:47:00 -05:00
AudioEngine : : instance ( ) - > Running . connect ( running_connection , MISSING_INVALIDATOR , boost : : bind ( & TracksControlPanel : : engine_running , this ) , gui_context ( ) ) ;
AudioEngine : : instance ( ) - > Stopped . connect ( stopped_connection , MISSING_INVALIDATOR , boost : : bind ( & TracksControlPanel : : engine_stopped , this ) , gui_context ( ) ) ;
AudioEngine : : instance ( ) - > Halted . connect ( stopped_connection , MISSING_INVALIDATOR , boost : : bind ( & TracksControlPanel : : engine_stopped , this ) , gui_context ( ) ) ;
2014-05-27 21:46:05 -04:00
/* Subscribe for udpates from AudioEngine */
2014-05-13 07:47:00 -05:00
EngineStateController : : instance ( ) - > BufferSizeChanged . connect ( update_connections , MISSING_INVALIDATOR , boost : : bind ( & TracksControlPanel : : populate_buffer_size_combo , this ) , gui_context ( ) ) ;
EngineStateController : : instance ( ) - > DeviceListChanged . connect ( update_connections , MISSING_INVALIDATOR , boost : : bind ( & TracksControlPanel : : populate_device_combo , this ) , gui_context ( ) ) ;
2014-05-27 21:46:05 -04:00
2014-05-01 06:06:16 -05:00
_engine_combo . signal_changed ( ) . connect ( sigc : : mem_fun ( * this , & TracksControlPanel : : engine_changed ) ) ;
2014-05-15 06:53:24 -05:00
_device_combo . signal_changed ( ) . connect ( sigc : : bind ( sigc : : mem_fun ( * this , & TracksControlPanel : : device_changed ) , true ) ) ;
2014-05-01 06:06:16 -05:00
_sample_rate_combo . signal_changed ( ) . connect ( sigc : : mem_fun ( * this , & TracksControlPanel : : sample_rate_changed ) ) ;
_buffer_size_combo . signal_changed ( ) . connect ( sigc : : mem_fun ( * this , & TracksControlPanel : : buffer_size_changed ) ) ;
2014-05-27 21:46:05 -04:00
populate_engine_combo ( ) ;
2014-05-13 07:47:00 -05:00
populate_output_mode ( ) ;
2014-05-01 06:06:16 -05:00
_audio_settings_tab_button . set_active ( true ) ;
2014-05-27 21:46:05 -04:00
}
2014-05-06 03:21:18 -05:00
DeviceConnectionControl & TracksControlPanel : : add_device_capture_control ( std : : string device_capture_name , bool active , uint16_t capture_number , std : : string track_name )
{
DeviceConnectionControl & capture_control = * manage ( new DeviceConnectionControl ( device_capture_name , active , capture_number , track_name ) ) ;
_device_capture_list . pack_start ( capture_control , false , false ) ;
capture_control . signal_active_changed . connect ( sigc : : mem_fun ( * this , & TracksControlPanel : : on_capture_active_changed ) ) ;
return capture_control ;
}
DeviceConnectionControl & TracksControlPanel : : add_device_playback_control ( std : : string device_playback_name , bool active , uint16_t playback_number )
{
DeviceConnectionControl & playback_control = * manage ( new DeviceConnectionControl ( device_playback_name , active , playback_number ) ) ;
_device_playback_list . pack_start ( playback_control , false , false ) ;
playback_control . signal_active_changed . connect ( sigc : : mem_fun ( * this , & TracksControlPanel : : on_playback_active_changed ) ) ;
return playback_control ;
}
2014-05-12 09:21:16 -05:00
DeviceConnectionControl & TracksControlPanel : : add_midi_capture_control ( std : : string device_capture_name , bool active )
{
DeviceConnectionControl & capture_control = * manage ( new DeviceConnectionControl ( device_capture_name , active ) ) ;
_midi_capture_list . pack_start ( capture_control , false , false ) ;
capture_control . signal_active_changed . connect ( sigc : : mem_fun ( * this , & TracksControlPanel : : on_midi_capture_active_changed ) ) ;
return capture_control ;
}
DeviceConnectionControl & TracksControlPanel : : add_midi_playback_control ( bool active )
{
DeviceConnectionControl & playback_control = * manage ( new DeviceConnectionControl ( active ) ) ;
_midi_playback_list . pack_start ( playback_control , false , false ) ;
playback_control . signal_active_changed . connect ( sigc : : mem_fun ( * this , & TracksControlPanel : : on_midi_playback_active_changed ) ) ;
return playback_control ;
}
2014-05-27 21:46:05 -04:00
void
TracksControlPanel : : populate_engine_combo ( )
{
if ( _ignore_changes ) {
return ;
}
2014-05-01 06:06:16 -05:00
std : : vector < std : : string > strings ;
2014-05-13 07:47:00 -05:00
std : : vector < const AudioBackendInfo * > backends ;
EngineStateController : : instance ( ) - > available_backends ( backends ) ;
2014-05-27 21:46:05 -04:00
if ( backends . empty ( ) ) {
MessageDialog msg ( string_compose ( _ ( " No audio/MIDI backends detected. %1 cannot run \n \n (This is a build/packaging/system error. It should never happen.) " ), PROGRAM_NAME)) ;
msg . run ( ) ;
throw failed_constructor ( ) ;
}
2014-05-13 07:47:00 -05:00
for ( std : : vector < const AudioBackendInfo * > : : const_iterator b = backends . begin ( ) ; b ! = backends . end ( ) ; + + b ) {
2014-05-27 21:46:05 -04:00
strings . push_back ( ( * b ) - > name ) ;
}
{
// set _ignore_changes flag to ignore changes in combo-box callbacks
PBD : : Unwinder < uint32_t > protect_ignore_changes ( _ignore_changes , _ignore_changes + 1 ) ;
2014-05-01 06:06:16 -05:00
set_popdown_strings ( _engine_combo , strings ) ;
_engine_combo . set_sensitive ( strings . size ( ) > 1 ) ;
2014-05-27 21:46:05 -04:00
}
if ( ! strings . empty ( ) )
{
2014-05-13 07:47:00 -05:00
_engine_combo . set_active_text ( EngineStateController : : instance ( ) - > get_current_backend_name ( ) ) ;
2014-05-27 21:46:05 -04:00
}
}
void
TracksControlPanel : : populate_device_combo ( )
{
2014-05-13 07:47:00 -05:00
std : : vector < AudioBackend : : DeviceStatus > all_devices ;
EngineStateController : : instance ( ) - > enumerate_devices ( all_devices ) ;
2014-05-27 21:46:05 -04:00
2014-05-13 07:47:00 -05:00
std : : vector < std : : string > available_devices ;
2014-05-27 21:46:05 -04:00
2014-05-13 07:47:00 -05:00
for ( std : : vector < AudioBackend : : DeviceStatus > : : const_iterator i = all_devices . begin ( ) ; i ! = all_devices . end ( ) ; + + i ) {
2014-05-27 21:46:05 -04:00
available_devices . push_back ( i - > name ) ;
}
{
// set _ignore_changes flag to ignore changes in combo-box callbacks
PBD : : Unwinder < uint32_t > protect_ignore_changes ( _ignore_changes , _ignore_changes + 1 ) ;
2014-05-01 06:06:16 -05:00
set_popdown_strings ( _device_combo , available_devices ) ;
_device_combo . set_sensitive ( available_devices . size ( ) > 1 ) ;
2014-05-15 06:53:24 -05:00
if ( ! available_devices . empty ( ) ) {
_device_combo . set_active_text ( EngineStateController : : instance ( ) - > get_current_device_name ( ) ) ;
}
}
if ( ! available_devices . empty ( ) ) {
device_changed ( false ) ;
}
2014-05-27 21:46:05 -04:00
}
void
TracksControlPanel : : populate_sample_rate_combo ( )
{
2014-05-13 07:47:00 -05:00
std : : vector < float > sample_rates ;
EngineStateController : : instance ( ) - > available_sample_rates_for_current_device ( sample_rates ) ;
2014-05-27 21:46:05 -04:00
std : : vector < std : : string > s ;
2014-05-13 07:47:00 -05:00
for ( std : : vector < float > : : const_iterator x = sample_rates . begin ( ) ; x ! = sample_rates . end ( ) ; + + x ) {
2014-05-27 21:46:05 -04:00
s . push_back ( rate_as_string ( * x ) ) ;
}
{
// set _ignore_changes flag to ignore changes in combo-box callbacks
PBD : : Unwinder < uint32_t > protect_ignore_changes ( _ignore_changes , _ignore_changes + 1 ) ;
2014-05-01 06:06:16 -05:00
set_popdown_strings ( _sample_rate_combo , s ) ;
_sample_rate_combo . set_sensitive ( s . size ( ) > 1 ) ;
2014-05-27 21:46:05 -04:00
}
if ( ! s . empty ( ) ) {
2014-05-13 07:47:00 -05:00
std : : string active_sr = rate_as_string ( EngineStateController : : instance ( ) - > get_current_sample_rate ( ) ) ;
2014-05-01 06:06:16 -05:00
_sample_rate_combo . set_active_text ( active_sr ) ;
2014-05-27 21:46:05 -04:00
}
}
void
TracksControlPanel : : populate_buffer_size_combo ( )
{
2014-05-13 07:47:00 -05:00
std : : vector < std : : string > s ;
std : : vector < pframes_t > buffer_sizes ;
2014-05-27 21:46:05 -04:00
2014-05-13 07:47:00 -05:00
EngineStateController : : instance ( ) - > available_buffer_sizes_for_current_device ( buffer_sizes ) ;
for ( std : : vector < pframes_t > : : const_iterator x = buffer_sizes . begin ( ) ; x ! = buffer_sizes . end ( ) ; + + x ) {
2014-05-27 21:46:05 -04:00
s . push_back ( bufsize_as_string ( * x ) ) ;
}
{
// set _ignore_changes flag to ignore changes in combo-box callbacks
PBD : : Unwinder < uint32_t > protect_ignore_changes ( _ignore_changes , _ignore_changes + 1 ) ;
2014-05-01 06:06:16 -05:00
set_popdown_strings ( _buffer_size_combo , s ) ;
_buffer_size_combo . set_sensitive ( s . size ( ) > 1 ) ;
2014-05-27 21:46:05 -04:00
}
if ( ! s . empty ( ) ) {
2014-05-13 07:47:00 -05:00
std : : string active_bs = bufsize_as_string ( EngineStateController : : instance ( ) - > get_current_buffer_size ( ) ) ;
2014-05-01 06:06:16 -05:00
_buffer_size_combo . set_active_text ( active_bs ) ;
2014-05-27 21:46:05 -04:00
}
}
2014-05-13 07:47:00 -05:00
void
TracksControlPanel : : populate_output_mode ( )
{
_multi_out_button . set_active ( Config - > get_output_auto_connect ( ) & AutoConnectPhysical ) ;
_stereo_out_button . set_active ( Config - > get_output_auto_connect ( ) & AutoConnectMaster ) ;
}
2014-05-27 21:46:05 -04:00
void
2014-04-04 18:20:33 -05:00
TracksControlPanel : : on_control_panel ( WavesButton * )
2014-05-27 21:46:05 -04:00
{
2014-05-06 03:21:18 -05:00
// ******************************* ATTENTION!!! ****************************
// here is just demo code to remove it in future
// *************************************************************************
2014-05-13 07:47:00 -05:00
/*
2014-05-01 06:06:16 -05:00
static uint16_t number = 0 ;
static bool active = false ;
number + + ;
active = ! active ;
2014-05-12 09:21:16 -05:00
std : : string name = string_compose ( _ ( " Audio Capture %1 " ) , number ) ;
2014-05-06 03:21:18 -05:00
add_device_capture_control ( name , active , number , name ) ;
2014-05-12 09:21:16 -05:00
name = string_compose ( _ ( " Audio Playback Output %1 " ) , number ) ;
2014-05-06 03:21:18 -05:00
add_device_playback_control ( name , active , number ) ;
2014-05-12 09:21:16 -05:00
name = string_compose ( _ ( " Midi Capture %1 " ) , number ) ;
add_midi_capture_control ( name , active ) ;
add_midi_playback_control ( active ) ;
2014-05-13 07:47:00 -05:00
*/
2014-05-27 21:46:05 -04:00
}
void TracksControlPanel : : engine_changed ( )
{
if ( _ignore_changes ) {
return ;
}
2014-05-13 07:47:00 -05:00
std : : string backend_name = _engine_combo . get_active_text ( ) ;
if ( EngineStateController : : instance ( ) - > set_new_backend_as_current ( backend_name ) )
2014-05-27 21:46:05 -04:00
{
2014-05-13 07:47:00 -05:00
_have_control = EngineStateController : : instance ( ) - > is_setup_required ( ) ;
populate_device_combo ( ) ;
return ;
2014-05-27 21:46:05 -04:00
}
2014-05-13 07:47:00 -05:00
std : : cerr < < " \t failed to set backend [ " < < backend_name < < " ] \n " ;
2014-05-27 21:46:05 -04:00
}
2014-05-15 06:53:24 -05:00
void TracksControlPanel : : device_changed ( bool show_confirm_dial /*=true*/ )
2014-05-27 21:46:05 -04:00
{
if ( _ignore_changes ) {
return ;
}
2014-05-13 07:47:00 -05:00
std : : string device_name = _device_combo . get_active_text ( ) ;
2014-05-15 06:53:24 -05:00
if ( show_confirm_dial )
{
std : : string message = " Would you like to switch to " + device_name ;
MessageDialog msg ( message ,
false ,
Gtk : : MESSAGE_WARNING ,
Gtk : : BUTTONS_YES_NO ,
true ) ;
msg . set_position ( Gtk : : WIN_POS_MOUSE ) ;
switch ( msg . run ( ) ) {
case RESPONSE_NO :
// set _ignore_changes flag to ignore changes in combo-box callbacks
PBD : : Unwinder < uint32_t > protect_ignore_changes ( _ignore_changes , _ignore_changes + 1 ) ;
_device_combo . set_active_text ( EngineStateController : : instance ( ) - > get_current_device_name ( ) ) ;
return ;
}
}
2014-05-13 07:47:00 -05:00
if ( EngineStateController : : instance ( ) - > set_new_current_device_in_controller ( device_name ) )
{
populate_buffer_size_combo ( ) ;
populate_sample_rate_combo ( ) ;
return ;
2014-05-27 21:46:05 -04:00
}
2014-05-13 07:47:00 -05:00
{
// set _ignore_changes flag to ignore changes in combo-box callbacks
PBD : : Unwinder < uint32_t > protect_ignore_changes ( _ignore_changes , _ignore_changes + 1 ) ;
// restore previous device name in combo box
_device_combo . set_active_text ( EngineStateController : : instance ( ) - > get_current_device_name ( ) ) ;
}
MessageDialog ( _ ( " Selected device is not available for current engine " ) , PROGRAM_NAME ) . run ( ) ;
2014-05-27 21:46:05 -04:00
}
void
TracksControlPanel : : buffer_size_changed ( )
{
if ( _ignore_changes ) {
return ;
}
2014-05-13 07:47:00 -05:00
pframes_t new_buffer_size = get_buffer_size ( ) ;
if ( EngineStateController : : instance ( ) - > set_new_buffer_size_in_controller ( new_buffer_size ) )
{
show_buffer_duration ( ) ;
return ;
}
{
// set _ignore_changes flag to ignore changes in combo-box callbacks
PBD : : Unwinder < uint32_t > protect_ignore_changes ( _ignore_changes , _ignore_changes + 1 ) ;
// restore previous buffer size value in combo box
std : : string buffer_size_str = bufsize_as_string ( EngineStateController : : instance ( ) - > get_current_buffer_size ( ) ) ;
_buffer_size_combo . set_active_text ( buffer_size_str ) ;
}
MessageDialog ( _ ( " Buffer size set to the value which is not supported " ) , PROGRAM_NAME ) . run ( ) ;
2014-05-27 21:46:05 -04:00
}
void
TracksControlPanel : : sample_rate_changed ( )
{
if ( _ignore_changes ) {
return ;
}
2014-05-13 07:47:00 -05:00
framecnt_t new_sample_rate = get_sample_rate ( ) ;
if ( EngineStateController : : instance ( ) - > set_new_sample_rate_in_controller ( new_sample_rate ) )
2014-05-27 21:46:05 -04:00
{
2014-05-13 07:47:00 -05:00
show_buffer_duration ( ) ;
return ;
2014-05-27 21:46:05 -04:00
}
2014-05-13 07:47:00 -05:00
{
// set _ignore_changes flag to ignore changes in combo-box callbacks
PBD : : Unwinder < uint32_t > protect_ignore_changes ( _ignore_changes , _ignore_changes + 1 ) ;
// restore previous buffer size value in combo box
std : : string sample_rate_str = rate_as_string ( EngineStateController : : instance ( ) - > get_current_sample_rate ( ) ) ;
_sample_rate_combo . set_active_text ( sample_rate_str ) ;
2014-05-27 21:46:05 -04:00
}
2014-05-13 07:47:00 -05:00
MessageDialog ( _ ( " Sample rate set to the value which is not supported " ) , PROGRAM_NAME ) . run ( ) ;
2014-05-27 21:46:05 -04:00
}
void
TracksControlPanel : : engine_running ( )
{
2014-05-13 07:47:00 -05:00
_buffer_size_combo . set_active_text ( bufsize_as_string ( EngineStateController : : instance ( ) - > get_current_buffer_size ( ) ) ) ;
2014-05-27 21:46:05 -04:00
2014-05-13 07:47:00 -05:00
_sample_rate_combo . set_active_text ( rate_as_string ( EngineStateController : : instance ( ) - > get_current_sample_rate ( ) ) ) ;
2014-05-27 21:46:05 -04:00
2014-05-01 06:06:16 -05:00
_buffer_size_combo . set_sensitive ( true ) ;
_sample_rate_combo . set_sensitive ( true ) ;
2014-05-27 21:46:05 -04:00
}
void
TracksControlPanel : : engine_stopped ( )
{
}
void
2014-04-04 18:20:33 -05:00
TracksControlPanel : : on_audio_settings ( WavesButton * )
2014-05-27 21:46:05 -04:00
{
2014-05-01 06:06:16 -05:00
_midi_settings_layout . hide ( ) ;
_midi_settings_tab_button . set_active ( false ) ;
_session_settings_layout . hide ( ) ;
_session_settings_tab_button . set_active ( false ) ;
_audio_settings_layout . show ( ) ;
_audio_settings_tab_button . set_active ( true ) ;
2014-05-27 21:46:05 -04:00
}
void
2014-04-04 18:20:33 -05:00
TracksControlPanel : : on_midi_settings ( WavesButton * )
2014-05-27 21:46:05 -04:00
{
2014-05-01 06:06:16 -05:00
_audio_settings_layout . hide ( ) ;
_audio_settings_tab_button . set_active ( false ) ;
_session_settings_layout . hide ( ) ;
_session_settings_tab_button . set_active ( false ) ;
_midi_settings_layout . show ( ) ;
_midi_settings_tab_button . set_active ( true ) ;
2014-05-27 21:46:05 -04:00
}
2014-04-10 07:10:03 -05:00
void
TracksControlPanel : : on_session_settings ( WavesButton * )
{
2014-05-01 06:06:16 -05:00
_audio_settings_layout . hide ( ) ;
_audio_settings_tab_button . set_active ( false ) ;
_midi_settings_layout . hide ( ) ;
_midi_settings_tab_button . set_active ( false ) ;
_session_settings_layout . show ( ) ;
_session_settings_tab_button . set_active ( true ) ;
2014-04-10 07:10:03 -05:00
}
2014-04-16 04:41:22 -05:00
void
TracksControlPanel : : on_multi_out ( WavesButton * )
{
2014-05-13 07:47:00 -05:00
if ( Config - > get_output_auto_connect ( ) & AutoConnectPhysical ) {
2014-04-16 04:41:22 -05:00
return ;
}
2014-05-13 07:47:00 -05:00
Config - > set_output_auto_connect ( AutoConnectPhysical ) ;
2014-05-01 06:06:16 -05:00
_stereo_out_button . set_active ( false ) ;
_multi_out_button . set_active ( true ) ;
2014-04-16 04:41:22 -05:00
}
void
TracksControlPanel : : on_stereo_out ( WavesButton * )
{
2014-05-01 06:06:16 -05:00
2014-05-13 07:47:00 -05:00
if ( Config - > get_output_auto_connect ( ) & AutoConnectMaster ) {
2014-04-16 04:41:22 -05:00
return ;
}
2014-05-13 07:47:00 -05:00
Config - > set_output_auto_connect ( AutoConnectMaster ) ;
2014-05-01 06:06:16 -05:00
_multi_out_button . set_active ( false ) ;
_stereo_out_button . set_active ( true ) ;
2014-04-16 04:41:22 -05:00
}
2014-05-27 21:46:05 -04:00
void
2014-04-04 18:20:33 -05:00
TracksControlPanel : : on_ok ( WavesButton * )
2014-05-27 21:46:05 -04:00
{
hide ( ) ;
2014-05-13 07:47:00 -05:00
EngineStateController : : instance ( ) - > push_current_state_to_backend ( true ) ;
2014-05-27 21:46:05 -04:00
response ( Gtk : : RESPONSE_OK ) ;
}
void
2014-04-04 18:20:33 -05:00
TracksControlPanel : : on_cancel ( WavesButton * )
2014-05-27 21:46:05 -04:00
{
hide ( ) ;
response ( Gtk : : RESPONSE_CANCEL ) ;
}
void
2014-04-04 18:20:33 -05:00
TracksControlPanel : : on_apply ( WavesButton * )
2014-05-27 21:46:05 -04:00
{
2014-05-13 07:47:00 -05:00
EngineStateController : : instance ( ) - > push_current_state_to_backend ( true ) ;
2014-05-27 21:46:05 -04:00
response ( Gtk : : RESPONSE_APPLY ) ;
}
2014-05-06 03:21:18 -05:00
void TracksControlPanel : : on_capture_active_changed ( DeviceConnectionControl * capture_control , bool active )
{
// ******************************* ATTENTION!!! ****************************
// here is just demo code to replace it with a meaningful app logic in future
// *************************************************************************
capture_control - > set_number ( active ? 1000 : DeviceConnectionControl : : NoNumber ) ;
}
void TracksControlPanel : : on_playback_active_changed ( DeviceConnectionControl * playback_control , bool active )
{
// ******************************* ATTENTION!!! ****************************
// here is just demo code to replace it with a meaningful app logic in future
// *************************************************************************
playback_control - > set_number ( active ? 1000 : DeviceConnectionControl : : NoNumber ) ;
}
2014-05-12 09:21:16 -05:00
void TracksControlPanel : : on_midi_capture_active_changed ( DeviceConnectionControl * capture_control , bool active )
{
}
void TracksControlPanel : : on_midi_playback_active_changed ( DeviceConnectionControl * playback_control , bool active )
{
}
2014-05-27 21:46:05 -04:00
std : : string
TracksControlPanel : : bufsize_as_string ( uint32_t sz )
{
/* Translators: "samples" is always plural here, so no
need for plural + singular forms .
*/
char buf [ 32 ] ;
snprintf ( buf , sizeof ( buf ) , _ ( " %u samples " ) , sz ) ;
return buf ;
}
2014-05-13 07:47:00 -05:00
framecnt_t
2014-04-29 01:07:37 -05:00
TracksControlPanel : : get_sample_rate ( ) const
2014-05-27 21:46:05 -04:00
{
2014-05-01 06:06:16 -05:00
float r = atof ( _sample_rate_combo . get_active_text ( ) ) ;
2014-05-27 21:46:05 -04:00
/* the string may have been translated with an abbreviation for
* thousands , so use a crude heuristic to fix this .
*/
if ( r < 1000.0 ) {
r * = 1000.0 ;
}
return r ;
}
2014-05-13 07:47:00 -05:00
pframes_t TracksControlPanel : : get_buffer_size ( ) const
2014-05-27 21:46:05 -04:00
{
2014-05-13 07:47:00 -05:00
std : : string bs_text = _buffer_size_combo . get_active_text ( ) ;
pframes_t samples = atoi ( bs_text ) ; /* will ignore trailing text */
2014-05-27 21:46:05 -04:00
return samples ;
}
void
TracksControlPanel : : show_buffer_duration ( )
{
2014-04-29 01:07:37 -05:00
float latency = ( get_buffer_size ( ) * 1000.0 ) / get_sample_rate ( ) ;
2014-05-27 21:46:05 -04:00
char buf [ 256 ] ;
snprintf ( buf , sizeof ( buf ) , _ ( " INPUT LATENCY: %.1f MS OUTPUT LATENCY: %.1f MS TOTAL LATENCY: %.1f MS " ) ,
latency , latency , 2 * latency ) ;
2014-05-01 06:06:16 -05:00
_latency_label . set_text ( buf ) ;
2014-05-27 21:46:05 -04:00
}