Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

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


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

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.


<ul id="piano">
   <li id="C4" class="w_key">C</li>
   <li id="Cs4" class="b_key"></li> 
   <li id="D4" class="w_key">D</li>
   <li id="Ds4" class="b_key"></li> 
   <li id="E4" class="w_key">E</li>
   <li id="F4" class="w_key">F</li>
   <li id="Fs4" class="b_key"></li>
   <li id="G4" class="w_key">G</li>
   <li id="Gs4" class="b_key"></li>
   <li id="A4" class="w_key">A</li>
   <li id="As4" class="b_key"></li>
   <li id="B4" class="w_key">B</li>
   <li id="C5" class="w_key">C</li>
<div id="code_type">
<p id="code_type_text"></p>
<p id="code_keys_text"></p>
<form name="code_types" class="">
			<label><input type="radio" id="code_R" name="code_type" value="ルート(R)" onchange="codeTypeSelect()" checked>(R)</label>
			<label><input type="radio" id="code_5" name="code_type" value="パワーコード(5)" onchange="codeTypeSelect()">5</label>
			<label><input type="radio" id="code_M" name="code_type" value="メジャー(M)" onchange="codeTypeSelect()">(M)</label>
			<label><input type="radio" id="code_m" name="code_type" value="マイナー(m)" onchange="codeTypeSelect()">m</label>
			<label><input type="radio" id="code_dim" name="code_type" value="ディミニッシュ(dim)" onchange="codeTypeSelect()">dim</label>
			<label><input type="radio" id="code_aug" name="code_type" value="オーギュメント(aug)" onchange="codeTypeSelect()">aug</label>
			<label><input type="radio" id="code_sus4" name="code_type" value="サスペンデッド4th(sus4)" onchange="codeTypeSelect()">sus4</label>
			<label><input type="radio" id="code_M7" name="code_type" value="メジャーセブンス(M7)" onchange="codeTypeSelect()">M7</label>
			<label><input type="radio" id="code_7" name="code_type" value="セブンス(7)" onchange="codeTypeSelect()">7</label>
			<label><input type="radio" id="code_mM7" name="code_type" value="マイナー・メジャー・セブンス(mM7)" onchange="codeTypeSelect()">mM7</label>
			<label><input type="radio" id="code_m7" name="code_type" value="マイナーセブンス(m7)" onchange="codeTypeSelect()">m7</label>
			<label><input type="radio" id="code_m7-5" name="code_type" value="マイナー・セブン・フラット・ファイブ(m7(-5))" onchange="codeTypeSelect()">m7(-5)</label>
			<label><input type="radio" id="code_dim7" name="code_type" value="ディミニッシュ・セブンス(dim7)" onchange="codeTypeSelect()">dim7</label>
			<label><input type="radio" id="code_augM7" name="code_type" value="オーグメント・メジャー・セブンス(augM7)" onchange="codeTypeSelect()">augM7</label>
			<label><input type="radio" id="code_aug7" name="code_type" value="オーギュメント・セブンス(aug7)" onchange="codeTypeSelect()">aug7</label>
			<label><input type="radio" id="code_M7sus4" name="code_type" value="メジャー・セブンス・サスペンデッド4th(M7sus4)" onchange="codeTypeSelect()">M7sus4</label>
			<label><input type="radio" id="code_7sus4" name="code_type" value="セブンス・サスペンデッド4th(7sus4)" onchange="codeTypeSelect()">7sus4</label>
			<label><input type="radio" id="code_6" name="code_type" value="シックスス(6)" onchange="codeTypeSelect()">6</label>
			<label><input type="radio" id="code_m6" name="code_type" value="マイナー・シックスス(m6)" onchange="codeTypeSelect()">m6</label>


                body {
	font-family: sans-serif;

h1, #code_type, #code_type_text {
  text-align: center;

form {
  margin: 0 auto ;
	max-width: 400px; 
  border: 1px solid #ccc;
  padding: 10px 10px 0;
	text-align: left;

form dl {
	padding: 5px 0 0;
	display: flex;
	margin: 0;	

form dl:not(:last-child) {
	border-bottom: 1px solid #eee;

form dt {
	font-weight: bold;
	width: 15%;

form dd {
	margin: 0;
	display: inline-block;
	width: 85%;

label {
  margin: 0 10px 10px 0;
	display: inline-block;

label:hover {
  cursor: pointer;

#piano {
  background: #333;
  padding: 10px;
  width: 310px;
  display: block;
  margin: 0 auto;
  position: relative;

.w_key {
  background: #FFF;
  border: 0px solid #333;
  width: 34px;
  text-align: center;
  padding:  90px 0 10px;
  display: inline-block;

.b_key:hover {
  opacity: 0.7;

.b_key {
  position: absolute;
  z-index: 10;
  top: 10px;
  margin: 0 -20px;
  padding: 0;
  background: #000;
  border: 1px solid #fff;
  color: #fff;
  width: 35px;
  height: 75px;
  text-align: center;
  display: inline-block; 

#code_type_text {
  font-size: 20px;
	margin: 10px 0 0;

#code_keys_text {
	margin: 0 0 10px;


const Key = document.querySelectorAll('#piano li');
const codeTypeText = document.querySelector('#code_type_text');
const codeType = document.getElementsByName("code_type");
const codeKeysText = document.querySelector('#code_keys_text');

var scale = [
  'C4', 'C#4', 'D4', 'D#4', 'E4', 'F4', 'F#4', 'G4', 'G#4', 'A4', 'A#4', 'B4',
  'C5', 'C#5', 'D5', 'D#5', 'E5', 'F5', 'F#5', 'G5', 'G#5', 'A5', 'A#5', 'B5'];

var codeTypes = [
    {'codeName': '(R)',
        'codeKeys': [1]},
    {'codeName': '(5)',
        'codeKeys': [1,8]},		
    {'codeName': '(M)',
        'codeKeys': [1,5,8]},
    {'codeName': 'm',
        'codeKeys': [1,4,8]},
    {'codeName': 'dim',
        'codeKeys': [1,4,7]},
    {'codeName': 'aug',
        'codeKeys': [1,5,9]},
    {'codeName': 'sus4',
        'codeKeys': [1,6,8]},
    {'codeName': 'M7',
        'codeKeys': [1,5,8,12]},
    {'codeName': '7',
        'codeKeys': [1,5,8,11]},	
    {'codeName': 'mM7',
        'codeKeys': [1,4,8,12]},
    {'codeName': 'm7',
        'codeKeys': [1,4,8,11]},
    {'codeName': 'm7(-5)',
        'codeKeys': [1,4,7,11]},
    {'codeName': 'dim7',
        'codeKeys': [1,4,7,10]},
    {'codeName': 'augM7',
        'codeKeys': [1,5,9,12]},	
    {'codeName': 'aug7',
        'codeKeys': [1,5,9,11]},	
    {'codeName': 'M7sus4',
        'codeKeys': [1,6,8,12]},	
    {'codeName': '7sus4',
        'codeKeys': [1,6,8,11]},	
    {'codeName': '6',
        'codeKeys': [1,5,8,10]},	
    {'codeName': 'm6',
        'codeKeys': [1,4,8,10]},

var chords = [];

for (let h = 0 ; h < codeTypes.length; h++ ) {
  chords.push( [] );
  for (let i = 0 ; i < Key.length; i++ ) {
    chords[h].push( [] );
    for (var  j = 0; j < codeTypes[h]['codeKeys'].length; j++){     
      const nmb = scale[i+codeTypes[h]['codeKeys'][j]];

  function codeTypeSelect() {
    for(let i = 0; i < codeType.length; i++){
      if(codeType[i].checked) {
        const CodeTypeValue = codeType[i].value;
        codeTypeText.innerHTML = CodeTypeValue;
        const CodeKyesValue = codeTypes[i].codeKeys;	
        codeKeysText.innerHTML = '構成音:' +  CodeKyesValue;
        return chords[i];


var synth = new Tone.PolySynth().toMaster();

for (let i = 0; i < Key.length; i++) {
(function(i) {
  Key[i].addEventListener('click', function () { 
  var seletcCords = codeTypeSelect();
  synth.triggerAttackRelease(seletcCords[i], '4n');
  }, false);