Skip to content

Simple Usage error #3

@jnccneto

Description

@jnccneto

Hi

I am just trying the simple example but getting in errors:

    <script src="js/synth.js"></script>

var context = new AudioContext();

//square wave at 440 Hz (default)
var osc = context.createOscillator();
osc.type = osc.SQUARE;

//envelope with 0.001 sec attack and 0.5 sec decay
var envelope = context.createEnvelope(0.001, 0.5, 0, 0);

//feedback delay of 0.4 seconds with 0.5x feedback
var feedbackDelay = context.createFeedbackDelay(0.4, 0.5);

osc.connect(envelope);
envelope.connect(feedbackDelay);
envelope.connect(context.destination);
feedbackDelay.connect(context.destination);

//trigger the note and release after 0.6 seconds
envelope.trigger(0.6);

The provided value 'undefined' is not a valid enum value of type OscillatorType.
Synth.html:16 Uncaught TypeError: context.createEnvelope is not a function

Seems AudioContext is not being passed along
Something I am missing here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions