File: 02-band-limited-oscs.rst.txt

package info (click to toggle)
python-pyo 1.0.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 52,332 kB
  • sloc: python: 135,133; ansic: 127,822; javascript: 16,116; sh: 395; makefile: 388; cpp: 242
file content (49 lines) | stat: -rw-r--r-- 1,346 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
02-band-limited-oscs.py - Oscillators whose spectrum is kept under the Nyquist frequency.
============================================================================================================================================


This tutorial presents an object (misnamed LFO but it's too late
to change its name!) that implements various band-limited waveforms.
A band-limited signal is a signal that none of its partials exceeds
the nyquist frequency (sr/2).

The LFO object, despite its name, can be use as a standard oscillator,
with very high fundamental frequencies. At lower frequencies (below 20 Hz)
this object will give a true LFO with various shapes.

The "type" slider in the controller window lets choose between these
particular waveforms:

0. Saw up (default)
1. Saw down
2. Square
3. Triangle
4. Pulse
5. Bipolar pulse
6. Sample and hold
7. Modulated Sine

.. code-block:: python

    from pyo import *
    
    s = Server().boot()
    
    # Sets fundamental frequency.
    freq = 187.5
    
    # LFO applied to the `sharp` attribute
    lfo = Sine(0.2, mul=0.5, add=0.5)
    
    # Various band-limited waveforms
    osc = LFO(freq=freq, sharp=lfo, mul=0.4).out()
    osc.ctrl()
    
    # Displays the waveform
    sc = Scope(osc)
    
    # Displays the spectrum contents
    sp = Spectrum(osc)
    
    s.gui(locals())