sound.generator

waves.sound.generator.mono_ttf_gen(fps=44100, frequency=110, volume=0.5, sample_width=2)

Generates a time_to_frame function for a mono sine wave which can be passed to Sound.from_datatimes.

Parameters
  • fps (int, optional) – Frames per second of the sound to generate.

  • frequency (int, optional) – Frequency of the sine wave.

  • volume (float, optional) – Value between 0 and 1 that will define the volume of the wave.

  • sample_width (int, optional) – Number of bytes used in wave data values.

Returns

function – time.

Return type

Takes a parameter time t and returns the sound data for that

Examples

>>> from waves import Sound, mono_ttf_gen
>>>
>>> time_to_frame = mono_ttf_gen(frequency=660, volume=0.2)
>>> sound = Sound.from_datatimes(time_to_frame).with_duration(2)
waves.sound.generator.stereo_ttf_gen(fps=44100, frequencies=(440, 110), volume=0.5, sample_width=2)

Generates a time_to_frame function for a stereo sine wave which can be passed to Sound.from_datatimes.

Parameters
  • fps (int, optional) – Frames per second of the sound to generate.

  • frequencies (tuple or list, optional) – Frequencies of each channel for the sine wave. The number of channels will be determined by the number of values introduced in this parameter.

  • volume (float, optional) – Value between 0 and 1 that will define the volume of the wave.

  • sample_width (int, optional) – Number of bytes used in wave data values.

Returns

function – time for each channel of the sound.

Return type

Takes a parameter time t and returns the sound data for that

Examples

>>> from waves import Sound, stereo_ttf_gen
>>>
>>> time_to_frame = stereo_ttf_gen(frequencies=(660, 290), volume=0.2)
>>> sound = Sound.from_datatimes(time_to_frame).with_duration(2)