Pen Settings



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


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.


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.




  <script src=""></script>
  <script src=""></script>
  <link rel="stylesheet" type="text/css" href="style.css">
  <meta charset="utf-8" />


  <button onclick="toggle()">Toggle</button>
  <script src="sketch.js"></script>



                html, body {
  margin: 0;
  padding: 0;


                /* PDM Course: Sound Unit

  Scales with Scalemaker

// create a minor pentatonic scale over 2 octaves (9 notes), starting on F# in the
// 5th octave and get the value of the notes in hertz
// or 
// allScales === ['chromatic', 'wholeTone', 'major', 'majorPentatonic', 'minorPentatonic', 'kuomiPentatonic', 'chinesePentatonic', 'naturalMinor', 'harmonicMinor', 'melodicMinor', 'myWeirdScale'];

var myScaleInHertz = ScaleMaker.makeScale('majorPentatonic', 'F#3', 8).inHertz;
// console.log(myScaleInHertz)

const synth = new Tone.Synth().toDestination();

// Tonejs wants values in hertz
// make sure the arrays match in length
// try to use square brackets to add together multiple notes
// ['r', etc] will make it into a rest
const pitches = myScaleInHertz 
const durations = ['8n', '8n', '8n', '16n', '2n', '16n', '8n', '8n', '16n']
console.log(pitches.length === durations.length)
// combine them together 
const mergedData = toneRhythm.mergeMusicDataPart({
  rhythms: durations,
  notes: pitches

// see the data as an array of objects like Part needs
// console.log(mergedData)
const melodyPart = new Tone.Part((time, value) => {
  synth.triggerAttackRelease(value.note, value.duration, time);
}, mergedData).start(0);
melodyPart.loop = true 
melodyPart.loopEnd = "1:1:0"
const toggle = () => Tone.Transport.toggle()