Mercurial > hg > aimmat
annotate aim-mat/tools/@signal/attenuate.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 |
---|---|
bleeck@3 | 1 % method of class @signal |
bleeck@3 | 2 % |
bleeck@3 | 3 % INPUT VALUES: |
bleeck@3 | 4 % sig,attenuation |
bleeck@3 | 5 % sig is the signal |
bleeck@3 | 6 % attenuation is the attenuation against the lowdest possible tone |
bleeck@3 | 7 % |
bleeck@3 | 8 % |
bleeck@3 | 9 % |
bleeck@3 | 10 % RETURN VALUE: |
bleeck@3 | 11 % |
bleeck@3 | 12 % |
bleeck@3 | 13 % This external file is included as part of the 'aim-mat' distribution package |
bleeck@3 | 14 % (c) 2011, University of Southampton |
bleeck@3 | 15 % Maintained by Stefan Bleeck (bleeck@gmail.com) |
bleeck@3 | 16 % download of current version is on the soundsoftware site: |
bleeck@3 | 17 % http://code.soundsoftware.ac.uk/projects/aimmat |
bleeck@3 | 18 % documentation and everything is on http://www.acousticscale.org |
bleeck@3 | 19 |
bleeck@3 | 20 |
bleeck@3 | 21 |
bleeck@3 | 22 |
bleeck@3 | 23 function sig=attenuate(sig,attenuation) |
bleeck@3 | 24 |
bleeck@3 | 25 if attenuation==0 |
bleeck@3 | 26 return |
bleeck@3 | 27 end |
bleeck@3 | 28 |
bleeck@3 | 29 dat=sig.werte; |
bleeck@3 | 30 ma=max(dat); |
bleeck@3 | 31 mi=min(dat); |
bleeck@3 | 32 if -mi > ma |
bleeck@3 | 33 ma=-mi; |
bleeck@3 | 34 end |
bleeck@3 | 35 amphigh=ma; |
bleeck@3 | 36 |
bleeck@3 | 37 amp=amphigh / power(10,-attenuation/20); |
bleeck@3 | 38 if amp>0 |
bleeck@3 | 39 sig=scaletomaxvalue(sig,amp); |
bleeck@3 | 40 end |
bleeck@3 | 41 |