{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf350 {\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fnil\fcharset0 Monaco;\f2\froman\fcharset0 Times-Roman; } {\colortbl;\red255\green255\blue255;\red0\green0\blue191;\red0\green0\blue0;\red191\green0\blue0; \red0\green0\blue191;\red96\green96\blue96;\red96\green96\blue96;\red0\green115\blue0;} \deftab560 \pard\pardeftab560\ql\qnatural \f0\b\fs36 \cf2 MFCC\cf3 mel frequency cepstral coefficients \b0 \ \pard\pardeftab560\ql\qnatural \fs24 \cf3 \ \b #coeff1, coeff2, ... = \cf2 MFCC\cf3 .kr(chain, numcoeff=13) \b0 \ \ \b chain [fft] - \b0 \cf2 Audio\cf3 input to track, which has been pre-analysed by the \cf2 FFT\cf3 \cf2 UGen\cf3 ; see examples below for the expected \cf2 FFT\cf3 size\ \b numcoeff [s] - \b0 \cf2 Number\cf3 of coefficients, defaults to 13, maximum of 42; more efficient to use less of course! \ \ \cf2 Generates\cf3 a set of \cf2 MFCCs\cf3 ; these are obtained from a band-based frequency representation (using the \cf2 Mel\cf3 scale by default), and then a discrete cosine transform (\cf2 DCT\cf3 ). \cf2 The\cf3 \cf2 DCT\cf3 is an efficient approximation for principal components analysis, so that it allows a compression, or reduction of dimensionality, of the data, in \cf2 this\cf3 case reducing 42 band readings to a smaller set of \cf2 MFCCs\cf3 . \cf2 A\cf3 small number of features (the coefficients) end up describing the spectrum. \cf2 The\cf3 \cf2 MFCCs\cf3 are commonly used as timbral descriptors. \ \ \cf2 Output\cf3 values are somewhat normalised for the range 0.0 to 1.0, but there are no guarantees on exact conformance to \cf2 this\cf3 . \cf2 Commonly\cf3 , the first coefficient will be the highest value. \ \ \pard\pardeftab560\ql\qnatural \f1\fs18 \cf4 //Technical note: The 0th coefficient is not generated as it consists of multiplying all bands by 1 and summing\cf3 \ \ \ \cf4 //assumes hop of half fftsize, fine\cf3 \ b = \cf2 Buffer\cf3 .alloc(s,1024,1); \cf4 //for sampling rates 44100 and 48000\cf3 \ \cf4 //b = Buffer.alloc(s,2048,1); //for sampling rates 88200 and 96000\cf3 \ \cf0 d=\cf5 Buffer\cf0 .read(s,\cf5 Document\cf0 .current.dir ++ \cf6 "/pinknoise2.wav"\cf0 );\ d=\cf5 Buffer\cf0 .read(s,\cf5 Document\cf0 .current.dir ++ \cf6 "/whitenoise2.wav"\cf0 );\ \cf3 d=\cf2 Buffer\cf3 .read(s,\cf2 Document\cf3 .current.dir ++ \cf7 "/sinetest_stepping2.wav"\cf3 );\ d.play\ d\ (\ x= \{\ \cf2 var\cf3 in, fft, array;\ \ in= \cf2 PlayBuf\cf3 .ar(1,d,\cf2 BufRateScale\cf3 .kr(d),1,0,1);\ \ \cf4 //in = SoundIn.ar(0); \cf3 \ \ fft = \cf2 FFT\cf3 (b, in, 512, 1);\ \ array=\cf2 MFCC\cf3 .kr(fft); \ \ array.size.postln; \ \ \cf2 Out\cf3 .kr(0,array); \ \ \cf2 Out\cf3 .ar(0,\cf2 Pan2\cf3 .ar(in)); \ \}.play\ )\ \ \ c= \cf2 Bus\cf3 .new(\cf8 'control'\cf3 , 0, 13); \ \ \cf4 //poll coefficients\cf3 \ c.getn(13,\{\cf2 arg\cf3 val; \{val.plot;\}.defer\}); \ \ \ \ \cf4 //Continuous graphical display of MFCC values; free routine before closing window\cf3 \ \ (\ \cf2 var\cf3 ms; \ \ w=\cf2 Window\cf3 .new(\cf7 "Thirteen MFCC coefficients"\cf3 , \cf2 Rect\cf3 (200,400,700,300));\ \ ms= \cf2 MultiSliderView\cf3 .new(w, \cf2 Rect\cf3 (10,10,660,280));\ \ ms.value_(\cf2 Array\cf3 .fill(13,0.0));\ ms.valueThumbSize_(40.0);\ ms.indexThumbSize_(40.0);\ ms.gap_(0);\ \ w.front;\ \ r= \{\ \ \cf2 inf\cf3 .do\{\ \ c.getn(13,\{\cf2 arg\cf3 val; val.postln; \{ms.value_(val*0.9)\}.defer\}); \ \ 0.02.wait; \cf4 //25 frames per second\cf3 \ \};\ \ \}.fork;\ \ )\ \ \ \cf4 //tidy up\cf3 \ (\ r.stop;\ b.free;\ c.free;\ x.free;\ w.close;\ )\ \pard\pardeftab560\ql\qnatural \f2\fs32 \cf3 \ \ \ \ }