commit ff1cedddaa7a601df63905cd4d3ec5fa13237960
parent 5f453a4bff79c91ee62965c6dbc702fc8c617eef
Author: fundamental <mark.d.mccurry@gmail.com>
Date: Sun, 5 Feb 2012 12:20:17 -0500
OscilGen: Added spike waveform (lievenmoors)
- Author sf user lievenmoors
- spike wave: makes very 'thin' and grainy sounds
Diffstat:
3 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/AUTHORS.txt b/AUTHORS.txt
@@ -20,4 +20,5 @@ Contributors:
Ryan Billing (APhaser)
Hans Petter Selasky (OSS Midi, FreeBSD support)
Damien Goutte-Gattat (Bank select midi support)
+ lievenmoors (Spike waveform)
diff --git a/src/Synth/OscilGen.cpp b/src/Synth/OscilGen.cpp
@@ -1266,7 +1266,28 @@ FUNC(sqr)
return -atanf(sinf(x * 2.0f * PI) * a);
}
+FUNC(spike)
+{
+ float b = a * 0.66666; // the width of the range: if a == 0.5, b == 0.33333
+
+ if(x < 0.5){
+ if(x < (0.5 - (b / 2.0))) return 0.0;
+ else {
+ x = (x + (b / 2) - 0.5) * (2.0 / b); // shift to zero, and expand to range from 0 to 1
+ return x * (2.0 / b); // this is the slope: 1 / (b / 2)
+ }
+ }
+ else {
+ if(x > (0.5 + (b / 2.0))) return 0.0;
+ else {
+ x = (x - 0.5) * (2.0 / b);
+ return (1 - x) * (2.0 / b);
+ }
+ }
+}
+
typedef float (*base_func)(float, float);
+
base_func getBaseFunction(unsigned char func)
{
if(!func)
@@ -1276,7 +1297,7 @@ base_func getBaseFunction(unsigned char func)
return NULL;
func--;
- assert(func < 13);
+ assert(func < 14);
base_func functions[] = {
basefunc_triangle,
basefunc_pulse,
@@ -1291,6 +1312,7 @@ base_func getBaseFunction(unsigned char func)
basefunc_absstretchsine,
basefunc_chebyshev,
basefunc_sqr,
+ basefunc_spike,
};
return functions[func];
}
diff --git a/src/UI/OscilGenUI.fl b/src/UI/OscilGenUI.fl
@@ -513,6 +513,10 @@ if ((oscil->Pcurrentbasefunc==0)||(oscil->Pcurrentbasefunc==127)) basefuncmodula
label Sqr
xywh {122 122 100 20} labelfont 1 labelsize 11
}
+ MenuItem {} {
+ label Spike
+ xywh {122 122 100 20} labelfont 1 labelsize 11
+ }
}
Fl_Box {} {
label {Base Func.}