annotate aim-mat/tools/getsingleaif.m @ 4:537f939baef0 tip

various bug fixes and changed copyright message
author Stefan Bleeck <bleeck@gmail.com>
date Tue, 16 Aug 2011 14:37:17 +0100
parents 20ada0af3d7d
children
rev   line source
tomwalters@0 1 % tool
tomwalters@0 2 %
tomwalters@0 3 % INPUT VALUES:
tomwalters@0 4 %
tomwalters@0 5 % RETURN VALUE:
tomwalters@0 6 %
tomwalters@0 7 %
bleeck@3 8 % (c) 2011, University of Southampton
bleeck@3 9 % Maintained by Stefan Bleeck (bleeck@gmail.com)
bleeck@3 10 % download of current version is on the soundsoftware site:
bleeck@3 11 % http://code.soundsoftware.ac.uk/projects/aimmat
bleeck@3 12 % documentation and everything is on http://www.acousticscale.org
bleeck@3 13
tomwalters@0 14
tomwalters@0 15 function fr=getsingleaif(varargin)
tomwalters@0 16 % usage: fr=getsingleaif(varargin)
tomwalters@0 17 % produces only one frame from the (static) sound "soundfile"
tomwalters@0 18 % This frame is taken as with the makeaimmovie with the framesperseconds-parameter
tomwalters@0 19 % set to longer than the stimulus. Therefore the frame at the end of the signal duration is taken
tomwalters@0 20
tomwalters@0 21 temp_sound_file_name='temp.wav';
tomwalters@0 22
tomwalters@0 23 if nargin<2 % only one parameter -> read file
tomwalters@0 24 if size(varargin)==1
tomwalters@0 25 makefilename=varargin{1};
tomwalters@0 26 else
tomwalters@0 27 makefilename='lastrun.genmovie';
tomwalters@0 28 end
tomwalters@0 29 % fprintf('movie is produced from file %s from aifffile "makemovie_temp.aif"\n!',makefilename);
tomwalters@0 30 fprintf('aiff-file is produced according to file ''%s''\n',makefilename);
tomwalters@0 31 else
tomwalters@0 32 makefilename='lastrun.genmovie';
tomwalters@0 33 generateparameterfile(makefilename,varargin);
tomwalters@0 34 end
tomwalters@0 35
tomwalters@0 36 arguments=readparameterfile(makefilename);
tomwalters@0 37
tomwalters@0 38 str_model=getargument(arguments,'modelfile');
tomwalters@0 39 str_soundcommand=getargument(arguments,'soundfile');
tomwalters@0 40 str_movie_duration=getargument(arguments,'movie_duration');
tomwalters@0 41 str_movie_start_time=getargument(arguments,'movie_start_time');
tomwalters@0 42 str_output_normalization=getargument(arguments,'output_normalization');
tomwalters@0 43 str_sound_sample_rate=getargument(arguments,'sound_sample_rate');
tomwalters@0 44 str_sound_endian=getargument(arguments,'sound_endian');
tomwalters@0 45 str_echo=getargument(arguments,'echo');
tomwalters@0 46
tomwalters@0 47 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tomwalters@0 48 % read the sound command and transfere the data to the buffer
tomwalters@0 49 if ~isempty(str_movie_duration) % default frames per second
tomwalters@0 50 eval(sprintf('movie_duration=%s;',str_movie_duration));
tomwalters@0 51 eval(sprintf('movie_start_time=%s;',str_movie_start_time));
tomwalters@0 52 [sounddata,samplerate,bits,endian]=producesounddata(str_soundcommand,temp_sound_file_name,str_sound_sample_rate,str_sound_endian,movie_start_time,movie_duration);
tomwalters@0 53 else
tomwalters@0 54 movie_start_time=0;
tomwalters@0 55 [sounddata,samplerate,bits,endian]=producesounddata(str_soundcommand,temp_sound_file_name,str_sound_sample_rate,str_sound_endian);
tomwalters@0 56 movie_duration=length(sounddata)/samplerate;
tomwalters@0 57 end
tomwalters@0 58
tomwalters@0 59 videolength=size(sounddata,1)/samplerate;
tomwalters@0 60
tomwalters@0 61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tomwalters@0 62 % frames per second
tomwalters@0 63 framespersecond=1/videolength; %
tomwalters@0 64 framespersecond=framespersecond*1.001;
tomwalters@0 65
tomwalters@0 66 aiffs=getaiffs('modelfile',str_model,...
tomwalters@0 67 'soundfile',str_soundcommand,...
tomwalters@0 68 'framespersecond',sprintf('%f',framespersecond),...
tomwalters@0 69 'output_normalization',str_output_normalization,...
tomwalters@0 70 'movie_duration',movie_duration,...
tomwalters@0 71 'movie_start_time',movie_start_time,...
tomwalters@0 72 'echo',str_echo);
tomwalters@0 73 % aiffs=getaiffs('modelfile',str_model,...
tomwalters@0 74 % 'soundfile',temp_sound_file_name,...
tomwalters@0 75 % 'framespersecond',sprintf('%f',framespersecond),...
tomwalters@0 76 % 'output_normalization',str_output_normalization,...
tomwalters@0 77 % 'movie_duration',movie_duration,...
tomwalters@0 78 % 'movie_start_time',movie_start_time,...
tomwalters@0 79 % 'echo',str_echo);
tomwalters@0 80
tomwalters@0 81 fr=aiffs(1); % this is the one and only
tomwalters@0 82
tomwalters@0 83
tomwalters@0 84
tomwalters@0 85