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>自前の音源の使用方法</p>
<button id="piano">ピアノ音</button>
<p>音楽の使用</p>
<button id="pianomusic">音楽を再生</button>
<button id="pianomusic_stop">音楽をストップ</button>
<button id="pianomusic_volup">音量を上げる</button>
<button id="pianomusic_voldown">音量を下げる</button>
<button id="pianomusic_fadein">フェードイン</button>

<button id="pianomusic_reverse">逆再生</button>
<button id="pianomusic_reversenormal">再生方向を戻す</button>
<p>Tone.Transportとの併用</p>
<button id="transport_start">Tone.Transport再生</button>
<button id="transport_stop">Tone.Transportストップ</button>
<button id="pianomusic_transport">Tone.Transportへ同期</button>
<button id="pianomusic_transport_cansel">Tone.Transportの同期を解除</button>
<button id="get_transport">Tone.Transportの再生状態</button>
              
            
!

CSS

              
                
              
            
!

JS

              
                //ピアノ音源(単音)
let pianoplayer = new Tone.Player("https://dl.dropbox.com/s/wx1cdawifqyijvn/piano_C3.mp3?dl=0").toMaster();

//音楽
let pianomusic = new Tone.Player("https://dl.dropbox.com/s/k3i7qqde16b0oul/pianoBGM.mp3?dl=0").toMaster();

$("#piano").on("click",function(){
  pianoplayer.start();
});

$("#pianomusic").on("click",function(){
  pianomusic.start();
});

$("#pianomusic_stop").on("click",function(){
  pianomusic.stop();
});

$("#pianomusic_volup").on("click",function(){
  pianomusic.volume.value += 2;  
});

$("#pianomusic_voldown").on("click",function(){
  pianomusic.volume.value -= 2;  
});

$("#pianomusic_fadein").on("click",function(){
  pianomusic.fadeIn = 3;   
});

$("#pianomusic_reverse").on("click",function(){
  pianomusic.reverse = true;   
});

$("#pianomusic_reversenormal").on("click",function(){
  pianomusic.reverse = false;   
});

$("#transport_start").on("click",function(){
  Tone.Transport.start(); 
});

$("#transport_stop").on("click",function(){
  Tone.Transport.stop();
});

$("#pianomusic_transport").on("click",function(){
  alert(Tone.Transport.position+"←このタイミングで同期させました");
  pianomusic.sync().start();
});

$("#pianomusic_transport_cansel").on("click",function(){
  pianomusic.unsync();
  pianomusic.stop();
});

$("#get_transport").on("click",function(){
  alert(Tone.Transport.state);
});
              
            
!
999px

Console