muzgen/doc/guide/signals.rst

99 lines
1.5 KiB
ReStructuredText
Raw Normal View History

=======
Signals
=======
Signal primitives
-----------------
MuzGen use different kind of signals for sound design.
Constant
^^^^^^^^
The simplest signal is the **constant signal**. It
returns the same frame everytime. It is used mostly as argument of
commands. In MuzScript, every numbers are constant signals.
.. code-block::
# constant signal
142
Sine
^^^^
The sine wave signal is the fundamental signal in sound theory.
It takes two arguments: a frequency and an amplitude.
Mathematically we can define our sine using the following formula:
.. math::
amplitude * sin(2 * pi * frequency / samplerate * time)
To generate a sine, we can use the ``sine`` command.
.. code-block::
# sine signal with a frequency of 440 and an amplitude of 1
[sine 440 1]
2024-01-31 09:23:03 +00:00
Noise
^^^^^
The noise command generate uniform random frames.
.. code-block::
[noise]
Signal operations
-----------------
The signal operation commands allows us to combine signals in
different ways.
Add
^^^
The ``sum`` command takes two signals as input and outputs their sum.
.. code-block::
[sum [sine 220] [sine 220]]
Sub
^^^
The ``sub`` command takes two signals as input and outputs their
difference.
.. code-block::
[sub [sine 460] [sine 80]]
Mul
^^^
The ``mul`` command takes two signals as input and output their product.
.. code-block::
[mul 0.7 [sine 220]]
Div
^^^
The ``div`` command takes two signals as input and output their ratio.
.. code-block::
[div [sine 220] 2]