Adding feature for itaVA experimental GUI: volume control and signal source...

Adding feature for itaVA experimental GUI: volume control and signal source play-state control. Also fixing some bugs with internal variable storage.
parent c90c2089
function varargout = itaVA_experimental_gui(varargin)
% ITAVA_EXPERIMENTAL_GUI MATLAB code for itaVA_experimental_gui.fig
% ITAVA_EXPERIMENTAL_GUI, by itself, creates a new ITAVA_EXPERIMENTAL_GUI or raises the existing
% singleton*.
% ITAVA_EXPERIMENTAL_GUI VirtualAcoustics (VA) GUI adapter for simple FIR filter switch auralization
%
% Connect to a running VA server instance, play back sounds and
% exchange filters of your workspace to make an FIR filter set of aribatrary channel number
% audible. Input data is only considered if current workspace
% variable is of itaAudio type and time data can be accessed.
%
% This GUI requires an enabled generic path prototype renderer in
% VACore. The number of channels is fixed and has to match the channels provided in
% the renderer. Basically, a real-time convolution engine is set up
% and it's FIR filters can be exchanged instantaneously using Matlab
% and the VAMatlab TCP/IP network interface.
%
% H = ITAVA_EXPERIMENTAL_GUI returns the handle to a new ITAVA_EXPERIMENTAL_GUI or the handle to
% the existing singleton*.
% To configure itaVA, call itaVA_setup. To run the experimental
% VA server, call itaVA_experimental_renderer_prepare and itaVA_experimental_start_server
%
% ITAVA_EXPERIMENTAL_GUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in ITAVA_EXPERIMENTAL_GUI.M with the given input arguments.
% If the VA server is printing a lot of "empty output" warnings, you
% can ignore them. It is a hint that the rendering processor produces
% zeros, which is normal if your initial FIR filter is empty. This is
% the default behaviour.
%
% ITAVA_EXPERIMENTAL_GUI('Property','Value',...) creates a new ITAVA_EXPERIMENTAL_GUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before itaVA_experimental_gui_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to itaVA_experimental_gui_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help itaVA_experimental_gui
% Last Modified by GUIDE v2.5 24-Mar-2017 11:30:53
% Last Modified by GUIDE v2.5 04-Apr-2017 22:31:45
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
......@@ -45,7 +45,7 @@ end
% --- Executes just before itaVA_experimental_gui is made visible.
function itaVA_experimental_gui_OpeningFcn(hObject, eventdata, handles, varargin)
function itaVA_experimental_gui_OpeningFcn( hObject, ~, handles, varargin )
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
......@@ -56,15 +56,15 @@ function itaVA_experimental_gui_OpeningFcn(hObject, eventdata, handles, varargin
handles.output = hObject;
handles.va = itaVA;
handles.module_id = 'PrototypeGenericPath:MyGenericRenderer';
handles.va_source_id = 1;
handles.va_source_id = -1;
handles.va_signal_id = '';
handles.va_listener_id = 1;
handles.va_listener_id = -1;
refresh_workspace_vars( hObject, handles );
refresh_sourcesignals( hObject, handles );
% Update handles structure
guidata(hObject, handles);
guidata( hObject, handles );
......@@ -73,18 +73,18 @@ guidata(hObject, handles);
% --- Outputs from this function are returned to the command line.
function varargout = itaVA_experimental_gui_OutputFcn(hObject, eventdata, handles)
function varargout = itaVA_experimental_gui_OutputFcn( ~, ~, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
varargout{ 1 } = handles.output;
% --- Executes on button press in connect_connect_va.
function connect_connect_va_Callback(hObject, eventdata, handles)
function connect_connect_va_Callback( hObject, ~, handles )
% hObject handle to connect_connect_va (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
......@@ -94,19 +94,24 @@ end
handles.va.connect;
handles.va.reset;
gpg_renderer_list = [];
for n=1:numel( handles.va.getRenderingModules )
if strcmp( handles.va.getRenderingModules( n ).class, 'PrototypeGenericPath' )
gpg_renderer = handles.va.getRenderingModules( n );
break;
gpg_renderer_list = [ gpg_renderer_list handles.va.getRenderingModules( n ) ];
end
end
if ~exist( 'gpg_renderer', 'var' )
error( 'No prototype generic path renderer found, please add or enable in VA configuration.' )
if numel( gpg_renderer_list ) == 1
gpg_renderer = gpg_renderer_list( 1 );
elseif numel( gpg_renderer_list ) > 1
gpg_renderer = gpg_renderer_list( 1 );
warning( 'More than one prototype generic path renderer found. Using first.' )
else
disp( [ 'Using channel prototype generic path renderer with identifier: ' gpg_renderer.id ] )
error( 'No prototype generic path renderer found, please add or enable in VA configuration.' )
end
disp( [ 'Using channel prototype generic path renderer with identifier: ' gpg_renderer.id ] )
% Classic VA module call with input and output arguments
handles.module_id = [ gpg_renderer.class ':' gpg_renderer.id ];
in_args.info = true;
......@@ -115,15 +120,33 @@ disp( [ 'Your experimental renderer "' handles.module_id '" has ' num2str( out_a
handles.edit_va_channels.String = out_args.numchannels;
handles.edit_va_fir_taps.String = out_args.irfilterlengthsamples;
handles.edit_va_fs.String = '44.100';
handles.edit_va_fs.String = '44.100'; % @todo get from VA audio streaming settings
% example
% Useful FIRs
global ita_impulse;
ita_impulse = ita_merge( ita_generate_impulse, ita_generate_impulse );
if ~exist( 'ita_all_dirac', 'var' )
ita_impulse = ita_merge( ita_generate_impulse, ita_generate_impulse );
end
global ita_silence;
if ~exist( 'ita_all_silence', 'var' )
ita_silence = ita_merge( ita_generate_impulse, ita_generate_impulse ) * 0;
end
% Very simple scene with one path
handles.va_listener_id = handles.va.createListener( 'itaVA_ExperimentalListener' );
handles.va_source_id = handles.va.createSoundSource( 'itaVA_ExperimentalSource' );
handles.va_signal_id = '';
% VA control
handles.va.setOutputMuted( handles.checkbox_global_muted.Value );
handles.va.setOutputGain( handles.slider_volume.Value );
% Update handles (store values)
guidata( hObject, handles );
function edit_va_channels_CreateFcn(hObject, eventdata, handles)
......@@ -138,6 +161,11 @@ function listbox_filters_Callback(hObject, eventdata, handles)
% Hints: contents = cellstr(get(hObject,'String')) returns listbox_filters contents as cell array
% contents{get(hObject,'Value')} returns selected item from listbox_filters
index_selected = handles.listbox_filters.Value;
if isempty( index_selected )
return
end
filter_list = handles.listbox_filters.String;
filter_selected = filter_list{ index_selected };
......@@ -176,7 +204,7 @@ end
% --- Executes on selection change in listbox_sourcesignals.
function listbox_sourcesignals_Callback(hObject, eventdata, handles)
function listbox_sourcesignals_Callback( hObject, ~, handles )
% hObject handle to listbox_sourcesignals (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
......@@ -190,18 +218,38 @@ filepath_selected = filepath_list{ index_selected };
filename_selected = filename_list{ index_selected };
if handles.va.isConnected
ss_infos = handles.va.getSignalSourceInfos;
for i=1:numel( ss_infos )
va_signal_id_old = handles.va_signal_id;
if ~isempty( va_signal_id_old ) && strcmp( handles.va.getSoundSourceSignalSource( handles.va_source_id ), va_signal_id_old )
playstate = handles.va.getAudiofileSignalSourcePlaybackState( va_signal_id_old );
if strcmpi( playstate, 'playing' )
handles.va.setAudiofileSignalSourcePlaybackAction( handles.va_signal_id, 'pause' );
else
handles.va.setAudiofileSignalSourcePlaybackAction( handles.va_signal_id, 'play' );
end
else
if ~isempty( va_signal_id_old )
handles.va.setSoundSourceSignalSource( handles.va_source_id, '' );
handles.va.deleteSignalSource( va_signal_id_old );
end
handles.va_signal_id = handles.va.createAudiofileSignalSource( filepath_selected, filename_selected );
handles.va.setSoundSourceSignalSource( handles.va_source_id, handles.va_signal_id );
handles.va.setAudiofileSignalSourcePlaybackAction( handles.va_signal_id, 'play' );
is_looping = handles.checkbox_loop.Value;
handles.va.setAudiofileSignalSourceIsLooping( handles.va_signal_id, is_looping );
if ~isempty( va_signal_id_old )
handles.va.deleteSignalSource( va_signal_id_old );
end
end
handles.va_signal_id = handles.va.createAudiofileSignalSource( filepath_selected, filename_selected );
handles.va.setSoundSourceSignalSource( handles.va_source_id, handles.va_signal_id );
handles.va.setAudiofileSignalSourceIsLooping( handles.va_signal_id, true );
handles.va.setAudiofileSignalSourcePlaybackAction( handles.va_signal_id, 'play' );
end
% Update handles structure
guidata( hObject, handles );
% --- Executes during object creation, after setting all properties.
function listbox_sourcesignals_CreateFcn(hObject, eventdata, handles)
......@@ -298,7 +346,7 @@ function edit_va_fs_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function edit_va_fs_CreateFcn(hObject, eventdata, handles)
function edit_va_fs_CreateFcn( hObject, eventdata, handles )
% hObject handle to edit_va_fs (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
......@@ -316,3 +364,79 @@ function pushbutton_refresh_input_files_Callback(hObject, eventdata, handles)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
refresh_sourcesignals( hObject, handles )
% --- Executes on button press in checkbox_loop.
function checkbox_loop_Callback(hObject, eventdata, handles)
% hObject handle to checkbox_loop (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if handles.va.isConnected && ~isempty( handles.va_signal_id )
handles.va.setAudiofileSignalSourceIsLooping( handles.va_signal_id, get( hObject, 'Value' ) );
end
% --- Executes on button press in pushbutton_stop.
function pushbutton_stop_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_stop (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if handles.va.isConnected && ~isempty( handles.va_signal_id )
handles.va.setAudiofileSignalSourcePlaybackAction( handles.va_signal_id, 'stop' );
end
% --- Executes on button press in checkbox_global_muted.
function checkbox_global_muted_Callback(hObject, eventdata, handles)
% hObject handle to checkbox_global_muted (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if handles.va.isConnected
handles.va.setOutputMuted( get( hObject, 'Value' ) );
end
% --- Executes on slider movement.
function slider_volume_Callback(hObject, ~, handles)
% hObject handle to slider_volume (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if handles.va.isConnected
handles.va.setOutputGain( get( hObject, 'Value' ) );
end
handles.edit_output_volume.String = num2str( get( hObject, 'Value' ) );
% --- Executes during object creation, after setting all properties.
function slider_volume_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider_volume (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
function edit_output_volume_Callback(hObject, eventdata, handles)
% hObject handle to edit_output_volume (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_output_volume as text
% str2double(get(hObject,'String')) returns contents of edit_output_volume as a double
% --- Executes during object creation, after setting all properties.
function edit_output_volume_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_output_volume (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment