toolkit manual

Upload: aura-auro

Post on 11-Jul-2015

367 views

Category:

Documents


1 download

TRANSCRIPT

1

SRT Matlab Audio Toolkit ManualRevised 2009,2010,2011

2

Foreword.................................................................................................6 User Notes...............................................................................................7 Simple Oscillators.....................................................................................7 cosine.......................................................................................................................7 one_shot...................................................................................................................7 osc............................................................................................................................8 saw ..........................................................................................................................8 sine..........................................................................................................................8 spike.........................................................................................................................8 sqr............................................................................................................................9 synthesize................................................................................................................9 tri.............................................................................................................................9 unit...........................................................................................................................9 Other Sound Generators.........................................................................10 formant..................................................................................................................10 fm_instr..................................................................................................................10 mygrain, mygrainu.................................................................................................11 noisefilter...............................................................................................................11 pluck, plucklp.........................................................................................................11 powernoise.............................................................................................................11 Shepard..................................................................................................................12 vowel......................................................................................................................12 Synthesizer Units...................................................................................13 vca.........................................................................................................................13 vcf..........................................................................................................................13 vco (MATLAB).........................................................................................................13 Filters....................................................................................................14 EQ10......................................................................................................................14 FIRlow ....................................................................................................................14 FIRpass...................................................................................................................15 FIRstop...................................................................................................................15 flt............................................................................................................................15 nlreson...................................................................................................................16 parmeq...................................................................................................................17 peq (equalizer).......................................................................................................17 shelving..................................................................................................................17 Vibrato and Tremolo...............................................................................18 tremolo...................................................................................................................18 vibrato....................................................................................................................18 Dynamics Processing..............................................................................18 agc.........................................................................................................................18 a_r..........................................................................................................................19 compexp ...............................................................................................................19 crossfade................................................................................................................19 env.........................................................................................................................19 expa_r....................................................................................................................20 expattack...............................................................................................................20

3expdecay................................................................................................................20 FadeIn....................................................................................................................21 FadeOut..................................................................................................................21 follow......................................................................................................................21 inflimit....................................................................................................................21 limiter.....................................................................................................................22 rms.........................................................................................................................22 Delay Lines............................................................................................22 allpdelay.................................................................................................................22 crossdelay..............................................................................................................23 firdelay...................................................................................................................23 iirdelay...................................................................................................................23 lpiirdelay................................................................................................................24 multiecho...............................................................................................................24 tdl, (tapped delay line)...........................................................................................24 pad.........................................................................................................................24 unidelay.................................................................................................................25 vardelay.................................................................................................................25 Reverb Units..........................................................................................25 artrvb.....................................................................................................................25 schroeder...............................................................................................................27 Spatial Effects........................................................................................27 autopan..................................................................................................................27 delaypan................................................................................................................27 phaseinvert............................................................................................................28 specpan..................................................................................................................28 spreader.................................................................................................................28 spreadnoise............................................................................................................29 stereopan...............................................................................................................29 Pitch- and Time-Shifting Functions..........................................................30 deci........................................................................................................................30 interp_move (pitch shift)........................................................................................30 lint..........................................................................................................................30 pitch_shift...............................................................................................................31 pv_move (pitch shift)..............................................................................................31 pvoc (time scale)....................................................................................................31 resample (MATLAB)................................................................................................32 time_stretch...........................................................................................................32 Miscellaneous Digital FX.........................................................................32 atx (pitch quantization)..........................................................................................32 auto_wah................................................................................................................33 cross_synthesis......................................................................................................33 dispersion...............................................................................................................33 flanger....................................................................................................................34 fuzzexp...................................................................................................................34 f_warp....................................................................................................................34 leslie.......................................................................................................................34 morph.....................................................................................................................35 mutate...................................................................................................................35 noisegt...................................................................................................................35

4phaser....................................................................................................................36 robotize..................................................................................................................36 symclip...................................................................................................................36 wah........................................................................................................................37 wah_wah................................................................................................................37 whisperize..............................................................................................................37 Denoising...............................................................................................37 BT (block thresholding)..........................................................................................37 denoise...................................................................................................................38 xerase ...................................................................................................................38 Stereo....................................................................................................39 destereo.................................................................................................................39 stereo.....................................................................................................................39 Data Conversions...................................................................................39 abs2dbfs.................................................................................................................39 freq2midi................................................................................................................40 midi2freq................................................................................................................40 General Vector Operations......................................................................40 colvec.....................................................................................................................40 fastconv.................................................................................................................41 mix.........................................................................................................................41 mul.........................................................................................................................41 rev, reverse............................................................................................................41 rowvec....................................................................................................................42 trim2......................................................................................................................42 Data Analysis.........................................................................................42 magresponse..........................................................................................................42 pwrspec..................................................................................................................42 Matlab Sound Functions..........................................................................43 sound, soundsc......................................................................................................43 wavread.................................................................................................................43 wavwrite.................................................................................................................43 Text-to-speech.......................................................................................43 text2speech...........................................................................................................43 tts (Windows only)..................................................................................................44 Text-to-speech For Macintosh................................................................................44 Demos...................................................................................................44 agcDemo................................................................................................................44 BTDemo.................................................................................................................44 compressionDemo..................................................................................................45 cross_synthesisDemo.............................................................................................45 CVdemo..................................................................................................................45 CVCdemo...............................................................................................................45 dispersionDemo.....................................................................................................45 FMDemo.................................................................................................................45 formantDemo.........................................................................................................45 leslieDemo.............................................................................................................45

5noisegtDemo..........................................................................................................45 pvocDemo..............................................................................................................45 unidelayDemo........................................................................................................45 vowelDemo............................................................................................................45

6

ForewordThe Audio Toolkit is a compilation of Matlab functions drawn from many sources. It was possible to make this collection because the results of so many of the most advanced audio research projects have been published in the form of Matlab code. Many of the routines in the Toolkit have been modified somewhat from their original published form. Usually this was done to achieve greater computational efficiency (I attempted to make the execution time of each function no greater than the time it takes to play its output). In some other cases, a function was modified to make it easier to use or to perform an operation different from the one it was originally designed to perform. The Toolkit is intended primarily for the use of my students. If any of the Toolkits routines are used by others for a different purpose, all code not written by me must be properly credited to its authors, and the authors restrictions on the use of their code must be respected. The source of each routine is indicated in the M-file below the routines definition. Where no source is indicated, I am the author. Stuart Smith Chelmsford, MA August 2011

7

User Notes1. Except as noted, Toolkit functions accept either row- or column-vector arguments and return row-vector results. 2. Whenever a Toolkit function does not have a sample rate (sr) parameter, you should assume that the sample rate for both input and output is 44.1 kHz. 3. Toolkit functions have been successfully tested with audio-friendly input arguments, but they do little or no checking of argument values. 4. The Matlab Signal Processing Toolbox contains many additional functions useful for audio signal processing. Check it out.

Simple Oscillatorscosiney = cosine( freq , dur , sr ) Generates samples of a sinewave 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 samples

one_shoty = one_shot( dur , wave , start , finish , sr ) A one-shot oscillator. Creates one cycle of an arbitrary waveform defined in a user-supplied wave table. The table contains one cycle of the desired waveform. A partial cycle can be obtained by specifying start and finish values within the cycle. Example: s = sine( 1 , 1 , 65536 ) ; % large table is no big deal for Matlab y = one_shot( 2 , s , 0.25 , 0.75 , 44100 ) ; % middle half of sine plot( y ) Inputs: dur wave start finish sr Output: y = = = = = signal duration in seconds user-supplied vector of one cycle of the desired waveform fraction of cycle where output begins: 0=