[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] convert audio files tempo/dur to globol tempo



Hia again.

sorry for the ill thought out post, basically thinking out loud
(well, more being loud than thinking :))
I've made progress since i last posted. i just happened to trundled my way through the math. it will probably take a day or two more for it to sink in properly.

anyway here is what i've got so far

a = Buffer.read(s,"sounds/break");   //8 beats

(
~rateScale = {arg   numOfBars=2,numOfBeats=8,tempo=120,buffer,barMeterBeatVal=1;
                                       
           //barMeterBeatVal 0.125 = 1/32 Beat, 0.25 = 1/16 Beat, 0.5 = 1/8 Beat
                                  //1 = 1/4 Beat, 2 = 1/2 Beat
        
         var barMeterNumBeats,tempoDur,fileDur,calcRatio;
      
             barMeterNumBeats = numOfBeats/numOfBars;               
             tempoDur =(((barMeterBeatVal*60)/tempo)*(numOfBeats/numOfBars));
             fileDur = ((buffer.numFrames/buffer.sampleRate)/numOfBars);
             calcRatio = (tempoDur/fileDur);
        
             calcRatio.reciprocal;
          };
)
1.0*~rateScale.value(2,8,150,a,1);

(
SynthDef(\test,{arg out=0,gate=1,buffer,rate=1;
Out.ar(out,
PlayBuf.ar(1,buffer,BufRateScale.kr(buffer)*rate,1,0)*
EnvGen.kr(Env.asr(0.001,1,0.1,\sine),gate,doneAction:2));
}).memStore;
)
(
Pbind(\instrument,\test,
      \tempo,180/60,
      \dur,8,
      \buffer,a,
      \rate,Pseq([1.0,0.5],inf)*~rateScale.value(2,8,180,a,1);,
      \legato,1).play(quant:0);
Pbind(\dur,1,
      \legato,0.01,
      \freq,600).play(quant:0);
)

cheers

d.shoes