waveforms – Various Sound Waves

Provides functions to make 16-bit buffers suitable for playing audio on CodeX.

Each of the make_X functions returns a new array (‘h’) of the requested length (default 240) that contains 16-bit numbers forming the corresponding wave shape:

  • sine

  • square

  • sawtooth

  • triangle

  • random

codex.waveforms.make_random(max_amplitude=32767, length=240)[source]

Generate a single cycle of a random wave with the requested amplitude and length (resolution)

codex.waveforms.make_sawtooth(max_amplitude=32767, length=240)[source]

Generate a single cycle of a sawtooth wave with the requested amplitude and length (resolution)

codex.waveforms.make_sine(max_amplitude=32767, length=240)[source]

Generate a single cycle of a sine wave with the requested amplitude and length (resolution)

codex.waveforms.make_square(max_amplitude=32767, length=240)[source]

Generate a single cycle of a square wave with the requested amplitude and length (resolution)

codex.waveforms.make_triangle(max_amplitude=32767, length=240)[source]

Generate a single cycle of a triangle wave with the requested amplitude and length (resolution)

Download Source