Jump to content

Recommended Posts

In JavaScript I'm trying to:

take a tone generated by a tone generator

manipulate the tone (the only thing that will be on the whole page for sound) in several ways at the same time

produce the tone in its manipulated form

 

What I understand:

the tone is generated by startTone( tone )

computer speaker manipulation

 

What I need to do:

make the product of startTone() manipulatable

From what I can tell briefly looking at the script if you want to store the tone into a variable you need to create another generateTone function which will create a new oscillator object at the proper frequency. Eg:

function generateTone(context, frequency){
    var oscillator = context.createOscillator();
    fixOscillator(oscillator);
    oscillator.frequency.value = frequency;

    var amp = context.createGainNode();
    oscillator.connect(amp);
    amp.connect(context.destination);

    return { oscillator: oscillator, amp: amp };
}
That would create the oscillator and an associated amp object and return them. You'd then use the oscillator to alter the tone's frequency or the amp object to alter it's volume level. You could wrap that all up into a Tone object so that you'd just have to do something like

var tone = new Tone(context, 100);
tone.setVolume(0.6);
tone.start();
tone.changeFrequency(60);
tone.stop();
//etc
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.