diff options
| author | Mick Grierson <mickgrierson@strangebook.lan> | 2011-10-28 09:27:37 +0100 |
|---|---|---|
| committer | Mick Grierson <mickgrierson@strangebook.lan> | 2011-10-28 09:27:37 +0100 |
| commit | 71f5a13bd245350b5924867f89f4621d05b9279f (patch) | |
| tree | b5ade6790e44cad8887cb1bf002727164727a32c | |
| parent | 9fd23b3d03639eca7b2e3b0fba76cff8b3d837ff (diff) | |
added maxisample::playOnce with a speed setting - only uses linear interpolation at the moment
| -rwxr-xr-x | main.cpp | 4 | ||||
| -rw-r--r-- | maximilian.cpp | 13 | ||||
| -rwxr-xr-x | maximilian.h | 2 |
3 files changed, 17 insertions, 2 deletions
@@ -56,9 +56,9 @@ void play(double *output) {//this is where the magic happens. Very slow magic. } - bassout=basscompress.compressor(sound1.pulse(slew.lopass(bassfreq/2,0.001), sound2.phasor(8)*0.25),10,0.5,0.0001,0.995)*0.25; + bassout=basscompress.compressor(sound1.pulse(slew.lopass(bassfreq/2,0.001), sound2.phasor(8)*0.25),5,0.5,0.0001,0.995)*0.125; - sampleOut=compress.compressor(kick.playOnce()+snare.playOnce(),5,0.5),0.0001,0.9995;//just play the file. No looping. + sampleOut=compress.compressor(kick.playOnce(0.5)+snare.playOnce(0.5),1,0.5),0.01,0.9995;//just play the file. No looping. output[0]=sampleOut+bassout;//left channel output[1]=sampleOut+bassout;//right channel diff --git a/maximilian.cpp b/maximilian.cpp index 92f1292..12ea302 100644 --- a/maximilian.cpp +++ b/maximilian.cpp @@ -457,6 +457,19 @@ double maxiSample::playOnce() { return(output); } +double maxiSample::playOnce(double speed) { + double remainder; + //long a,b; + // long length=myDataSize*0.5; + short* buffer = (short *)myData; + position=position+((speed*chandiv*myChannels)/(maxiSettings::sampleRate/mySampleRate)); + if ((long) position<length) + output = (double) ((1-remainder) * buffer[1+ (long) position] + remainder * buffer[2+(long) position])/32767;//linear interpolation + else + output=0; + return(output); +} + double maxiSample::play(double speed) { double remainder; long a,b; diff --git a/maximilian.h b/maximilian.h index ad0e116..5062ba5 100755 --- a/maximilian.h +++ b/maximilian.h @@ -216,6 +216,8 @@ public: double playOnce(); + double playOnce(double speed); + double play(double speed); double play(double frequency, double start, double end, double &pos); |
