Home > fcn > DIVA_GUI_callbacks > gui_vocaltract_cbk.m

gui_vocaltract_cbk

PURPOSE ^

SYNOPSIS ^

function gui_vocaltract_cbk(src,eventdata,options)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function gui_vocaltract_cbk(src,eventdata,options)
0002   switch(get(src,'tag'))
0003     %---------------------Set duration of VT simulation-----------------------%
0004    case {'duration'},
0005     value=str2num(get(src,'string'));
0006     DIVA('GUI','duration',value);
0007     
0008     %---------------------Reset/Randomize vocal tract configuration-----------%
0009    case {'random','reset'}
0010     if(strcmp(get(src,'tag'),'random'))
0011       names=options;
0012       config=round(100*((2*DIVA('VocalTract','MaedaSpread'))*...
0013                         (rand(length(names),1)-0.5)))/100;
0014       for i=1:length(names)
0015         params(i).name=names{i};
0016         params(i).value=config(i);
0017       end
0018     else
0019       names=options{1};
0020       glot_label=options{2};
0021       config=zeros(length(names),1);
0022       for i=1:length(names)
0023         params(i).name=names{i};
0024         params(i).value=config(i);
0025       end
0026       config=[];
0027       config=[0.01 0.2 100];
0028       for i=1:length(glot_label)
0029         params(i+length(names)).name=glot_label{i};
0030         params(i+length(names)).value=config(i);
0031       end
0032     end
0033     DIVA('GUI','artic_edit',params);
0034     DIVA('GUI','artic_slider',params);
0035     DIVA('GUI','VT_Configuration','update');
0036     artic=DIVA('GUI','artic_slider',[]);
0037     temp=DIVA('VocalTract','motor',artic);
0038     %DIVA('GUI','FmtSpace_crosshairs',mel(temp{1}));
0039     DIVA('GUI','FmtSpace_crosshairs',(temp{1}));
0040     DIVA('GUI','FmtValues',temp{1});
0041 
0042     %DIVA('GUI','Cochlea_plot','update');
0043     
0044     %----------------------------Set individual articulators/glottal params ----%%
0045    case 'articslider',
0046     set(src,'value',(round(get(src,'value')*100)/100));
0047     params.name=get(src,'UserData');
0048     params.value=get(src,'Value');
0049     DIVA('GUI','artic_edit',params);
0050     DIVA('GUI','VT_Configuration','update');
0051     artic=DIVA('GUI','artic_slider',[]);
0052     temp=DIVA('VocalTract','motor',artic);
0053     %DIVA('GUI','FmtSpace_crosshairs',mel(temp{1}));
0054     DIVA('GUI','FmtSpace_crosshairs',(temp{1}));
0055     DIVA('GUI','FmtValues',temp{1});
0056     %  DIVA('GUI','Cochlea_plot','update');
0057 
0058    case 'articedit',
0059     edit_value=str2double(get(src,'string'));
0060     if(abs(edit_value)>DIVA('VocalTract','MaedaSpread'))
0061       set(src,'string',...
0062               sprintf('%1.2f',(edit_value/abs(edit_value))*...
0063                       DIVA('VocalTract','MaedaSpread')));
0064     end
0065     set(src,'string',sprintf('%1.2f',(round(str2double(get(src,'string'))*100)/100)));
0066     params.name=get(src,'UserData');
0067     params.value=str2double(get(src,'string'));
0068     DIVA('GUI','artic_slider',params);
0069     DIVA('GUI','VT_Configuration','update');
0070     artic=DIVA('GUI','artic_slider',[]);
0071     temp=DIVA('VocalTract','motor',artic);
0072     %DIVA('GUI','FmtSpace_crosshairs',mel(temp{1}));
0073     DIVA('GUI','FmtSpace_crosshairs',(temp{1}));
0074     DIVA('GUI','FmtValues',temp{1});
0075     %  DIVA('GUI','Cochlea_plot','update');
0076     
0077    case 'glotslider',
0078     set(src,'value',(round(get(src,'value')*100)/100));
0079     params.name=get(src,'UserData');
0080     params.value=get(src,'Value');
0081     DIVA('GUI','artic_edit',params);
0082 
0083    case 'glotedit',
0084     edit_value=str2double(get(src,'string'));
0085     params=get(src,'UserData');
0086     if(edit_value > params.max | edit_value < params.min)
0087       set(src,'string',sprintf('%1.2f', (edit_value>params.max)*params.max+...
0088                                (edit_value<params.min)*params.min));
0089     end
0090     set(src,'string',sprintf('%1.2f',(round(str2double(get(src,'string'))*100)/100)));
0091     nparams.name=params.name;
0092     nparams.value=str2double(get(src,'string'));
0093     DIVA('GUI','artic_slider',nparams);
0094 
0095     %---------------------------Update cochlea plot (NEEDS NEW FUNCTION)-----%
0096    case 'set',
0097     %DIVA('GUI','Cochlea_plot','update');
0098     artic=DIVA('GUI','artic_slider',[]);
0099     temp=DIVA('VocalTract','motor',artic);
0100     %DIVA('GUI','FmtSpace_crosshairs',mel(temp{1}));
0101     DIVA('GUI','FmtSpace_crosshairs',(temp{1}));
0102     DIVA('GUI','FmtValues',temp{1});
0103     
0104     %------------------------------Generate sound from articulator config-----%
0105     
0106    case 'generate',
0107     artics=options{1};
0108     glots=options{2};
0109     
0110     outa=DIVA('GUI','artic_slider',artics);
0111     outg=DIVA('GUI','glot_slider',glots);
0112     f0=outg(3);
0113     m=[outa;outg];
0114     %  duration=inputdlg('Sound Duration (ms): ','Enter Sound Duration...',1,{'300'});
0115     %  if(isempty(duration))
0116     %    msgbox('Sound Canceled...');
0117     %  else
0118     %   duration=str2num(duration{1});
0119     duration = DIVA('GUI','duration');
0120     m=repmat(m,1,ceil(duration));
0121     % taper F0 for authentic sound
0122     m(end,:)=pchip([0 ceil(duration/3) ceil(duration)],[f0-5 f0 f0-.25*f0],0:ceil(duration)-1);
0123     sound = DIVA('VocalTract','synthsound',m);
0124     soundview(sound{1},sound{2});
0125     wavwrite(sound{1},sound{2},fullfile(pwd,'RESULTS','sounds','lastheard.wav'));
0126     DIVA('GUI','Cochlea_plot',sound{1});
0127     % soundview(sound,DIVA('VocalTract','fs'));
0128 %    end
0129 
0130     %-------------------------Learn sound produced from current config-------%
0131    case 'learn',
0132     artics=options{1};
0133     glots=options{2};
0134     
0135     outa=DIVA('GUI','artic_slider',artics);
0136     outg=DIVA('GUI','glot_slider',glots);
0137     f0=outg(3);
0138     fmt = DIVA('GUI','FmtValues');
0139     m=[outa;outg];
0140     desc=inputdlg({'Sound Label: ','Sound Duration (ms): '},...
0141                   'Sound Description...',1,{'','300'});
0142     if(isempty(desc))
0143       msgbox('Learning Canceled...');
0144     else
0145       label=desc{1};
0146       dur=str2num(desc{2});
0147       dur = ceil(dur);
0148       % taper F0 for authentic sound
0149       F0 = [(0:dur-1)' ...
0150              pchip([0 ceil(dur/3) dur],[f0-5 f0 f0-.25*f0],0:dur-1)' ...
0151              ones(dur,1)];
0152       AgP=[(0:dur-1)',repmat(outg(2),dur,1),ones(ceil(dur),1)];
0153       Ag0=[(0:dur-1)',repmat(outg(1),dur,1),ones(ceil(dur),1)];
0154 
0155       if(size(fmt,1)>size(fmt,2))
0156         fmt=fmt';
0157       end
0158       f.mean = repmat(fmt,dur,1);
0159       f.var =repmat([400 2500 10000],dur,1);      
0160       name = label;
0161       target.pathname=['Sessiontargets',filesep,'Session_',DIVA('SessionName'),filesep];
0162       target.filename=[label,'.mat'];
0163       save([target.pathname,target.filename],'f','Ag0','AgP','F0','dur','name');
0164       % set current file
0165       DIVA('SoundChannel','sound',f.mean');
0166       DIVA('AuditoryCortexCategorical','label',label);
0167       DIVA('simulate');
0168       DIVA('GUI','ACC_AuditoryTargets','update');
0169 %           DIVA('AuditoryCortexCategorical','AuditoryTargets'));
0170       DIVA('GUI','auTarget',target);
0171       DIVA('GUI','train_sound');
0172     end
0173   end

Generated on Tue 27-Mar-2007 12:06:24 by m2html © 2003