tomwalters@0: % support file for 'aim-mat' tomwalters@0: % tomwalters@0: % This external file is included as part of the 'aim-mat' distribution package bleeck@3: % (c) 2011, University of Southampton bleeck@3: % Maintained by Stefan Bleeck (bleeck@gmail.com) bleeck@3: % download of current version is on the soundsoftware site: bleeck@3: % http://code.soundsoftware.ac.uk/projects/aimmat bleeck@3: % documentation and everything is on http://www.acousticscale.org tomwalters@0: tomwalters@0: function spectal_profile=calculate_spectral_profile(wave_file) tomwalters@0: % function for Tim Griffith to plot the spectral profile from an simple tomwalters@0: % model tomwalters@0: tomwalters@0: % define the model: tomwalters@0: model_file='simple_model.m'; % this can be exchanged against any model produced with aim-mat by selecting "save standalone parameter file" tomwalters@0: tomwalters@0: % evaluate the model, so that it can passed to aimmat: tomwalters@0: % ( you have to be in the same directory as the model file!) tomwalters@0: [a,b,c]=fileparts(model_file); tomwalters@0: eval(b); tomwalters@0: tomwalters@0: % now there is a variable with the name all_parameters. Tell aimmat to tomwalters@0: % use the given soundfile tomwalters@0: all_options.signal.signal_name=wave_file; tomwalters@0: % tell it to use the full length and the given samplerate (this could be tomwalters@0: % changed here) tomwalters@0: sig=loadwavefile(signal,wave_file); tomwalters@0: all_options.signal.start_time=0; tomwalters@0: all_options.signal.duration=getlength(sig); tomwalters@0: all_options.signal.samplerate=getsr(sig); tomwalters@0: tomwalters@0: % call aimmat with the appropriate model: tomwalters@0: retdata=aim_ng(all_options); tomwalters@0: tomwalters@0: % the nap is now caluclated and available in the returning data structure: tomwalters@0: nap=retdata.data.nap; tomwalters@0: tomwalters@0: % we need the data: tomwalters@0: nap_values=getvalues(nap); tomwalters@0: tomwalters@0: % and calculate the profile: tomwalters@0: spectal_profile=sum(nap_values'); tomwalters@0: tomwalters@0: % figure tomwalters@0: % % and plot it tomwalters@0: % plot(spectal_profile); tomwalters@0: tomwalters@0: % an easier (?) way to plot: tomwalters@0: options.frequency_profile_scale=0.7/max(spectal_profile); tomwalters@0: options.maximum_time_interval=getlength(sig); tomwalters@0: options.turn_axis_vertically=0; tomwalters@0: figure tomwalters@0: plotfrequencyprofile(nap,options); tomwalters@0: