Tonejs / Tone.js

A Web Audio framework for making interactive music in the browser.
https://tonejs.github.io
MIT License
13.52k stars 983 forks source link

Fixing my error regarding MetalSynth #981

Closed masakakinoki closed 2 years ago

masakakinoki commented 2 years ago

This code (code A) is working: https://editor.p5js.org/abirdwhale/sketches/JzjyxlscM This code ( code B) is not working: https://editor.p5js.org/abirdwhale/sketches/wVFbFZxlx

Could anyone point out what's wrong with code B?

Many thanks, Masa

dirkk0 commented 2 years ago

you are missing the "C1": cymbalSynth.triggerAttack("C1", time, 0.3);

On Sun, Nov 21, 2021 at 2:55 PM abirdwhale @.***> wrote:

This code (code A) is working: https://editor.p5js.org/abirdwhale/sketches/JzjyxlscM

let bassSynth, cymbalSynth; let counter;

function setup() { counter = 0;

bassSynth = new Tone.MembraneSynth().toDestination(); // cymbalSynth = new Tone.MetalSynth().toDestination();

loopBeat = new Tone.Loop(song, "8n");

Tone.Transport.bpm.value = 140; Tone.Transport.start(); loopBeat.start(1); }

function song(time) { bassSynth.triggerAttack("C1", time, 0.3); // cymbalSynth.triggerAttack(time, 0.3); }```

This code ( code B) is not working:https://editor.p5js.org/abirdwhale/sketches/wVFbFZxlx


let bassSynth, cymbalSynth;
let counter;

function setup() {
  counter = 0;

  // bassSynth = new Tone.MembraneSynth().toDestination();
  cymbalSynth = new Tone.MetalSynth().toDestination();

  loopBeat = new Tone.Loop(song, "8n");

  Tone.Transport.bpm.value = 140;
  Tone.Transport.start();
  loopBeat.start(1);
}

function song(time) {
  // bassSynth.triggerAttack("C1", time, 0.3);
  cymbalSynth.triggerAttack(time, 0.3);
}```

Could anyone point out what's wrong with code B?

Many thanks,
Masa

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<https://github.com/Tonejs/Tone.js/issues/981>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEYV4QRDGIH237Z7ASC3ZDUND24HANCNFSM5IPF4C6A>
.
masakakinoki commented 2 years ago

Oh, such a simple misunderstanding of how .triggerAttack ( ) works. Thank you, @dirkk0 !

masakakinoki commented 2 years ago

I made the mistake because I was looking at the old document. https://tonejs.github.io/docs/r13/MetalSynth

I should have checked the latest document. https://tonejs.github.io/docs/14.7.77/MetalSynth