Yes, thanks Matt. This is very similar to what I already do, and I would call it amplitude slope detection. It works very well for splitting up audio into segments (phrases). But, I'd still want to detect transients more precisely. For example plosives in speech or singing. Sometimes, the transient fror an instrument does not lead to a significant amplitude change (in the overall mix), this might happen if the audio signal was heavily compressed before transient analysis. best Oeyvind 2008/4/23, Matt J. Ingalls : > > here's something i showed in Ireland festival last november that will sense > the transients in a file and save the position in a table for later > playback. if you don't have a mac just replace invalue/outvalue with > pfields or something.. > > i have yet to use it in a performance, but AFAIK it works. > > > > > /*************************************************** > > Transient Analysis > > ***************************************************/ > > nchnls = 2 > 0dbfs = 1 > > ;#define FILENAME #marble# > #define FILENAME #duct# > ;#define FILENAME #wineEns# > > gkpoints init 0 > > > ; analysis > instr 1 > > ; initial values > kattackthresh invalue "attack" > iminlen init 2000 > > isilencethresh init 200 > imaxampbufsiz init 200 > > kdur init 0 > klastrms init 1 > > ; get audio > al, ar soundin "$FILENAME" > > ; take rms and campare to last > krms rms .5*(al+ar) > kratio = krms/klastrms > > outvalue "ratio", 1/kratio > outvalue "rms", krms > > ; if rms/lastrms ratio is greater than threshold, write to table > if (krms > .01 && kratio > kattackthresh && kdur > iminlen) then > ktim times > printks "%f %n", 0, ktim > kdur = 0 > > tablew ktim, gkpoints, 2 > > gkpoints = gkpoints + 1 > outvalue "count", gkpoints > endif > > kdur = kdur+1 > klastrms port krms, 1 > > outs al, ar > > endin > > > ; playack one transient segment (randomly chosen) of the soundfile > instr 2 > > indx linrand gkpoints > iskip table indx, 2 > print iskip > > iend table indx+1, 2 > > ipitch linrand 3 > ipitch = ipitch + .1 > > kcount init (iend-iskip)/ipitch > > al, ar diskin2 "$FILENAME", ipitch, iskip, 0, 0, 4 > > outs al, ar > > kcount = kcount - 1/kr > if (kcount <= .1) then > turnoff > endif > > endin > > > f1 0 512 10 1 > > f2 0 512 -7 35 512 35 > > i1 0 35 > > f0 9999999 > > > > > Version: 3 > Render: Real > Ask: Yes > SFDIR: /Users/matt/Music > Functions: ioObject > Listing: ioObject > WindowBounds: 64 44 1032 870 > CurrentView: io > IOViewEdit: Off > Options: -b256 -A -s -m7 -R > > > ioView background {65535, 64997, 56784} > ioText {382, 13} {56, 72} label 0.000000 0.001000 "" left "Lucida Grande" 8 > {0, 0, 0} {65535, 65535, 65535} nobackground border clip count > ioText {233, 13} {114, 47} label 0.000000 0.001000 "" left "Lucida Grande" 8 > {0, 0, 0} {65535, 65535, 65535} nobackground noborder attack threshold > ioText {48, 70} {47, 28} label 0.000000 0.001000 "" left "Lucida Grande" 8 > {0, 0, 0} {65535, 65535, 65535} nobackground noborder rms > ioListing {10, 152} {395, 433} > ioGraph {410, 150} {511, 428} > ioSlider {26, 21} {247, 34} 1.000000 30.000000 3.282300 attack > ioMeter {117, 58} {92, 23} {44563, 53738, 65535} "ratio" 9.314381 "ratio" > 9.314381 fill 1 0 notrack > ioText {277, 28} {47, 24} display 3.282300 0.001000 "attack" center "Lucida > Grande" 10 {0, 0, 0} {65535, 65535, 65535} nobackground noborder > ioMeter {20, 57} {92, 23} {44563, 53738, 65535} "rms" 0.000484 "rms" > 0.000484 fill 1 0 notrack > ioText {399, 52} {44, 35} display 24.000000 1.000000 "count" left "Lucida > Grande" 20 {0, 0, 0} {65535, 65535, 65535} nobackground noborder click to edit text> > ioButton {276, 88} {90, 48} event 1.000000 "" "Play clip" "/" i2 0 10 > ioText {120, 73} {114, 47} label 0.000000 0.001000 "" left "Lucida Grande" 8 > {0, 0, 0} {65535, 65535, 65535} nobackground noborder lastrms/rms ratio > > > > > > Send bugs reports to this list. > To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe > csound" >