Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <p>Tone.jsで準備された音源の再生</p>
<button id="tonejs_single_synth">単音再生(synth)</button>
<button id="tonejs_chord_synth">和音再生(synth)※Polysynthでは無い為正常に再生されないよ</button>
<button id="tonejs_single_polysynth">単音再生(polysynth)</button>
<button id="tonejs_chord_polysynth">和音再生(polysynth)</button>
              
            
!

CSS

              
                
              
            
!

JS

              
                let synth = new Tone.Synth().toMaster();
let polysynth = new Tone.PolySynth().toMaster();

$("#tonejs_single_synth").on("click",function(){
    synth.triggerAttackRelease('C5','2n');//←nは音の長さ、2nの場合は2分音符、4nの場合は4分音符で再生される。
});

$("#tonejs_chord_synth").on("click",function(){
    synth.triggerAttackRelease(['C4','E4','G4'], '2n');
  //←配列で囲むと和音もできる。が…Synth()は和音に対応していない為、一つの音しか再生されない
});

$("#tonejs_single_polysynth").on("click",function(){
    polysynth.triggerAttackRelease('C5','4n');
});

$("#tonejs_chord_polysynth").on("click",function(){
    polysynth.triggerAttackRelease(['C4','E4','G4'], '4n');//←配列で囲むと和音もできる。
});
              
            
!
999px

Console