Home > . > DIVA_SensoryChannel.m

DIVA_SensoryChannel

PURPOSE ^

DIVA_SensoryChannel DIVA Sensory-Channel module

SYNOPSIS ^

function out=DIVA_SensoryChannel(varargin);

DESCRIPTION ^

 DIVA_SensoryChannel DIVA Sensory-Channel module

 This module incorporates any sensory transformations between
 the sensory percept produced by the vocal tract configuration
 and the actual sensory configuration perceived by the sensory module.

 DIVA_SensoryChannel('init' [,SessionName]);          Initializes the module
 DIVA_SensoryChannel('save' [,SessionName] );         Saves state 
 DIVA_SensoryChannel('exit');                         Exits the module (without saving)
 DIVA_SensoryChannel(PropertyName [,PropertyValue] )  Reads and writes internal model properties

 DIVA_SensoryChannel(ChannelName1,ChannelValue1,...
               ChannelName2,ChannelValue2,...); Executes module process(es)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function out=DIVA_SensoryChannel(varargin);
0002 % DIVA_SensoryChannel DIVA Sensory-Channel module
0003 %
0004 % This module incorporates any sensory transformations between
0005 % the sensory percept produced by the vocal tract configuration
0006 % and the actual sensory configuration perceived by the sensory module.
0007 %
0008 % DIVA_SensoryChannel('init' [,SessionName]);          Initializes the module
0009 % DIVA_SensoryChannel('save' [,SessionName] );         Saves state
0010 % DIVA_SensoryChannel('exit');                         Exits the module (without saving)
0011 % DIVA_SensoryChannel(PropertyName [,PropertyValue] )  Reads and writes internal model properties
0012 %
0013 % DIVA_SensoryChannel(ChannelName1,ChannelValue1,...
0014 %               ChannelName2,ChannelValue2,...); Executes module process(es)
0015 %
0016 
0017 % Dependencies:
0018 %
0019 
0020 out=[];
0021 global DIVA_SensoryChannel_data
0022 
0023 indexargin=1; 
0024 switch(varargin{indexargin}),
0025  case 'init',
0026   SessionFolder=strcat(DIVA('SessionFolder'),filesep);
0027   if nargin<indexargin+1 | isempty(varargin{indexargin+1}), 
0028     initfile=''; 
0029   else, 
0030     initfile=[SessionFolder,'Session_',varargin{indexargin+1},filesep,mfilename,'.mat']; 
0031   end
0032   if isempty(initfile) || isempty(dir(initfile)),
0033     disp([mfilename, ' : Defining new session...']);
0034     % INITIALIZES INTERNAL MODULE PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0035     DIVA_SensoryChannel_data.params=struct(...
0036         'delayToSensory',.0);  
0037     % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0038     
0039   else,
0040     data=load(initfile,'-mat');
0041     DIVA_SensoryChannel_data.params=data.params;
0042   end
0043   % INITIALIZES OTHER (TEMPORAL) PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0044   DIVA_SensoryChannel_data.params.current=struct(...
0045       'configuration',[],...
0046       'delay',[]);   
0047   % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0048   
0049   % LIST OF MODULE CHANNELS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0050   out={};   
0051   % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0052   
0053  case 'save',
0054   SessionFolder=strcat(DIVA('SessionFolder'),filesep);
0055   if nargin<indexargin+1, 
0056     initfile=[SessionFolder,'Session_','default',filesep,mfilename,'.mat']; 
0057   else, 
0058     initfile=[SessionFolder,'Session_',varargin{indexargin+1},filesep,mfilename,'.mat']; 
0059   end
0060   params=DIVA_SensoryChannel_data.params;
0061   save(initfile,'params'); 
0062   
0063  case 'exit',
0064   clear DIVA_SensoryChannel_data;
0065   % CODE FOR CLEARING MEMORY OR THE LIKE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0066   % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0067   
0068  case 'disp',
0069   disp(DIVA_SensoryChannel_data.params);
0070   out=fieldnames(DIVA_SensoryChannel_data.params);
0071   
0072   % CODE IMPLEMENTING THIS MODULE PROCESS(ES) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0073   % Note: use DIVA(ModuleName,ChannelName,data,delay) to comunicate with other DIVA modules
0074  case 'configuration',
0075   DIVA_SensoryChannel_data.current.configuration = varargin{indexargin+1};
0076   if nargin<indexargin+2 | isempty(varargin{indexargin+2}), 
0077     DIVA_SensoryChannel_data.current.delay = 0; 
0078   else, 
0079     DIVA_SensoryChannel_data.current.delay = varargin{indexargin+2}; 
0080   end
0081   DIVA_SensoryChannel_data.current.delay = ...
0082       DIVA_SensoryChannel_data.current.delay + ...
0083       DIVA_SensoryChannel_data.params.delayToSensory;
0084   
0085   if ~nargout,
0086     DIVA('Sensory','configuration',...
0087          DIVA_SensoryChannel_data.current.configuration,...
0088          DIVA_SensoryChannel_data.current.delay); 
0089   else, 
0090     out={DIVA_SensoryChannel_data.current.configuration}; 
0091   end
0092   
0093   % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0094   
0095  otherwise,
0096   if isfield(DIVA_SensoryChannel_data.params,varargin{indexargin}),
0097     if indexargin==nargin, 
0098       out=DIVA_SensoryChannel_data.params.(varargin{indexargin}); 
0099     else, 
0100       DIVA_SensoryChannel_data.params.(varargin{indexargin})=varargin{indexargin+1}; 
0101     end
0102   else, 
0103     warning('DIVA_SensoryChannel: wrong argument'); 
0104   end
0105 end

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