Skip to content

Commit 57d4cb5

Browse files
committed
SuperSaw now uses FloatArray
1 parent a1bf411 commit 57d4cb5

2 files changed

Lines changed: 18 additions & 17 deletions

File tree

LibSource/SuperSaw.hpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ class SuperSaw{
2323
int lastCall=kNone;
2424
float samplePeriod;
2525
float detune;
26-
float* frequencyRatios;
27-
float* phaseIncrements;
28-
float* amplitudes;
29-
float* phases;
30-
float* allTheArrays=NULL;
26+
FloatArray frequencyRatios;
27+
FloatArray phaseIncrements;
28+
FloatArray amplitudes;
29+
FloatArray phases;
3130
BiquadFilter *filter=NULL;
3231
float frequency;
3332
int numberOfOscillators;
@@ -42,7 +41,10 @@ void init(){
4241
}
4342

4443
void destroy(){
45-
free(allTheArrays);
44+
FloatArray::destroy(frequencyRatios);
45+
FloatArray::destroy(phaseIncrements);
46+
FloatArray::destroy(amplitudes);
47+
FloatArray::destroy(phases);
4648
if(filter!=NULL){
4749
BiquadFilter::destroy(filter);
4850
filter=NULL;
@@ -52,13 +54,14 @@ void init(){
5254
void allocate(){
5355
destroy();
5456
int numArrays=4;
55-
float size=sizeof(float)*numberOfOscillators*numArrays;
56-
allTheArrays=(float*)malloc(size);
57-
memset(allTheArrays,0,size);
58-
frequencyRatios=allTheArrays;
59-
phaseIncrements=allTheArrays+numberOfOscillators*1;
60-
amplitudes=allTheArrays+numberOfOscillators*2;
61-
phases=allTheArrays+numberOfOscillators*3;
57+
frequencyRatios=FloatArray::create(numberOfOscillators);
58+
frequencyRatios.clear();
59+
phaseIncrements=FloatArray::create(numberOfOscillators);
60+
phaseIncrements.clear();
61+
amplitudes=FloatArray::create(numberOfOscillators);
62+
amplitudes.clear();
63+
phases=FloatArray::create(numberOfOscillators);
64+
phases.clear();
6265
float filterStages=2;
6366
filter=BiquadFilter::create(filterStages);
6467
}
@@ -144,7 +147,6 @@ void init(){
144147
amplitudes[n]=detunedAmplitude;
145148
}
146149
amplitudes[numberOfOscillators/2]=1-aMix;
147-
debugMessage("detunedamplitude", detunedAmplitude, 1-aMix);
148150
}
149151

150152
/**
@@ -197,7 +199,7 @@ void init(){
197199
}
198200
}
199201
if(filterBypass==false){
200-
filter->process(output, output, size); //highpass filter
202+
// filter->process(output, output, size); //highpass filter
201203
}
202204
}
203205
};

TestPatches/SuperSawTestPatch.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ class SuperSawTestPatch : public Patch {
3838
ss.setSampleRate(getSampleRate());
3939
}
4040
void processAudio(AudioBuffer &buffer){
41-
static int count=0;
42-
count++;
4341
float gain=getParameterValue(PARAMETER_A);
4442
float frequency=powf(2,5*getParameterValue(PARAMETER_B))*100;
4543
float detune=getParameterValue(PARAMETER_C);
@@ -49,6 +47,7 @@ class SuperSawTestPatch : public Patch {
4947
ss.setFrequency(frequency);
5048
ss.setDetune(detune);
5149
ss.getSamples(fa);
50+
// ss.setNumOscillators(gain*14+1); //just for fun
5251
fa.scale(gain);
5352
}
5453
};

0 commit comments

Comments
 (0)