| 1 |
BaseModule API |
| 2 |
=============== |
| 3 |
|
| 4 |
Here are the explanations about the processing class under every cecilia module. |
| 5 |
|
| 6 |
Declaration of the module's class |
| 7 |
---------------------------------- |
| 8 |
|
| 9 |
Every module must contain a class named 'Module', where the audio processing |
| 10 |
will be developed. In order to work properly inside the environment, this |
| 11 |
class must inherit from the `BaseModule` class, defined inside the Cecilia |
| 12 |
source code. The BaseModule's internals create all links between the interface |
| 13 |
and the module's processing. A Cecilia module must be declared like this: |
| 14 |
|
| 15 |
.. code:: |
| 16 |
|
| 17 |
class Module(BaseModule): |
| 18 |
''' |
| 19 |
Module's documentation |
| 20 |
''' |
| 21 |
def __init__(self): |
| 22 |
BaseModule.__init__(self) |
| 23 |
### Here comes the processing chain... |
| 24 |
|
| 25 |
|
| 26 |
The module file will be executed in an environment where both `BaseModule` and |
| 27 |
`pyo` are already available. No need to import anything specific to define the |
| 28 |
audio process of the module. |
| 29 |
|
| 30 |
Module's output |
| 31 |
---------------- |
| 32 |
|
| 33 |
The last object of the processing chain (ie the one producing the output sound) |
| 34 |
must be called 'self.out'. The audio server gets the sound from this variable |
| 35 |
and sends it to the Post-Processing plugins and from there, to the soundcard. |
| 36 |
|
| 37 |
Here is an example of a typical output variable, where 'self.snd' is the dry |
| 38 |
sound and 'self.dsp' is the processed sound. 'self.drywet' is a mixing slider |
| 39 |
and 'self.env' is the overall gain from a grapher's line: |
| 40 |
|
| 41 |
.. code:: |
| 42 |
|
| 43 |
self.out = Interp(self.snd, self.dsp, self.drywet, mul=self.env) |
| 44 |
|
| 45 |
|
| 46 |
Module's documentation |
| 47 |
----------------------- |
| 48 |
|
| 49 |
The class should provide a __doc__ string giving relevant information about |
| 50 |
the processing implemented by the module. The user can show the documentation |
| 51 |
by selecting 'Help Menu' ---> 'Show Module Info'. Here is an example: |
| 52 |
|
| 53 |
.. code:: |
| 54 |
|
| 55 |
''' |
| 56 |
"Convolution brickwall lowpass/highpass/bandpass/bandstop filter" |
| 57 |
|
| 58 |
Description |
| 59 |
|
| 60 |
Convolution filter with a user-defined length sinc kernel. This |
| 61 |
kind of filters are very CPU expensive but can give quite good |
| 62 |
stopband attenuation. |
| 63 |
|
| 64 |
Sliders |
| 65 |
|
| 66 |
# Cutoff Frequency : |
| 67 |
Cutoff frequency, in Hz, of the filter. |
| 68 |
# Bandwidth : |
| 69 |
Bandwith, in Hz, of the filter. |
| 70 |
Used only by bandpass and pnadstop filters. |
| 71 |
# Filter Order : |
| 72 |
Number of points of the filter kernel. A longer kernel means |
| 73 |
a sharper attenuation (and a higher CPU cost). This value is |
| 74 |
only available at initialization time. |
| 75 |
|
| 76 |
Graph Only |
| 77 |
|
| 78 |
# Overall Amplitude : |
| 79 |
The amplitude curve applied on the total duration of the performance |
| 80 |
|
| 81 |
Popups & Toggles |
| 82 |
|
| 83 |
# Filter Type : |
| 84 |
Type of the filter (lowpass, highpass, bandpass, bandstop) |
| 85 |
# Balance : |
| 86 |
Compression mode. Off, balanced with a fixed signal |
| 87 |
or balanced with the input source. |
| 88 |
# Polyphony Voices : |
| 89 |
Number of voices played simultaneously (polyphony), |
| 90 |
only available at initialization time |
| 91 |
# Polyphony Spread : |
| 92 |
Pitch variation between voices (chorus), |
| 93 |
only available at initialization time |
| 94 |
|
| 95 |
''' |
| 96 |
|
| 97 |
|
| 98 |
Public Attributes |
| 99 |
------------------ |
| 100 |
|
| 101 |
These are the attributes, defined in the BaseModule class, available to the |
| 102 |
user to help in the design of his custom modules. |
| 103 |
|
| 104 |
**self.sr** |
| 105 |
Cecilia's current sampling rate. |
| 106 |
**self.nchnls** |
| 107 |
Cecilia's current number of channels. |
| 108 |
**self.totalTime** |
| 109 |
Cecilia's current duration. |
| 110 |
**self.filepath** |
| 111 |
Path to the directory where is saved the current cecilia file. |
| 112 |
**self.number_of_voices** |
| 113 |
Number of voices from the cpoly widget. |
| 114 |
**self.polyphony_spread** |
| 115 |
List of transposition factors from the cpoly widget. |
| 116 |
**self.polyphony_scaling** |
| 117 |
Amplitude value according to polyphony number of voices. |
| 118 |
|
| 119 |
Public Methods |
| 120 |
--------------- |
| 121 |
|
| 122 |
These are the methods, defined in the BaseModule class, available to the |
| 123 |
user to help in the design of his custom modules. |
| 124 |
|
| 125 |
**self.addFilein(name)** |
| 126 |
Creates a SndTable object from the name of a cfilein widget. |
| 127 |
**self.addSampler(name, pitch, amp)** |
| 128 |
Creates a sampler/looper from the name of a csampler widget. |
| 129 |
**self.getSamplerDur(name)** |
| 130 |
Returns the duration of the sound used by the sampler `name`. |
| 131 |
**self.duplicate(seq, num)** |
| 132 |
Duplicates elements in a sequence according to the `num` parameter. |
| 133 |
**self.setGlobalSeed(x)** |
| 134 |
Sets the Server's global seed used by objects from the random family. |
| 135 |
|
| 136 |
Template |
| 137 |
--------- |
| 138 |
|
| 139 |
This template, saved in a file with the extension '.c5', created a basic |
| 140 |
module where a sound can be load in a sampler for reading, with optional |
| 141 |
polyphonic playback. A graph envelope modulates the amplitude of the sound |
| 142 |
over the performance duration. |
| 143 |
|
| 144 |
.. code:: |
| 145 |
|
| 146 |
class Module(BaseModule): |
| 147 |
''' |
| 148 |
Module's documentation |
| 149 |
''' |
| 150 |
def __init__(self): |
| 151 |
BaseModule.__init__(self) |
| 152 |
### get the sound from a sampler/looper |
| 153 |
self.snd = self.addSampler('snd') |
| 154 |
### mix the channels and apply the envelope from the graph |
| 155 |
self.out = Mix(self.snd, voices=self.nchnls, mul=self.env) |
| 156 |
|
| 157 |
Interface = [ |
| 158 |
csampler(name='snd'), |
| 159 |
cgraph(name='env', label='Amplitude', func=[(0,1),(1,1)], col='blue1'), |
| 160 |
cpoly() |
| 161 |
] |
| 162 |
|
| 163 |
|