tomwalters@0: % method of class @signal tomwalters@0: % function sig=changesr(sig,sr_neu) tomwalters@0: % changes the sample rate of the signal to the new samplerate. tomwalters@0: % the number of points of the signal change! tomwalters@0: % new values are interpolated tomwalters@0: % tomwalters@0: % INPUT VALUES: tomwalters@0: % sig1: first @signal tomwalters@0: % sr_new: new samplerate tomwalters@0: % tomwalters@0: % RETURN VALUE: tomwalters@0: % sigresult: @signal ` bleeck@3: % 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 sig=changesr(a,sr_neu) tomwalters@0: tomwalters@0: sr_alt=a.samplerate; tomwalters@0: if fround(sr_alt,5)==fround(sr_neu,5) %nichts zu tun tomwalters@0: sig=a; tomwalters@0: return; tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: if sr_neu > sr_alt tomwalters@0: r=round(sr_neu/sr_alt); tomwalters@0: % r=sr_neu/sr_alt; tomwalters@0: % y = interp(a.werte,r); tomwalters@0: x_val_new = a.start_time+1/sr_neu:1/sr_neu:getlength(a); tomwalters@0: x_val_old = a.start_time+1/sr_alt:1/sr_alt:getlength(a); tomwalters@0: y = interp1(x_val_old, a.werte, x_val_new, 'cubic'); tomwalters@0: else tomwalters@0: p=sr_neu; tomwalters@0: q=sr_alt; tomwalters@0: y = resample(a.werte,p,q); tomwalters@0: end tomwalters@0: tomwalters@0: sig=signal(y); tomwalters@0: sig.samplerate=sr_neu; tomwalters@0: sig.name=a.name; tomwalters@0: sig.unit_x=a.unit_x; tomwalters@0: sig.unit_y=a.unit_y; tomwalters@0: sig.start_time=a.start_time; tomwalters@0: sig.nr_x_ticks=a.nr_x_ticks; tomwalters@0: sig.x_tick_labels=a.x_tick_labels;