1 SRT Matlab Audio Toolkit Manual Spring Term 2009 2 User Notes....................................................................................................................... 4 Simple Oscillators ........................................................................................................... 4 cosine .......................................................................................................................... 4 sawtooth ...................................................................................................................... 4 sine .............................................................................................................................. 5 spike ............................................................................................................................ 5 square .......................................................................................................................... 5 synthesize .................................................................................................................... 6 unit .............................................................................................................................. 6 Other Sound Generators.................................................................................................. 6 fm_instr ....................................................................................................................... 6 lpnoise ......................................................................................................................... 7 mygrain ....................................................................................................................... 7 mygrainu ..................................................................................................................... 7 noisefilter .................................................................................................................... 7 pluck............................................................................................................................ 8 plucklp ........................................................................................................................ 8 vowel ........................................................................................................................... 8 Synthesizer Units ............................................................................................................ 8 vca ............................................................................................................................... 8 vcf ............................................................................................................................... 9 vco ............................................................................................................................... 9 Filters .............................................................................................................................. 9 flt ................................................................................................................................. 9 lpflt ............................................................................................................................ 10 shelving ..................................................................................................................... 10 Vibrato and Tremolo ..................................................................................................... 10 tremolo ...................................................................................................................... 10 vibrato ....................................................................................................................... 11 vibrato2 ..................................................................................................................... 11 vibratox ..................................................................................................................... 11 Envelope Shapers .......................................................................................................... 12 a_r (Matlab Student Edition) .................................................................................... 12 ar ............................................................................................................................... 12 env ............................................................................................................................. 12 FadeIn ....................................................................................................................... 12 FadeOut ..................................................................................................................... 13 Delay Lines ................................................................................................................... 13 allpdelay .................................................................................................................... 13 delay .......................................................................................................................... 13 firdelay ...................................................................................................................... 14 iirdelay ...................................................................................................................... 14 lpiirdelay ................................................................................................................... 14 unidelay ..................................................................................................................... 15 3 Pitch- and Time-Shifting Functions .............................................................................. 15 deci ............................................................................................................................ 15 lint ............................................................................................................................. 15 pitch_shift ................................................................................................................. 16 resample .................................................................................................................... 16 time_stretch ............................................................................................................... 16 Miscellaneous Digital FX ............................................................................................. 17 auto_wah ................................................................................................................... 17 denoise ...................................................................................................................... 17 flanger ....................................................................................................................... 17 fuzzexp ...................................................................................................................... 18 inflimit ...................................................................................................................... 18 leslie .......................................................................................................................... 18 limiter ........................................................................................................................ 19 mutate........................................................................................................................ 19 noisegt ....................................................................................................................... 19 phaser ........................................................................................................................ 20 robotize ..................................................................................................................... 20 spreader ..................................................................................................................... 20 symclip ...................................................................................................................... 21 wah ............................................................................................................................ 21 wah_wah ................................................................................................................... 21 whisperize ................................................................................................................. 22 Stereo ............................................................................................................................ 22 destereo ..................................................................................................................... 22 stereo ......................................................................................................................... 22 General Vector Operations ........................................................................................... 23 fastconv ..................................................................................................................... 23 grand ......................................................................................................................... 23 mask .......................................................................................................................... 23 midi2freq ................................................................................................................... 23 mix ............................................................................................................................ 24 mvgrms ..................................................................................................................... 24 mul ............................................................................................................................ 24 reverse ....................................................................................................................... 25 trim ............................................................................................................................ 25 Data Analysis ................................................................................................................ 25 analyze ...................................................................................................................... 25 rifft ............................................................................................................................ 26 4 User Notes 1. Except as noted, Toolkit functions accept either row- or column-vector arguments. 2. Except as noted, Toolkit functions return row-vector results. 3. Toolkit functions have been successfully tested with audio-friendly input arguments, but they do little or no checking of argument values. 4. A few Toolkit functions are available under more than one name in order to avoid conflicts with functions already defined in the Matlab Student Edition. The correct function name to use in each of these special cases is noted in the documentation below. Simple Oscillators cosine y = cosine( freq , dur , sr ) Generates samples of a sine tone of specified frequency and duration. Inputs: freq = frequency in Hz. dur = duration in seconds sr = sample rate in samples per second Output y = vector of sine tone samples sawtooth y = sawtooth( freq , dur , sr ) Generates samples of a sawtooth tone of specified frequency and duration. Inputs: freq = frequency in Hz. dur = duration in seconds sr = sample rate in samples per second Output: y = vector of sawtooth tone samples 5 sine y = sine( freq , dur , sr ) Generates samples of a sine tone of specified frequency and duration. Inputs: freq = frequency in Hz. dur = duration in seconds sr = sample rate in samples per second Output: y = vector of sine tone samples spike y = spike( freq , dur , sr ) Generates a stream of unit impulses. Inputs: freq = frequency in Hz. dur = duration in seconds sr = sampling frequency in Hz. Output: y = impulse stream square y = square( freq , dur , sr ) Generates samples of a square wave tone of specified frequency and duration. Inputs: freq = frequency in Hz. dur = duration in seconds sr = sample rate in samples per second Output: y = vector of square wave tone samples 6 synthesize y = synthesize( freq , dur , amp , sr ) Performs additive synthesis of a tone with an arbitrary number of harmonics. Inputs: freq = dur = amp = sr = fundamental frequency in Hz. duration of the tone in seconds vector of amplitudes of the harmonics sample rate in samples per second Output: y = vector of samples of the synthesized tone unit y = unit( dur , sr ) Creates a unit impulse. Inputs: dur = duration of the time interval in which the impulse occurs sr = sample rate in samples per second Output: y = unit impulse Other Sound Generators fm_instr y = fm_instr( cf , cm , mi , amp , dur , sr ) Implements an FM instrument. The amp argument specifies the amplitudes of a single multi-segment linear envelope, which is applied both to output amplitude and modulation index. The modulating frequency is obtained by c:m ratio. See FMDemo for a demonstration of the use of fm_instr. Inputs: cf = cm = mi = amp = carrier frequency in Hz. c:m ratio modulation index vector of ending amplitudes of envelope segments (start is always 0) dur = vector of envelope segment durations in seconds sr = sample rate in samples per second Output y = vector of samples of the instrument sound 7 lpnoise y = lpnoise( cutoff , dur , sr ) Generates low-pass noise with specified cut-off frequency. Gaussian white noise is filtered by a 128-point Hanning-windowed ideal low-pass filter. Inputs: cutoff = lowpass cutoff frequency in Hz dur = duration in seconds sr = sample rate in samples per second Output: y = vector of samples of filtered noise mygrain mygrainu y = mygrain( cf , dur , dev , gs , sr ) y = mygrainu( cf , dur , dev , gs , sr ) Generates a segment of granular sound. Inputs: cf = center frequency of the segment dur = duration of the segment in seconds dev = average deviation above and below the center frequency, in Hz. gs = grain separation in seconds sr = sample rate in samples per second Output: y = vector of samples of granular sound noisefilter y = noisefilter( type , lf , hf , dur , sr ) Generates filtered white noise. Inputs: type = lf = hf = dur = sr = filter type (1=lowpass, 2=highpass, 3=bandpass, 4=notch) lowpass cutoff frequency in Hz. highpass cutoff frequency in Hz. duration of the example in seconds sample rate in samples per second Output: y = vector of samples of filtered noise 8 pluck plucklp y = pluck( freq , dur , pw , sr ) y = plucklp( freq , dur , pw , sr ) Simulates the sound of a plucked string using an IIR comb filter. A low-pass filter in the feedback loop of plucklp gives greater realism than can be achieved with pluck. Inputs: freq = dur = pw = sr = approximate frequency of output in Hz. duration of output in seconds width of driving pulse in samples sample rate in samples per second Output: y = vector of samples of plucked string sound vowel y = vowel( f0 , f1 , f2 , f3 , dur , sr ) Creates vowel sounds using formant filtering. See VowelDemo for a demonstration of the use of this function. Inputs: f0 = fundamental frequency of driving signal in Hz. f1, f2, f3 = formant frequencies in Hz. dur = duration in seconds sr = sample rate in samples per second Output: y = vector of samples of the vowel sound Synthesizer Units vca y = vca( x , ctrl ) Uses a control signal to regulate the gain of the input signal. The input signal should be in the range [-1,+1]. If the control signal goes negative, the corresponding output samples will be set to zero. If the input signal and the control signal are not of the same length, the longer will be trimmed to the length of the shorter. Inputs: x = input signal ctrl = control signal in the range [ 0 , 1 ] Output: y = vector of samples of the input signal with gain controlled by ctrl 9 vcf y = vcf( x , ctrl , fl , fh , d , sr ) Applies a control signal to a resonant filter to continuously update the filter’s center frequency. Inputs: x = ctrl = fl = fh = d = sr = input signal control signal in the range [ 0 , 1 ] lowest center frequency of the filter in Hz highest center frequency of the filter in Hz half-bandwidth of the filter in Hz. (100 Hz typical) sample rate in samples per second Output: y = vector of samples of the input signal filtered as specified vco y = vco( rf , vc , dev , wave , sr ) Simulates a voltage-controlled oscillator that generates an arbitrary waveform whose frequency is determined by a control input. The control signal, vc, is normalized and then multiplied by the frequency deviation, dev, to obtain the actual instantaneous frequency of the oscillator output. Because the sampling of the input waveform, wave, is fairly crude, the output waveform is denoised before it is returned to the calling program. Inputs: rf = vc = dev = wave = sr = reference frequency in Hz "voltage control" signal maximum deviation from reference frequency, in Hz. desired output waveform (vector, 512 samples typical) sample rate in samples per second Output: y = vector of samples of the oscillator tone Filters flt y = flt( x , F , D , R ) Implements a resonant bandpass filter. Inputs: x = signal to be filtered F = the center frequency of the filter in Hz. D = the half-bandwidth of the filter in Hz. R = the sample rate in samples per second Output: y = vector of samples of the filtered signal 10 lpflt y = lpflt( x , cutoff , sr ) Implements a 128-point Hanning-windowed ideal low-pass filter. Inputs: x = input signal cutoff = lowpass cutoff frequency in Hz. sr = sample rate in samples per second Output: y = vector of samples of the filtered signal shelving [ b , a ] = shelving( type , g , fc , Q , sr ) Derives coefficients for a shelving filter with a given amplitude and cutoff frequency. Use Matlab filter to apply filter to signal. See Toolkit ShelvingDemo for examples of the use of shelving. Inputs: type = a character string defining filter type. Choices are: 'Bass_Shelf' or 'Treble_Shelf' g = the logarithmic gain in dB; positive for boost, negative for cut fc = the center frequency Q = adjusts the slope sr = the sample rate in samples per second Outputs: [ b , a ] = filter coefficients to be used with Matlab filter Vibrato and Tremolo tremolo y = tremolo( x , lfo , mi , sr ) Applies tremolo to the input signal. Inputs: x = lfo = mi = sr = input signal tremolo frequency in Hz. tremolo depth (normally in the range [0,1]) sample rate in samples per second Output: y = vector of samples of the input signal with tremolo applied 11 vibrato y = vibrato( x , lfo , mi , sr ) Applies frequency modulation to the input signal. Because this function uses a fairly crude algorithm, it should be used only where a quickand-dirty process is acceptable. For the cleanest sound, use either vibrato2 or vibratox (which are two orders of magnitude slower than this function). Inputs: x = lfo = mi = sr = input signal vibrato frequency in Hz. (3-8 Hz typical) modulation index (0.001-0.005 typical) sample rate in samples per second Output: y = input signal with vibrato applied vibrato2 vibratox y = vibrato2( x , lfo , mi , sr ) y = vibratox( x , lfo , mi , sr ) Applies vibrato (low-frequency frequency modulation) to the input signal. These functions produce much cleaner results than the Toolkit function vibrato but they compute much more slowly. vibratox is slightly faster than vibrato2. Inputs: x = lfo = mi = sr = input signal vibrato frequency (5-8 Hz. typical) the depth of vibrato (0.05 typical) sample rate in samples per second Output: y = vector of samples of the input signal with vibrato applied 12 Envelope Shapers a_r (Matlab Student Edition) ar y = a_r( x , at , rt , sr ) y = ar( x , at , rt , sr ) A simple attack/release envelope shaper. Users of Matlab Student Edition must use a_r. Inputs: x = input signal at = attack time in seconds rt = release time in seconds sr = sample rate in samples per second Output: y = vector of samples of the input signal with the specified attack and release applied env y = env( amp , dur , sr ) Generates a multi-segment linear envelope. The envelope can be applied to a signal with mul or vca. Inputs: amp = vector containing the amplitude at the end of each segment(starting amplitude is always 0) dur = vector containing the durations of the segments sr = sample rate in samples per second Output: y = vector of samples of the specified envelope FadeIn y = FadeIn( x , sr , fa ) Attenuates the first fa*sr elements of the vector x linearly from 0 to 1. Inputs: x = input signal sr = sample rate in samples per second fa = fade-in time, in seconds Output: y = vector of samples of the input signal with specified fade-in 13 FadeOut y = FadeOut( x , sr , fa ) Attenuates the last fa*sr elements of the vector x linearly from 1 to 0. Inputs: x = input signal sr = sample rate in samples per second fa = fade-out time, in seconds Output: y = vector of samples of the input signal with specified fade-out Delay Lines allpdelay y = allpdelay( x , dur , g , sr ) The classic Manfred Schroeder allpass filter, which is typically used as an inexpensive reverb unit. Inputs: x = dur = g = sr = input signal length of delay in seconds gain in the range [ 0 , 1 ] sample rate in seconds Output: y = vector of samples of the filtered input signal delay [ a b ] = delay( x , dur , sr ) A simple delay-line. Vector x is delayed dur seconds and stored in output vector b. The original un-delayed vector is stored in output vector a. Both a and b are lengthened by padding with dur*sr zero samples. Inputs: x = input signal dur = delay time in seconds sr = sample rate in samples per second Outputs: a = original input vector (zero-padded at the end) b = delayed version of input vector (zero-padded at the beginning) 14 firdelay y = firdelay( x , dur , g , sr ) A single-delay fir comb filter. Inputs: x = input signal dur = delay time in seconds. Standard effects based on the length of the delay are: 0 - .020 sec = resonator .025 - .050 sec = slapback .050 sec = echo g = gain in the range [ 0 , 1 ] sr = sample rate in samples per second Output: y = vector of samples of the filtered input signal iirdelay function y = iirdelay( x , dur , g , sr ) A single-delay iir comb filter. This can be used for simple echo and reverb effects. Inputs: x = dur = g = sr = input signal delay time in seconds gain in the range [ 0 , 1 ] sample rate in samples per second Output: y = vector of samples of the filtered input signal lpiirdelay An iir comb filter with lowpass filter in the feedback loop. This configuration is often used in room simulators. Inputs: x = dur = g = sr = input signal length of delay in seconds gain in the range [ 0 , 1 ] sample rate in samples per second Output: y = vector of samples of the filtered input signal 15 unidelay y = unidelay( x , BL , FB , FF , dur , sr ) Universal (fir and iir) comb filter with a single delay. Inputs: x = BL = FB = FF = dur = sr = input signal blend control for feedforward of input sample gain for feedback (iir) in the range [ 0 , 1 ] gain for feedforward (fir) in the range [ 0 , 1 ] delay duration in seconds sample rate in samples per second Output: y = vector of samples of the filtered input signal Pitch- and Time-Shifting Functions deci y = deci( x , ratio ) Decimates the input signal, raising its pitch by up to one octave (e.g., a ratio of 2 gives the "chipmunk" or "munchkin" effect). NB: deci also reduces the length of the input signal by a factor of 1/ratio. Inputs: x ratio = input signal = pitch increase factor: >=1 and <= 2 Output: y = vector of samples of the decimated input signal lint y = lint( x , ratio ) Shifts the pitch of the input signal down by linearly interpolating between samples. NB: this function will lengthen the duration of the sound by a factor of 1/ratio. With speech input, this typically produces the effect of slurred, drunken speech. Inputs: x ratio = input signal = pitch reduction factor: >0 and <= 1 Output: y = vector of samples of the interpolated input signal 16 pitch_shift pitch_shift( x , r ) Performs pitch shifting. If r>1, pitch will be shifted up; if r<1, pitch will be shifted down. Duration is unaffected. Inputs: x = input vector r = ratio of output pitch to input pitch Output: y = vector of samples of the pitch-shifted input signal resample y = resample( x , oldsr , newsr ) Resamples an array of samples so it is usable at a higher or lower sample rate without change of pitch or duration. Inputs: x = input signal oldsr = original sample rate of x newsr = desired new sample rate Output: y = resampled signal time_stretch y = time_stretch( x , r ) This function performs time stretching. If r>0, duration will be increased; if r<1, duration will be reduced. Pitch is unaffected. Inputs: x = input signal r = ratio of output duration to input duration Output: y = vector of samples of the time-stretched input signal 17 Miscellaneous Digital FX auto_wah y = auto_wah( x , damp , minf , maxf , fw , sr ) State variable BP filter with narrow pass band. The center frequency oscillates up and down the spectrum to produce a continuous wah-wah effect. Inputs: x = input signal damp = damping factor (typically 0.05); the lower the damping factor the smaller the pass band. minf = minimum center cutoff frequency (typically 500 Hz) maxf = maximum center cutoff frequency (typically 3000 Hz) fw = center cutoff frequency change rate (typically 2000 Hz/sec) sr = sample rate in samples per second Output y = vector of samples of the input signal with wah-wah applied denoise y = denoise( x ) "Denoises" a signal Input: x = input signal Output: y = vector of samples of the denoised input signal flanger y = flanger( x , max_time_delay , rate , sr ) Creates a single delay, with the delay time oscillating from zero to max_time_delay seconds at the frequency specified by rate. Inputs: x max_time_delay rate sr Output: y = = = = input signal maximum flange delay in seconds (.003-.015 typical) flange delay oscillation rate in Hz. (3-10 typical) sample rate in samples per second = vector of samples of the flanged input signal 18 fuzzexp y = fuzzexp( x , gain , mix ) Creates distortion based on an exponential function. Inputs: x = input signal gain = amount of distortion, > 0 mix = mix of original and distorted sound: 1=only distorted Output: y = vector of samples of the distorted input signal. inflimit y = inflimit( x , a ) An infinite limiter. Restricts the level of the input signal so that the output level can never exceed the range [-1,+1] regardless of the input level. Inputs: x = input signal a = the limiter parameter. Typical values range from 0.5 to 2. As the value of a increases, the onset of limiting becomes increasingly abrupt at high signal levels. Outputs: y = vector of samples of the input signal limited as specified leslie y = leslie( x , lfo , td , vd , sr ) Simulates the effect of a rotary loudspeaker. See Toolkit LeslieDemo for a demonstration of the use of this function. Inputs: x = lfo = td = vd = sr = mono input signal speaker rotation rate in revolutions per second tremolo depth (~0.3) vibrato depth (~0.003) sample rate in samples per second Output y = stereo matrix, ready to used as input to sound or wavwrite 19 limiter y = limiter( x , thresh , rt , at ) Limits peak signal amplitude, with user-specified attack and release times. Inputs: x thresh rt at = = = = Output: y = vector of samples of the input signal with limiting applied input signal signal level at which gain is reduced release time (0.01 typical) attack time (0.4 typical) mutate y = mutate( x1 , x2 ) This function performs a mutation between two sounds, taking the phase of the first one and the modulus of the second one. The longer input vector is trimmed to the length of the shorter prior to processing to assure conformability. Inputs: x1 = input vector to provide phase information x2 = input vector to provide amplitude information Output: y = vector of samples of the mutated input signals noisegt y = noisegt( x , holdtime , ltrhold , utrhold , release , attack , a , sr ) Simulates a noise gate with hysteresis. Inputs: x = input vector holdtime = time in seconds the sound level has to be below the threshold value before the gate is activated ltrhold = threshold value for activating the gate utrhold = threshold value for deactivating the gate: > ltrhold release = time in seconds before the sound level reaches zero attack = time in seconds before the output sound level is the same as the input level after deactivating the gate a = pole placement of the envelope detecting filter: <1 sr = sample rate in samples per second Output: y = vector of samples of the gated input signal 20 phaser y = phaser( x , damp , minf , maxf , fw , sr ) State variable notch filter with narrow reject band. The center frequency oscillates up and down the spectrum, producing a continuous phasing effect. Inputs: x = input signal damp = damping factor (typically 0.1-0.3); the smaller the damping factor the greater the phasing effect. minf = minimum center cutoff frequency (typically 200 Hz) maxf = maximum center cutoff frequency (typically 1000 Hz) fw = phasing center frequency change rate (typically 1000-3000 Hz/sec) sr = sample rate in samples per second Output: y = vector of samples of the phased input signal robotize y = robotize( x ) Performs a "robotization" of sound, especially voice. Input: x = input signal Output: y = vector of samples of the robotized input signal spreader y = spreader( mono , delayL , delayR , pitchL , pitchR , mixer , sr ) Spreads mono input across the stereo image by applying slightly different time delays and pitch shifts to the left and right channels. The output is a stereo matrix ready to be sent to sound or wavwrite. Inputs: mono = mono input vector to be "spread" delayL = delay time in miliseconds for the left side (5 to 15 typical) delayR = delay time in miliseconds for the right side (5 to 15 typical) pitchL = pitch shift in cents for left side (+/-9 to +/-15 typical) pitchR = pitch shift in cents for right side (+/-9 to +/-15 typical) mixer = fraction of dry sound in final mix, in the range [ 0 , 1 ] sr = sample rate in samples per second Output: y = Nx2 stereo matrix of the spread signal 21 symclip y = symclip( x ) "Overdrive" simulation with symmetrical clipping. Input: x = input signal Output: y = vector of samples of the clipped input signal wah y = wah( x , FS , FF , D , R ) Simulates a "wah" effect. Inputs: x = input signal FS = center frequency of the filter in Hz. at start and end of wah (100 Hz typical) FF = center frequency of the filter in Hz. at middle of wah (1500 Hz. typical) D = half-bandwidth of the filter in Hz. (100 Hz. typical) R = sample rate in samples per second Output: y = vector of samples of the input signal with wah effect applied wah_wah y = wah_wah( x , wr , fs , ff , d , sr ) Applies a continuous "wah-wah" effect to the input signal. This function is similar to auto_wah but computes much faster. Inputs: x = input signal wr = wah-wah frequency in Hz (1-3 Hz typical) fs = center frequency of the filter in Hz at start and end of wah (100 Hz typical) ff = center frequency of the filter in Hz at middle of wah (1500 Hz typical) d = half-bandwidth of the filter in Hz. (100 Hz typical) sr = sample rate in samples per second Output: y = vector of samples of the input signal with wah-wah applied 22 whisperize y = whisperize( x , sr ) "Whisperizes" the input sound. Input: x = input signal sr = sample rate in samples per second Output: y = vector of samples of the input signal whisperized Stereo destereo [ a b ] = destereo( y ) The inverse of the stereo function: it separates a single Nx2 matrix into two 1xN row vectors. These vectors may then be manipulated by other Toolkit functions. Input: y = Nx2 matrix) Outputs: a , b = 1xN row vectors stereo y = stereo( a , b ) Combines two row vectors into a single Nx2 matrix that can be used as input to sound or wavwrite. If the input vectors do not have the same length, the longer will be trimmed to match the length of the shorter. Inputs: a , b = input signals Output: y = stereo matrix 23 General Vector Operations fastconv cxy = fastconv( x , y ) Fast convolution of vectors x and y. Inputs: x = input vector (typically an impulse response) y = input vector (typically sound samples) Output: cxy = x convolved with y grand y = grand( n ) Generates n normally distributed variates with mean = 0 and standard deviation = 1. Input: n = the desired number of variates Output: y = vector of n normally distributed variates mask y = mask( x , itype ) Applies a data window or “mask” to a vector. Inputs: x = input vector itype = window type (1-6): 1(Rectangular) 2(Tapered rectangular) 4(Hanning) 5(Hamming) 3(Triangular) 6(Blackman) Output: y = vector of samples of the input with mask applied midi2freq f = midi2freq( m ) Converts MIDI note numbers to frequencies in Hz. Input: m = vector or matrix of MIDI note numbers (0-127) Output: f = vector or matrix of the corresponding frequencies 24 mix y = mix( a , b ) Adds two input vectors and returns the sum. Prior to the addition, the longer vector will be trimmed to the length of the shorter to assure conformability. Inputs: a , b = vectors to be trimmed Output: y = elementwise sum of a and b mvgrms y = mvgrms( x , n ) A moving-window rms averager that can be used to extract the envelope of an audio signal. The envelope can be applied with mul or vca. Inputs: x = the signal to be processed n = the number of samples to be averaged in the rms calculation (1000-2000 typical at 44.1 kHz sample rate) Output: y = vector of samples of the averaged input signal mul y = mul( a , b ) Multiplies two input vectors and returns the product. Prior to the multiplication, the longer vector will be trimmed to the length of the shorter to assure conformability. Inputs: a , b = vectors to be multiplied Output: y = elementwise product of a and b 25 reverse y = reverse( x ) Reverses a vector. Octave users must use rev. Input: x = vector to be reversed Output: y = reversed vector trim [ a , b ] = trim( x , y ) Trims the length of the longer input vector to the length of the shorter vector Inputs: x , y = any vectors Outputs: a , b = row vectors trimmed to common length Data Analysis analyze [ f p ] = analyze( y , sr ) Computes the power spectrum of a vector of sound samples and plots it side-by-side with the original input signal Inputs: y = the array to be analyzed sr = sample rate in samples per second Outputs: f = vector of frequencies corresponding to the values in p p = the power spectrum amplitudes 26 rifft [ r i ] = rifft( y , sr ) Returns and plots the real and imaginary parts of the fft of a vector of sound samples Inputs: y = the signal to be analyzed sr = sample rate in samples per second Outputs: r = real part of fft i = imaginary part of fft