WaveformPlayer - RoseAndres/gDAW GitHub Wiki

Inherits: Node < Object < AudioStreamPlayer

Description

Plays an audio waveform non-positionally.

Properties

Type Name Default
float attack 0.5
float attack_shape 0.5
float decay 0.5
float decay_shape 0.5
float hz 220
float last_level
float limit 0.6
bool linear false
Note note C
int octave 4
bool play false
AudioStreamPlayback playback
float release 0.5
float release_shape 0.5
float sustain 0.5
bool use_hz false
bool was_playing
Waveform waveform SINE

Methods

Type Name(args)
void finish ( )
float frequency ( )
String get_state ( )
void set_state ( String new_state )
void start ( )
int time_in_state ( )

Signals

  • state_changed ( String from, String to, int time_in_state )
    Emitted when this WaveformPlayer's ADSR state is changed.

    from the key of the State this WaveformPlayer transitioned from.
    to the key of the State this WaveformPlayer transitioned to.
    time_in_state the amount of time in ms this WaveformPlayer was in the from state.\

Enumerations

enum Note:

  • C, D, E, F, G, A, B = 0, 2, 4, 5, 7, 9, 11 --- The musical note this WaveformPlayer will play.
  • CS, EB, FS, GS, BB = 1, 3, 6, 8, 10 --- -S and -B indicate sharp and flat, respectively. Thus, CS and BB are equivalent to C# and Bb.

    Note: The values of this enum are hard-coded; it does not account for equivalent notes (A# and Bb or Cb and B, for example).

enum State:

  • STOPPED = 0 --- Sound is not being generated.
  • ATTACK = 1 --- The waveform is currently in the Attack phase.
  • DECAY = 2 --- The waveform is currently in the Decay phase.
  • SUSTAIN = 3 --- The waveform is currently in the Sustain phase.
  • RELEASE = 3 --- The waveform is currently in the Release phase.

enum Waveform:

  • SINE = 0 --- A Sine wave will be used to generate sound.
  • TRIANGLE = 1 --- A Triangle wave will be used to generate sound.
  • SQUARE = 2 --- A Square wave will be used to generate sound.
  • SAW = 3 --- A Saw wave will be used to generate sound.
  • WHITE_NOISE = 4 --- The generated noise will be White Noise (sounds like heavy rain).
  • BROWN_NOISE = 5 --- The generated noise will be Brownian Noise (deeper than White Noise, akin to a thunderstorm).

Property Descriptions

  • float attack
    Default: 0.5

    The length of time (in seconds) that the Attack phase will last.

  • float attack_shape
    Default: 0.5

    A value between 0.0 and 1.0 that determines the shape of the Attack curve. Higher values will result in a more logarithmic curve, while lower values will appear more exponential. This value will be ignored if linear is set to true.

  • float decay
    Default: 0.5

    The length of time (in seconds) that the Decay phase will last.

  • float decay_shape
    Default: 0.5

    A value between 0.0 and 1.0 that determines the shape of the Decay curve. Higher values will result in a more logarithmic curve, while lower values will appear more exponential. This value will be ignored if linear is set to true.

  • float hz
    Default: 220

    A raw Hz value. This will be used as the sound's frequency instead of finding it with note and octave, if use_hz is set to true.

  • float limit
    Default: 0.6

    A value between 0.0 and 1.0 that determines percentage of the max GoDAW max volume that this WaveformPlayer will use as its own local max volume.

  • bool linear
    Default: false

    If true, the ADSR curves will be linear. Otherwise, the curves will be quadratic and use the attack_shape, decay_shape, and release_shape properties to calculate the curves.

  • Note note
    Default: C

    The note is to be played. Ignored if use_hz is true.

  • int octave
    Default: 4

    The octave the current note is to be played in. Ignored if use_hz is true.

  • bool play
    Default: false

    If true, the WaveformPlayer will emit noise according to the envelope and frequency determined by its other vars. This will also cause the WaveformPlayer to emit sound when toggled in-editor.

  • float release
    Default: 0.5

    The length of time (in seconds) that the Release phase will last.

  • float release_shape
    Default: 0.5

    A value between 0.0 and 1.0 that determines the shape of the Release curve. Higher values will result in a more logarithmic curve, while lower values will appear more exponential. This value will be ignored if linear is set to true.

  • float sustain
    Default: 0.5

    A value between 0.0 and 1.0 that determines percentage of this WaveformPlayer's local max volume (limit) that will be used as the volume during the sustain phase of the ADSR envelope.

  • bool use_hz
    Default: false

    If true, this WaveformPlayer will use the hz value directly as the frequency, otherwise the WaveformPlayer will calculate it using the note and octave values.

  • Waveform waveform
    Default: SINE

    The waveform this WaveformPlayer will use to generate audio.

Method Descriptions

  • void start ( )

    Starts sound emission from the WaveformPlayer.

  • void finish ( )

    Initiates the stopping of sound emission from the WaveformPlayer (starts the release).

  • bool is_playing ( )

    Returns false if the WaveformPlayer's state is equal to State.STOPPED. Returns true otherwise.

  • void set_state ( String state_key )

    Sets the WaveformPlayer's state to the State value corresponding to the given state_key. Emits a state_changed signal.

  • String get_state ( )

    Returns the String representation of the WaveformPlayer's current state.

  • int time_in_state ( )

    Returns the amount of time (in milliseconds) that the WaveformPlayer has been in its current state.

  • float frequency ( )

    Returns the raw frequency being used by the WaveformPlayer to generate audio.
⚠️ **GitHub.com Fallback** ⚠️