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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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> -->
    <link rel="stylesheet" type="text/css" href="style.css">
    <meta charset="utf-8" />


   <div id="target"></div>
    <script src="sketch.js"></script>



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


                /* PDM Course: Sound Unit

  Remake Autofilter and Autopanner

var ampEnvelope;
var osc;
var start;
var autoFilter;
var selectFilterType;
var panner;
var autoPan;
var pannerSpeed;

function setup() {
  createCanvas(500, 250);

   // pan to the center
  panner = new Tone.Panner(0).toDestination()
  ampEnvelope = new Tone.AmplitudeEnvelope({
    attack: 0.5,
    decay: 0.1,
    sustain: 1.0,
    release: 0.4

  filter = new Tone.Filter({
    type: "lowpass",
    frequency: 400

  // setup osc and connect to filter, then start
  osc = new Tone.OmniOscillator(300, "pwm").connect(filter).start();

  autoFilter = new Tone.LFO(2, 200, 1000).connect(filter.frequency).start();
  autoPan = new Tone.LFO(1, -1, 1).connect(panner.pan).start();

  start = createButton("start");
  start.position(20, 20);
  start.mousePressed(() => {
    autoFilter.frequency.setValueCurveAtTime([1, 20, 10, 40, 50, 32, 1], '2m')
     autoPan.frequency.setValueCurveAtTime([1, 20, 60, 40, 50, 32, 1], '2m')

  affSpeed = createSlider(0, 50, 1, 0);
  affSpeed.position(20, 40);

  pannerSpeed = createSlider(0, 50, 1, 0);
  pannerSpeed.position(20, 60);

  // choose tremolo osc type
  selectAutoFilterType = createSelect();
  selectAutoFilterType.position(350, 40);
  selectAutoFilterType.changed(() => {
    filter.type = selectAutoFilterType.value();
  // choose vibrato osc type
  selectAutoPanType = createSelect();
  selectAutoPanType.position(350, 60);
  selectAutoPanType.changed(() => {
    autoPan.type = selectAutoPanType.value();

function draw() {
  // map slider to tremolo freq value
  // autoFilter.frequency.value = affSpeed.value();
  text("autofilter freq " + autoFilter.frequency.value.toFixed(2), 200, 50);
  // map slider to vibrato freq value
  // autoPan.frequency.value = pannerSpeed.value();
  text("pan freq " + autoPan.frequency.value.toFixed(2), 200, 70);