Debian Codegraph @

Resources/modules/Synthesis/AdditiveSynth.c5

raw
1 import random
2 class Module(BaseModule):
3 """
4 "Additive synthesis module"
5
6 Description
7
8 An all featured additive synthesis module.
9
10 Sliders
11
12 # Base Frequency :
13 Base pitch of the synthesis
14 # Partials Spread :
15 Distance between partials
16 # Partials Freq Rand Amp :
17 Amplitude of the jitter applied on the partials pitch
18 # Partials Freq Rand Speed :
19 Frequency of the jitter applied on the partials pitch
20 # Partials Amp Rand Amp :
21 Amplitude of the jitter applied on the partials amplitude
22 # Partials Amp Rand Speed :
23 Frequency of the jitter applied on the partials amplitude
24 # Amplitude Factor :
25 Spread of amplitude between partials
26 # Chorus Depth :
27 Amplitude of the chorus
28 # Chorus Feedback :
29 Amount of chorused signal fed back to the chorus
30 # Chorus Dry / Wet :
31 Mix between the original synthesis and the chorused signal
32
33 Graph Only
34
35 # Overall Amplitude :
36 The amplitude curve applied on the total duration of the performance
37
38 Popups & Toggles
39
40 # Num of Partials :
41 Number of partials present
42 # Wave Shape :
43 Shape used for the synthesis
44 # Custom Wave :
45 Define a custom wave shape by entering amplitude values
46
47 """
48 def __init__(self):
49 BaseModule.__init__(self)
50 self.customtable = self.custom_value
51 self.wavetable = HarmTable(size=8192)
52 self.polyfreqs = self.polyphony_spread
53 self.ply = [i*self.freq for i in self.polyfreqs for j in range(self.nchnls)]
54 self.out = OscBank(table=self.wavetable, freq=self.ply, spread=self.spread, slope=self.ampfactor,
55 fjit=True, frndf=self.rndampspeedf, frnda=self.rndampf, arndf=self.rndampspeed,
56 arnda=self.rndamp, num=int(self.num_value), mul=self.polyphony_scaling*self.env)
57
58 #INIT
59 self.wavedict = {'Sine':[1], 'Sawtooth':[1, 0.5, 0.333, 0.25, 0.2, 0.167, 0.143, 0.111, 0.1], 'Square':[1, 0, 0.333, 0, 0.2, 0, 0.143, 0, 0.111],
60 'Complex1':[1, 0, 0, 0, 0.3, 0, 0, 0, 0.2, 0, 0, 0.05], 'Complex2':[1, 0, 0, 0.3, 0, 0, 0.2, 0, 0, 0, 0, 0.1, 0, 0, 0.05, 0, 0, 0.02],
61 'Complex3':[1, 0, 0, 0.2, 0, 0.1, 0, 0, 0, 0.3, 0, 0.1, 0, 0, 0.05, 0, 0, 0.1, 0, 0.05, 0, 0, 0, 0.05, 0, 0, 0.02],
62 'Custom':self.customtable}
63
64 self.shape(self.shape_index, self.shape_value)
65
66 def shape(self, index, value):
67 self.wavetable.replace(self.wavedict[value])
68
69 def custom(self, value):
70 self.wavedict['Custom'] = value
71
72 Interface = [ cgraph(name="env", label="Overall Amplitude", func=[(0,1),(1,1)], col="blue"),
73 cslider(name="freq", label="Base Frequency", min=10, max=10000, init=150, rel="log", unit="Hz", col="blue"),
74 cslider(name="spread", label="Partials Spread", min=0.0001, max=4, init=0.003, rel="log", unit="x", col="red3"),
75 cslider(name="rndampspeedf", label=" Freq Rand Speed", min=0.0001, max=100, init=1, rel="log", unit="Hz", col="blue3",half=True),
76 cslider(name="rndampspeed", label=" Amp Rand Speed", min=0.0001, max=20, init=1, rel="log", unit="Hz", col="green3",half=True),
77 cslider(name="rndampf", label=" Freq Rand Amp", min=0.0001, max=1, init=0.02, rel="log", unit="x", col="blue3",half=True),
78 cslider(name="rndamp", label=" Amp Rand Amp", min=0.0001, max=1, init=0.01, rel="log", unit="x", col="green3",half=True),
79 cslider(name="ampfactor", label="Amplitude Factor", min=0.5, max=1, init=0.85, rel="lin", unit="x", col="green"),
80 cpopup(name="num", label="Num of Partials", init="20", col="grey", rate="i", value=["5","10","20","40","80","160","320","640"]),
81 cpopup(name="shape", label="Wave Shape", init="Square", col="green", value=["Sine","Sawtooth","Square","Complex1", "Complex2", "Complex3", "Custom"]),
82 cgen(name="custom", label="Custom Wave", init=[1,0,0.5,0.3,0,0,0.2,0,0.1,0,0.09,0,0.05], popup=("shape", 6), col="green2"),
83 cpoly()
84 ]