annotate aim-mat/tools/calculate_spectral_profile.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 % support file for 'aim-mat'
tomwalters@0 2 %
tomwalters@0 3 % This external file is included as part of the 'aim-mat' distribution package
bleeck@3 4 % (c) 2011, University of Southampton
bleeck@3 5 % Maintained by Stefan Bleeck (bleeck@gmail.com)
bleeck@3 6 % download of current version is on the soundsoftware site:
bleeck@3 7 % http://code.soundsoftware.ac.uk/projects/aimmat
bleeck@3 8 % documentation and everything is on http://www.acousticscale.org
tomwalters@0 9
tomwalters@0 10 function spectal_profile=calculate_spectral_profile(wave_file)
tomwalters@0 11 % function for Tim Griffith to plot the spectral profile from an simple
tomwalters@0 12 % model
tomwalters@0 13
tomwalters@0 14 % define the model:
tomwalters@0 15 model_file='simple_model.m'; % this can be exchanged against any model produced with aim-mat by selecting "save standalone parameter file"
tomwalters@0 16
tomwalters@0 17 % evaluate the model, so that it can passed to aimmat:
tomwalters@0 18 % ( you have to be in the same directory as the model file!)
tomwalters@0 19 [a,b,c]=fileparts(model_file);
tomwalters@0 20 eval(b);
tomwalters@0 21
tomwalters@0 22 % now there is a variable with the name all_parameters. Tell aimmat to
tomwalters@0 23 % use the given soundfile
tomwalters@0 24 all_options.signal.signal_name=wave_file;
tomwalters@0 25 % tell it to use the full length and the given samplerate (this could be
tomwalters@0 26 % changed here)
tomwalters@0 27 sig=loadwavefile(signal,wave_file);
tomwalters@0 28 all_options.signal.start_time=0;
tomwalters@0 29 all_options.signal.duration=getlength(sig);
tomwalters@0 30 all_options.signal.samplerate=getsr(sig);
tomwalters@0 31
tomwalters@0 32 % call aimmat with the appropriate model:
tomwalters@0 33 retdata=aim_ng(all_options);
tomwalters@0 34
tomwalters@0 35 % the nap is now caluclated and available in the returning data structure:
tomwalters@0 36 nap=retdata.data.nap;
tomwalters@0 37
tomwalters@0 38 % we need the data:
tomwalters@0 39 nap_values=getvalues(nap);
tomwalters@0 40
tomwalters@0 41 % and calculate the profile:
tomwalters@0 42 spectal_profile=sum(nap_values');
tomwalters@0 43
tomwalters@0 44 % figure
tomwalters@0 45 % % and plot it
tomwalters@0 46 % plot(spectal_profile);
tomwalters@0 47
tomwalters@0 48 % an easier (?) way to plot:
tomwalters@0 49 options.frequency_profile_scale=0.7/max(spectal_profile);
tomwalters@0 50 options.maximum_time_interval=getlength(sig);
tomwalters@0 51 options.turn_axis_vertically=0;
tomwalters@0 52 figure
tomwalters@0 53 plotfrequencyprofile(nap,options);
tomwalters@0 54