From 9428f8d8079797f381657b62fa9d84e2b6a546a9 Mon Sep 17 00:00:00 2001 From: rob Date: Wed, 17 Dec 2008 20:09:29 +0000 Subject: [PATCH] added source files, built successfully in xcode --- RFWUGens.scx | Bin 0 -> 43428 bytes src/rfw-ugens.cpp | 206 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 206 insertions(+) create mode 100755 RFWUGens.scx create mode 100644 src/rfw-ugens.cpp diff --git a/RFWUGens.scx b/RFWUGens.scx new file mode 100755 index 0000000000000000000000000000000000000000..1105735595e1f5ef86d4e8bc44bc1e4c04802250 GIT binary patch literal 43428 zcmeHw4RlmhmhPz^ppb$pF#0kr(uJmd;m0J{I8$gzDn%+*BuKSXG-{yoPa+{nCl!fU z1r;iGr(Tii(5*gDLG(EYE}eGupLR=Qf_Wy`I4{t2Ph5>N(TUwKgzgB8(sbgTZ=ZW^ z<)#t{&YFI&-a-WNYR#2C|KpN8GQm=%fV0uE;EbFgD8 z!k+sQ4wR>D8Uq>w8Uq>w8Uq>w8Uq>w8Uq>w8Uq>w8Uq>w|DQ4N50}n1F)PaxG{Pr{o4zu)IB@Zm(g*~AG_s*fr>rCh&1P~H?EByWlJTP%#dG?Ot(>BU2Q zGqSLP{r=L1Kz&usdXbT+BlSkc3Q$I=dQU%0<@LqYc3C1(M;LW8P(&$Se8e|n z98q6NYik-tJCms6b=37jo>Fx^l?vz(b}W^16Lqk8jB`(^+J3c7e*c<4aiFR+x2B34 zlc>Xlx(~o%l#<^j+Wh|VN`FOt@y2qwG*L&uRfN5Y@tfiR#lhrus@9I-N=fvHAUvG;XZ(2Z~Foc_bw2 zaH8&Qkfl^z4|&LfTND3H#XF#S67wLzUHxpK>5ZrR~o{tszlbKuEUJ7SJZVH0%fI(7N!05 zW$SPj#Kx05-Kx05-Kx05-Kx5#)0t2V0lLgZ2n{eM83qOvd z)Gz17!W;Nme)N;bpeg1yb@SWEBkv$%O=K{IOFfMIsQW?;|GY-R*(oH7#Ml=37fF($ z#uVxJ6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z-7sFEH$6RRZ?|KQ7~>SApAPeEk6MGcx|G6TmOa_y!yB zk7YcU{CGsh^BlmxlJQr;4;zqexCwn{=LEh8d}&skf1Qrj78L6(+$LkxyT^eW9xn*o*wl0;4V6Hi3(PqXMIky6*^F2mG|aut&E?;4tt$fm?xJ6Sy7thXU^e zepBGRzy}5158Od(1>&_Lc+i~?xDWW0jA;z&F3Fh2l-?|38ZY{JGNxG7BW&@J0N?a? zV4Xn)uT<6?gbbEV)QJN9E){-Wg{lzdCJbS0_t|K*hW|(F6XJgoE)#1B`j=$*zs~rdG5(_~7S=Y_#}_8lRxcd=ZUJ3Y_DY-oym-@80k9 AK>z>% literal 0 HcmV?d00001 diff --git a/src/rfw-ugens.cpp b/src/rfw-ugens.cpp new file mode 100644 index 0000000..3b440a2 --- /dev/null +++ b/src/rfw-ugens.cpp @@ -0,0 +1,206 @@ +/* + * rfw-ugens.cpp + * Plugins + * + * Created by Rob Watson on 17/December/2008. + * Copyright 2008 __MyCompanyName__. All rights reserved. + * + * https://github.com/rfwatson + */ +/* + SuperCollider real time audio synthesis system + Copyright (c) 2002 James McCartney. All rights reserved. + http://www.audiosynth.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + auint32 with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include "SC_PlugIn.h" + +static InterfaceTable *ft; + +#define ENVLEN 2000.0 // TODO modulate + +struct SwitchDelay : public Unit { + float *buffer; + float prev_samp, offset_start, offset_current; + uint32 writepos, readpos, decaytime, bufsize, offset_timer; + char crossfading; +}; + +struct AverageOutput : public Unit { + float average, prev_trig; + uint32 count; +}; + +extern "C" { + void SwitchDelay_next(SwitchDelay *unit, int inNumSamples); + void SwitchDelay_Ctor(SwitchDelay* unit); + void SwitchDelay_Dtor(SwitchDelay* unit); + + void AverageOutput_next(AverageOutput *unit, int inNumSamples); + void AverageOutput_Ctor(AverageOutput* unit); +} + + +void SwitchDelay_Ctor( SwitchDelay* unit ) { + RGen& rgen = *unit->mParent->mRGen; + + float *buffer; + + unit->bufsize = (uint32)(SAMPLERATE * ZIN0(5)); + buffer = unit->buffer = (float *)RTAlloc(unit->mWorld, unit->bufsize * sizeof(float)); + + for(int i=0; ibufsize; ++i) + *(buffer+i)=0.; // TODO use memset or something here + + unit->decaytime = (uint32)(ZIN0(3) * SAMPLERATE); + unit->writepos = 0; + unit->prev_samp = 0.; + unit->offset_start = 0.; + unit->offset_current = 0.; + unit->offset_timer = ENVLEN; + unit->crossfading = 0; + unit->readpos = ((unit->bufsize - unit->decaytime) + unit->bufsize) % unit->bufsize; + + SETCALC(SwitchDelay_next); +} + + +void SwitchDelay_Dtor(SwitchDelay *unit) { + RTFree(unit->mWorld, unit->buffer); +} + +void SwitchDelay_next( SwitchDelay *unit, int inNumSamples ) { + int i; + float recval, readval, ratio; + + float *out = OUT(0); + float *in = IN(0); + float *buffer = unit->buffer; + + float drylevel = ZIN0(1); + float wetlevel = ZIN0(2); + float delayfactor = ZIN0(4); + float prev_samp = unit->prev_samp; + float offset_current = unit->offset_current; + float offset_start = unit->offset_start; + + uint32 decaytime = (uint32)(ZIN0(3) * SAMPLERATE); + uint32 bufsize = unit->bufsize; + uint32 offset_timer = unit->offset_timer; + uint32 writepos = unit->writepos; + uint32 readpos = ((writepos - decaytime) + (bufsize)) % bufsize; + + char crossfading = unit->crossfading; + + if(decaytime != unit->decaytime) { // move the read pointer + float newval, oldval, offset; + + newval = buffer[((readpos - decaytime) + bufsize) % bufsize]; + oldval = buffer[readpos] + offset_current; // adding the current offset means that we can modulate again mid-crossfade. + offset = oldval - newval; + + crossfading = 1; + offset_start = offset; + offset_current = offset; + offset_timer = ENVLEN; + } + + // limit the delay multiplier to reasonable numbers + if(delayfactor < 0.) delayfactor = 0.; + if(delayfactor > 0.9) delayfactor = 0.9; + + for(i=0; i < inNumSamples; ++i) { + recval = in[i]; + readval = buffer[readpos] + offset_current; + + recval = recval + (prev_samp * delayfactor); + out[i] = (in[i] * drylevel) + (readval * wetlevel); + + buffer[writepos] = recval; + prev_samp = readval; + + readpos = (readpos + 1) % bufsize; + writepos = (writepos + 1) % bufsize; + + if(crossfading) { + --offset_timer; + + if(offset_timer > 0.) { // still crossfading + ratio = (offset_timer / ENVLEN); + offset_current = offset_start * ratio; + } else { // all done + crossfading = 0; + offset_current = 0.; + } + } + } + + unit->crossfading = crossfading; + unit->offset_start = offset_start; + unit->offset_current = offset_current; + unit->offset_timer = offset_timer; + unit->decaytime = decaytime; + unit->writepos = writepos; + unit->readpos = readpos; + unit->prev_samp = prev_samp; +} + + +void AverageOutput_Ctor( AverageOutput* unit ) { + unit->average = 0.; + unit->count = 0; + unit->prev_trig = 0.; + + RGen& rgen = *unit->mParent->mRGen; + + SETCALC(AverageOutput_next); +} + + +void AverageOutput_next( AverageOutput *unit, int inNumSamples ) { + int i; + float *in = IN(0); + float *out = ZOUT(0); + float trig = ZIN0(1); + float prev_trig = unit->prev_trig; + double average = unit->average; + uint32 count = unit->count; + + if(prev_trig <= 0. && trig > 0.) { + average = 0.; + count = 0; + } + + for (i=0; iprev_trig = trig; + unit->count = count; + unit->average = average; +} + + +extern "C" void load(InterfaceTable *inTable) { + ft = inTable; + DefineDtorUnit(SwitchDelay); + DefineSimpleUnit(AverageOutput); +} + +