Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dave Griffiths
jellyfish
Commits
2576968f
Commit
2576968f
authored
Feb 09, 2015
by
Dave Griffiths
Browse files
added pad synth
parent
3f4b3f62
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
395 additions
and
202 deletions
+395
-202
examples/gp.scm
examples/gp.scm
+5
-0
src/fluxa/Graph.cpp
src/fluxa/Graph.cpp
+1
-0
src/fluxa/Graph.h
src/fluxa/Graph.h
+1
-1
src/fluxa/ModuleNodes.cpp
src/fluxa/ModuleNodes.cpp
+75
-0
src/fluxa/ModuleNodes.h
src/fluxa/ModuleNodes.h
+20
-10
src/fluxa/Modules.cpp
src/fluxa/Modules.cpp
+215
-145
src/fluxa/Modules.h
src/fluxa/Modules.h
+78
-46
No files found.
examples/gp.scm
View file @
2576968f
...
...
@@ -163,6 +163,11 @@
(
function-desc
'distort
(
list
(
arg-desc
'float
0
1
)
(
arg-desc
'float
0
1
)))
(
function-desc
'klip
(
list
(
arg-desc
'float
0
1
)
(
arg-desc
'float
0
1
)))
(
function-desc
'echo
(
list
(
arg-desc
'float
0
1
)
(
arg-desc
'float
0
1
)
(
arg-desc
'float
0
1
)))
(
function-desc
'ks
(
list
(
arg-desc
'float
0
1
)
(
arg-desc
'float
0
1
)
(
arg-desc
'float
0
1
)))
(
function-desc
'xfade
(
list
(
arg-desc
'float
0
1
)
(
arg-desc
'float
0
1
)
(
arg-desc
'float
0
1
)))
(
function-desc
's&h
(
list
(
arg-desc
'float
0
1
)
(
arg-desc
'float
0
1
)))
(
function-desc
't&h
(
list
(
arg-desc
'float
0
1
)
(
arg-desc
'float
0
1
)))
(
function-desc
'pad
(
list
(
arg-desc
'float
0
1
)
(
arg-desc
'float
0
1
)
(
arg-desc
'float
0
1
)
(
arg-desc
'float
0
1
)))
))
(
random
13
)
...
...
src/fluxa/Graph.cpp
View file @
2576968f
...
...
@@ -84,6 +84,7 @@ void Graph::Init()
case
XFADE
:
nodedesc
->
m_Node
=
new
XFadeNode
();
break
;
case
SAMPNHOLD
:
nodedesc
->
m_Node
=
new
HoldNode
(
HoldNode
::
SAMP
);
break
;
case
TRACKNHOLD
:
nodedesc
->
m_Node
=
new
HoldNode
(
HoldNode
::
TRACK
);
break
;
case
PAD
:
nodedesc
->
m_Node
=
new
PadNode
(
m_SampleRate
);
break
;
default:
assert
(
0
);
break
;
}
...
...
src/fluxa/Graph.h
View file @
2576968f
...
...
@@ -33,7 +33,7 @@ public:
enum
Type
{
TERMINAL
,
SINOSC
,
SAWOSC
,
TRIOSC
,
SQUOSC
,
WHITEOSC
,
PINKOSC
,
ADSR
,
ADD
,
SUB
,
MUL
,
DIV
,
POW
,
MOOGLP
,
MOOGBP
,
MOOGHP
,
FORMANT
,
SAMPLER
,
CRUSH
,
DISTORT
,
CLIP
,
DELAY
,
KS
,
XFADE
,
SAMPNHOLD
,
TRACKNHOLD
,
NUMTYPES
};
TRACKNHOLD
,
PAD
,
NUMTYPES
};
void
Init
();
void
Clear
();
...
...
src/fluxa/ModuleNodes.cpp
View file @
2576968f
...
...
@@ -684,3 +684,78 @@ void HoldNode::Process(unsigned int bufsize)
}
}
}
PadNode
::
PadNode
(
unsigned
int
SampleRate
)
:
GraphNode
(
4
),
m_Pad
(
SampleRate
)
{
}
void
PadNode
::
Trigger
(
float
time
)
{
TriggerChildren
(
time
);
float
freq
=
440
;
if
(
ChildExists
(
0
)
&&
GetChild
(
0
)
->
IsTerminal
())
{
freq
=
GetChild
(
0
)
->
GetValue
();
}
if
(
ChildExists
(
1
)
&&
GetChild
(
1
)
->
IsTerminal
())
{
m_Pad
.
SetGap
(
GetChild
(
1
)
->
GetValue
());
}
if
(
ChildExists
(
2
)
&&
GetChild
(
2
)
->
IsTerminal
())
{
m_Pad
.
SetCutoff
(
GetChild
(
2
)
->
GetValue
());
}
if
(
ChildExists
(
3
)
&&
GetChild
(
3
)
->
IsTerminal
())
{
m_Pad
.
SetResonance
(
GetChild
(
3
)
->
GetValue
());
}
m_Pad
.
Trigger
(
time
,
freq
,
freq
,
1
);
}
void
PadNode
::
Process
(
unsigned
int
bufsize
)
{
if
(
bufsize
>
(
unsigned
int
)
m_Output
.
GetLength
())
{
m_Output
.
Allocate
(
bufsize
);
}
ProcessChildren
(
bufsize
);
bool
HaveFreqCV
=
false
;
bool
HaveGapCV
=
false
;
// if frequency cv exists
HaveFreqCV
=
ChildExists
(
0
)
&&
!
GetChild
(
0
)
->
IsTerminal
();
HaveGapCV
=
ChildExists
(
1
)
&&
!
GetChild
(
1
)
->
IsTerminal
();
/* if (HaveFreqCV)
{
if (HaveGapCV)
{
m_Pad.Process(bufsize, m_Output,
GetChild(0)->GetOutput(),
GetChild(1)->GetOutput());
}
else
{
m_Pad.ProcessFM(bufsize, m_Output, GetChild(0)->GetOutput());
}
}
else
{
if (HaveGapCV)
{
m_Pad.Process(bufsize, m_Output, GetChild(1)->GetOutput());
}
else
{*/
m_Pad
.
Process
(
bufsize
,
m_Output
);
// }
//}
}
src/fluxa/ModuleNodes.h
View file @
2576968f
...
...
@@ -32,7 +32,7 @@ public:
virtual
void
SetValue
(
float
s
)
{
m_Value
=
s
;
}
virtual
bool
IsTerminal
()
{
return
true
;
}
//virtual void Clear() { GraphNode::Clear(); m_Value=0; }
private:
float
m_Value
;
};
...
...
@@ -43,7 +43,7 @@ public:
OscNode
(
unsigned
int
Shape
,
unsigned
int
SampleRate
);
virtual
void
Trigger
(
float
time
);
virtual
void
Process
(
unsigned
int
bufsize
);
private:
WaveTable
m_WaveTable
;
unsigned
int
m_Shape
;
...
...
@@ -55,7 +55,7 @@ public:
KSNode
(
unsigned
int
SampleRate
);
virtual
void
Trigger
(
float
time
);
virtual
void
Process
(
unsigned
int
bufsize
);
private:
KS
m_KS
;
unsigned
int
m_Shape
;
...
...
@@ -73,7 +73,7 @@ class HoldNode : public GraphNode
{
public:
enum
Type
{
SAMP
,
TRACK
};
HoldNode
(
Type
t
);
virtual
void
Trigger
(
float
time
);
virtual
void
Process
(
unsigned
int
bufsize
);
...
...
@@ -91,7 +91,7 @@ public:
ADSRNode
(
unsigned
int
SampleRate
);
virtual
void
Trigger
(
float
time
);
virtual
void
Process
(
unsigned
int
bufsize
);
private:
Envelope
m_Envelope
;
Sample
m_Temp
;
...
...
@@ -105,7 +105,7 @@ public:
MathNode
(
Type
t
);
virtual
void
Trigger
(
float
time
);
virtual
void
Process
(
unsigned
int
bufsize
);
private:
Type
m_Type
;
};
...
...
@@ -118,7 +118,7 @@ public:
FilterNode
(
Type
t
,
unsigned
int
samplerate
);
virtual
void
Trigger
(
float
time
);
virtual
void
Process
(
unsigned
int
bufsize
);
private:
Type
m_Type
;
FilterWrapper
m_Filter
;
...
...
@@ -133,7 +133,7 @@ public:
SampleNode(unsigned int samplerate);
virtual void Trigger(float time);
virtual void Process(unsigned int bufsize);
private:
PlayMode m_PlayMode;
Sampler m_Sampler;
...
...
@@ -148,11 +148,21 @@ public:
EffectNode
(
Type
type
,
unsigned
int
samplerate
);
virtual
void
Trigger
(
float
time
);
virtual
void
Process
(
unsigned
int
bufsize
);
private:
Type
m_Type
;
Delay
m_Delay
;
};
#endif
class
PadNode
:
public
GraphNode
{
public:
PadNode
(
unsigned
int
SampleRate
);
virtual
void
Trigger
(
float
time
);
virtual
void
Process
(
unsigned
int
bufsize
);
private:
Pad
m_Pad
;
};
#endif
src/fluxa/Modules.cpp
View file @
2576968f
This diff is collapsed.
Click to expand it.
src/fluxa/Modules.h
View file @
2576968f
...
...
@@ -42,7 +42,7 @@ class Module
public:
Module
(
int
SampleRate
)
:
m_SampleRate
(
SampleRate
)
{}
virtual
~
Module
()
{}
virtual
void
Process
(
unsigned
int
BufSize
,
Sample
&
In
)
{}
virtual
void
Trigger
(
float
time
,
float
pitch
,
float
vol
)
{}
virtual
void
Reset
()
{}
...
...
@@ -56,7 +56,7 @@ class WaveTable : public Module
public:
WaveTable
(
int
SampleRate
);
~
WaveTable
()
{}
typedef
char
Type
;
enum
{
SINE
,
SQUARE
,
SAW
,
REVSAW
,
TRIANGLE
,
PULSE1
,
PULSE2
,
NOISE
,
PINKNOISE
};
...
...
@@ -67,15 +67,15 @@ public:
virtual
void
Reset
();
static
void
WriteWaves
();
void
SetVolume
(
float
s
)
{
m_Volume
=
s
;
}
void
SetType
(
Type
s
)
{
m_Type
=
s
;
}
void
SetOctave
(
int
s
)
{
m_Octave
=
s
;
}
void
SetFineFreq
(
float
s
)
{
m_FineFreq
=
s
;
}
void
SetSlideLength
(
float
s
)
{
m_SlideLength
=
s
;
}
private:
float
m_Pitch
;
float
m_TargetPitch
;
float
m_Volume
;
...
...
@@ -88,7 +88,7 @@ private:
float
m_SlideLength
;
float
m_TimePerSample
;
float
m_TablePerSample
;
static
Sample
m_Table
[
NUM_TABLES
];
static
unsigned
int
m_TableLength
;
};
...
...
@@ -98,25 +98,25 @@ class SimpleWave : public Module
public:
SimpleWave
(
int
SampleRate
);
~
SimpleWave
()
{}
virtual
void
Process
(
unsigned
int
BufSize
,
Sample
&
In
);
virtual
void
Trigger
(
float
time
,
float
pitch
,
float
slidepitch
,
float
vol
);
virtual
void
Reset
();
void
WriteWaves
();
void
SetVolume
(
float
s
)
{
m_Volume
=
s
;
}
void
SetFineFreq
(
float
s
)
{
m_FineFreq
=
s
;
}
private:
float
m_Pitch
;
float
m_SlidePitch
;
float
m_Volume
;
int
m_Note
;
float
m_CyclePos
;
float
m_FineFreq
;
//\todo make these static??!!
Sample
m_Table
;
unsigned
int
m_TableLength
;
...
...
@@ -127,7 +127,7 @@ class Envelope : public Module
public:
Envelope
(
int
SampleRate
);
virtual
~
Envelope
()
{}
virtual
void
Process
(
unsigned
int
BufSize
,
Sample
&
CV
,
bool
Smooth
=
true
);
virtual
void
Trigger
(
float
time
,
float
pitch
,
float
vol
);
virtual
void
Reset
();
...
...
@@ -145,7 +145,7 @@ protected:
float
m_Decay
;
float
m_Sustain
;
float
m_Release
;
float
m_Volume
;
float
m_Volume
;
float
m_SampleTime
;
float
m_Current
;
...
...
@@ -156,7 +156,7 @@ class SimpleEnvelope : public Module
public:
SimpleEnvelope
(
int
SampleRate
);
virtual
~
SimpleEnvelope
()
{}
virtual
void
Process
(
unsigned
int
BufSize
,
Sample
&
In
,
Sample
&
CV
,
bool
Smooth
=
true
);
virtual
void
Trigger
(
float
time
,
float
pitch
,
float
vol
);
virtual
void
Reset
();
...
...
@@ -168,7 +168,7 @@ protected:
bool
m_Trigger
;
float
m_t
;
float
m_Decay
;
float
m_Volume
;
float
m_Volume
;
float
m_SampleTime
;
float
m_Current
;
};
...
...
@@ -178,7 +178,7 @@ class MoogFilter : public Module
public:
MoogFilter
(
int
SampleRate
);
virtual
~
MoogFilter
()
{}
virtual
void
Process
(
unsigned
int
BufSize
,
Sample
&
In
,
Sample
*
CutoffCV
,
Sample
*
LPFOut
,
Sample
*
BPFOut
,
Sample
*
HPFOut
);
virtual
void
Reset
();
...
...
@@ -189,44 +189,44 @@ public:
inline
float
ProcessSingle
(
float
in
)
{
float
Q
=
0
;
fc
=
Cutoff
;
fc
=
Cutoff
;
fc
*=
0.25
;
if
(
fc
<
0
)
fc
=
0
;
else
if
(
fc
>
1
)
fc
=
1
;
q
=
1.0
f
-
fc
;
p
=
fc
+
0.8
f
*
fc
*
q
;
f
=
p
+
p
-
1.0
f
;
Q
=
Resonance
*
6
-
3
;
q
=
Q
+
(
1.0
f
+
0.5
f
*
q
*
(
1.0
f
-
q
+
5.6
f
*
q
*
q
));
// say no to denormalisation!
in
+=
(
rand
()
%
1000
)
*
0.000000001
;
in
+=
(
rand
()
%
1000
)
*
0.000000001
;
in
-=
q
*
b4
;
if
(
in
>
1
)
in
=
1
;
if
(
in
<-
1
)
in
=-
1
;
t1
=
b1
;
b1
=
(
in
+
b0
)
*
p
-
b1
*
f
;
t2
=
b2
;
b2
=
(
b1
+
t1
)
*
p
-
b2
*
f
;
t1
=
b3
;
b3
=
(
b2
+
t2
)
*
p
-
b3
*
f
;
b4
=
(
b3
+
t1
)
*
p
-
b4
*
f
;
t1
=
b3
;
b3
=
(
b2
+
t2
)
*
p
-
b3
*
f
;
b4
=
(
b3
+
t1
)
*
p
-
b4
*
f
;
b4
=
b4
-
b4
*
b4
*
b4
*
0.166667
f
;
b0
=
in
;
return
b4
;
return
b4
;
}
protected:
float
Cutoff
,
Resonance
;
float
fs
,
fc
;
float
f
,
p
,
q
;
float
b0
,
b1
,
b2
,
b3
,
b4
;
float
t1
,
t2
;
float
in1
,
in2
,
in3
,
in4
,
out1
,
out2
,
out3
,
out4
;
};
...
...
@@ -252,9 +252,9 @@ class FilterWrapper : public Module
public:
FilterWrapper
(
int
SampleRate
);
virtual
~
FilterWrapper
()
{}
enum
Type
{
MOOG_LO
,
MOOG_BAND
,
MOOG_HI
,
FORMANT
};
void
SetType
(
Type
s
)
{
m_Type
=
s
;
}
void
SetCutoff
(
float
s
)
{
m_MoogFilter
.
SetCutoff
(
s
);
m_FormantFilter
.
SetCutoff
(
s
);
}
void
SetResonance
(
float
s
)
{
m_MoogFilter
.
SetResonance
(
s
);
m_FormantFilter
.
SetResonance
(
s
);
}
...
...
@@ -274,14 +274,14 @@ class Delay : public Module
public:
Delay
(
int
SampleRate
);
virtual
~
Delay
()
{}
virtual
void
Process
(
unsigned
int
BufSize
,
Sample
&
In
,
Sample
&
DelayCV
,
Sample
&
FeedbackCV
,
Sample
&
Out
);
virtual
void
Process
(
unsigned
int
BufSize
,
Sample
&
In
,
Sample
&
Out
);
virtual
void
Reset
();
void
SetDelay
(
float
s
)
{
m_Delay
=
s
;
}
void
SetFeedback
(
float
s
)
{
m_Feedback
=
s
;
}
protected:
float
m_Delay
,
m_Feedback
;
unsigned
int
m_Position
;
...
...
@@ -293,18 +293,18 @@ class Eq : public Module
public:
Eq
(
int
SampleRate
);
virtual
~
Eq
()
{}
virtual
void
Process
(
unsigned
int
BufSize
,
Sample
&
In
);
void
SetLow
(
float
s
)
{
m_Low
=
s
;
}
void
SetMid
(
float
s
)
{
m_Mid
=
s
;
}
void
SetHigh
(
float
s
)
{
m_High
=
s
;
}
protected:
// Filter #1 (Low band)
float
lf
;
// Frequency
float
f1p0
;
// Poles ...
float
f1p1
;
float
f1p1
;
float
f1p2
;
float
f1p3
;
...
...
@@ -323,7 +323,7 @@ protected:
float
m_Low
;
float
m_Mid
;
float
m_High
;
};
...
...
@@ -332,17 +332,17 @@ class Compressor : public Module
public:
Compressor
(
int
SampleRate
);
virtual
~
Compressor
()
{}
virtual
void
Process
(
unsigned
int
BufSize
,
Sample
&
In
);
void
SetAttack
(
float
s
)
{
tatt
=
s
*
1e-3
;
}
void
SetRelease
(
float
s
)
{
trel
=
s
*
1e-3
;
}
void
SetThreshold
(
float
s
)
{
threshold
=
s
;
}
void
SetSlope
(
float
s
)
{
slope
=
s
;
}
protected:
float
threshold
;
// threshold (percents)
float
threshold
;
// threshold (percents)
float
slope
;
// slope angle (percents)
int
sr
;
// sample rate (smp/sec)
float
tla
;
// lookahead (ms)
...
...
@@ -356,14 +356,14 @@ class KS : public Module
public:
KS
(
int
SampleRate
);
virtual
~
KS
()
{}
virtual
void
Process
(
unsigned
int
BufSize
,
Sample
&
Out
);
virtual
void
Trigger
(
float
time
,
float
pitch
,
float
slidepitch
,
float
vol
);
virtual
void
Reset
();
void
SetCutoff
(
float
s
)
{
m_Filter
.
SetCutoff
(
s
);
}
void
SetCutoff
(
float
s
)
{
m_Filter
.
SetCutoff
(
s
);
}
void
SetResonance
(
float
s
)
{
m_Filter
.
SetResonance
(
s
);
}
protected:
float
m_Delay
,
m_Feedback
;
unsigned
int
m_Position
;
...
...
@@ -371,5 +371,37 @@ protected:
MoogFilter
m_Filter
;
};
class
Pad
:
public
Module
{
public:
Pad
(
int
SampleRate
);
~
Pad
()
{}
virtual
void
Process
(
unsigned
int
BufSize
,
Sample
&
In
);
virtual
void
Trigger
(
float
time
,
float
pitch
,
float
slidepitch
,
float
vol
);
virtual
void
Reset
();
void
WriteWaves
();
void
SetVolume
(
float
s
)
{
m_Volume
=
s
;
}
void
SetGap
(
float
s
)
{
m_Gap
=
s
;
}
void
SetCutoff
(
float
s
)
{
m_Filter
.
SetCutoff
(
s
);
}
void
SetResonance
(
float
s
)
{
m_Filter
.
SetResonance
(
s
);
}
private:
MoogFilter
m_Filter
;
float
m_Gap
;
float
m_State
;
float
m_TablePerSample
;
float
m_Pitch
;
float
m_Volume
;
int
m_Note
;
float
m_CyclePos
;
unsigned
int
m_WritePos
;
Sample
m_Table
;
unsigned
int
m_TableLength
;
};
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment