Skip to content

Commit e31085f

Browse files
authored
Merge pull request #5 from fleximeter/class_refactor
Class refactor
2 parents ac3d194 + c578607 commit e31085f

26 files changed

Lines changed: 1382 additions & 1392 deletions

src/filters/filters.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@ You should have received a copy of the GNU General Public License
2222
along with this program. If not, see <https://www.gnu.org/licenses/>.
2323
*/
2424

25-
#include "SC_PlugIn.h"
2625
#include "fir.hpp"
2726

2827
InterfaceTable *ft;
2928

3029
PluginLoad(flex_filters) {
3130
ft = inTable;
32-
registerUnit<FIR>(ft, "FIR", false);
31+
registerUnit<FlexPlugins::FIR>(ft, "FIR", false);
3332
}

src/filters/fir.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
2525
#include "fir.hpp"
2626
extern InterfaceTable *ft;
2727

28-
FIR::FIR() {
28+
FlexPlugins::FIR::FIR() {
2929
m_z = static_cast<float*>(RTAlloc(mWorld, fullBufferSize() * sizeof(float)));
3030
for (size_t i = 0; i < fullBufferSize(); i++) {
3131
m_z[i] = 0.f;
@@ -34,26 +34,26 @@ FIR::FIR() {
3434
next(1);
3535
}
3636

37-
FIR::~FIR() {
37+
FlexPlugins::FIR::~FIR() {
3838
if (m_z) RTFree(mWorld, m_z);
3939
}
4040

41-
void FIR::next(int inNumSamples) {
41+
void FlexPlugins::FIR::next(int inNumSamples) {
4242
size_t numCoefs = static_cast<size_t>(mNumInputs - 1);
4343
numCoefs = sc_clip(numCoefs, 0, static_cast<size_t>(fullBufferSize()));
4444
const float *inBuf = in(0);
4545
float *outBuf = out(0);
46-
for (size_t xxi = 0; xxi < inNumSamples; xxi++) {
46+
for (size_t i = 0; i < inNumSamples; i++) {
4747
float convResult = 0.f;
4848
// unit delay
49-
for (size_t xxj = fullBufferSize() - 1; xxj > 0; xxj--) {
50-
m_z[xxj] = m_z[xxj-1];
49+
for (size_t j = fullBufferSize() - 1; j > 0; j--) {
50+
m_z[j] = m_z[j-1];
5151
}
52-
m_z[0] = inBuf[xxi];
52+
m_z[0] = inBuf[i];
5353
// convolve
54-
for (size_t xxk = 0; xxk < numCoefs; xxk++) {
55-
convResult += in0(1+xxk) * m_z[xxk];
54+
for (size_t k = 0; k < numCoefs; k++) {
55+
convResult += in0(1+k) * m_z[k];
5656
}
57-
outBuf[xxi] = convResult;
57+
outBuf[i] = convResult;
5858
}
5959
}

src/filters/fir.hpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
2626

2727
#include "SC_PlugIn.hpp"
2828

29-
class FIR : public SCUnit {
30-
public:
31-
FIR();
32-
~FIR();
33-
34-
private:
35-
void next(int inNumSamples);
36-
float *m_z;
37-
size_t m_delaySize;
38-
};
29+
namespace FlexPlugins {
30+
class FIR : public SCUnit {
31+
public:
32+
FIR();
33+
~FIR();
34+
35+
private:
36+
void next(int inNumSamples);
37+
float *m_z;
38+
size_t m_delaySize;
39+
};
40+
}

src/generators/LoopPhasor.schelp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,27 +67,29 @@ b = Buffer.read(s, p);
6767
x = Bus.audio(s, 1);
6868

6969
SynthDef(\ptr, {
70-
var sig;
71-
sig = LoopPhasor.ar(\t_start.tr(0.0), \t_end.tr(0.0), \rate.kr(1.0) * BufRateScale.ir(b), 0.0, BufFrames.kr(b), \loopStart.ir(0), \loopEnd.ir(1));
72-
Out.ar(\out.kr(0), sig);
70+
arg rate=1, loopStart=0, loopEnd=1, out=0, trigEnd=0.0;
71+
var sig;
72+
sig = LoopPhasor.ar(0.0, trigEnd, 1 * BufRateScale.ir(b), 0.0, BufFrames.ir(b), loopStart, loopEnd);
73+
sig.poll;
74+
Out.ar(out, sig);
7375
}).add;
7476

7577
SynthDef(\player, {
76-
var sig, ptr_in;
77-
ptr_in = In.ar(\ptr.kr(0));
78-
sig = BufRd.ar(1, b, ptr_in, 0);
79-
Out.ar(0, sig);
78+
arg ptr;
79+
var sig, ptr_in;
80+
ptr_in = In.ar(ptr);
81+
sig = BufRd.ar(1, b, ptr_in, 0);
82+
Out.ar(0, sig);
8083
}).add;
84+
)
8185

8286
// we need two synths: a pointer synth and a player synth
83-
y = Synth(\ptr, [\out, x, \loopStart, 80e3, \loopEnd, 120e3]);
87+
y = Synth(\ptr, [\out, x, \loopStart, 8e4, \loopEnd, 9e4]);
8488
z = Synth(\player, [\ptr, x], addAction: \addToTail);
8589

8690
// to stop looping and end naturally
87-
y.set(\t_end, 1.0);
91+
y.set(\trigEnd, 1.0);
8892

89-
// free the synths
9093
z.free;
9194
y.free;
92-
)
9395
::

src/generators/generators.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ You should have received a copy of the GNU General Public License
2222
along with this program. If not, see <https://www.gnu.org/licenses/>.
2323
*/
2424

25-
#include "SC_PlugIn.h"
25+
#include "SC_PlugIn.hpp"
2626
#include "loopPhasor.hpp"
2727
#include "impulseDropout.hpp"
2828
#include "impulseJitter.hpp"
@@ -31,7 +31,7 @@ InterfaceTable *ft;
3131

3232
PluginLoad(flexplugin_generators) {
3333
ft = inTable;
34-
DefineSimpleUnit(ImpulseDropout);
35-
DefineDtorUnit(ImpulseJitter);
36-
DefineSimpleUnit(LoopPhasor);
34+
registerUnit<FlexPlugins::ImpulseDropout>(ft, "ImpulseDropout", false);
35+
registerUnit<FlexPlugins::ImpulseJitter>(ft, "ImpulseJitter", false);
36+
registerUnit<FlexPlugins::LoopPhasor>(ft, "LoopPhasor", false);
3737
}

0 commit comments

Comments
 (0)