pyglet.media.synthesis
- class ADSREnvelope
A four-part Attack, Decay, Suspend, Release envelope.
This is a four part ADSR envelope. The attack, decay, and release parameters should be provided in seconds. For example, a value of 0.1 would be 100ms. The sustain_amplitude parameter affects the sustain volume. This defaults to a value of 0.5, but can be provided on a scale from 0.0 to 1.0.
- Parameters:
attack (
float) – The attack time, in seconds.decay (
float) – The decay time, in seconds.release (
float) – The release time, in seconds.sustain_amplitude (
float) – The sustain amplitude (volume), from 0.0 to 1.0.
- class Envelope
Base class for SynthesisSource amplitude envelopes.
Custom Envelopes need only provide a single get_generator method that takes the sample rate, and duration as arguments.
- class FlatEnvelope
A flat envelope, providing basic amplitude setting.
- Parameters:
amplitude (
float) – The amplitude (volume) of the wave, from 0.0 to 1.0. Values outside this range will be clamped.
- class LinearDecayEnvelope
A linearly decaying envelope.
This envelope linearly decays the amplitude from the peak value to 0, over the length of the waveform.
- Parameters:
- peakfloat
The Initial peak value of the envelope, from 0.0 to 1.0. Values outside this range will be clamped.
- __init__(peak=1.0)
- class Sawtooth
- class Silence
- class Sine
- class Square
- class SynthesisSource
Base class for synthesized waveforms.
- Parameters:
generator (
Generator) – A waveform generator that produces a stream of floats from (-1.0, 1.0)duration (
float) – The length, in seconds, of audio that you wish to generate.sample_rate (
int) – Audio samples per second. (CD quality is 44100).envelope (
Envelope|None) – An optional Envelope to apply to the waveform.
- class TremoloEnvelope
A tremolo envelope, for modulation amplitude.
A tremolo envelope that modulates the amplitude of the waveform with a sinusoidal pattern. The depth and rate of modulation can be specified. Depth is calculated as a percentage of the maximum amplitude. For example: a depth of 0.2 and amplitude of 0.5 will fluctuate the amplitude between 0.4 an 0.5.
- Parameters:
depth (
float) – The amount of fluctuation, from 0.0 to 1.0.rate (
float) – The fluctuation frequency, in seconds.amplitude (
float) – The peak amplitude (volume), from 0.0 to 1.0.
- class Triangle
- class WhiteNoise