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 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

Packages

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.

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

              
                
<html>
  <head>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.1/p5.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.1/addons/p5.dom.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/tone/13.2.0/Tone.min.js"></script>
    <link rel="stylesheet" type="text/css" href="style.css">
    <meta charset="utf-8" />

  </head>
  <body>
    <script src="sketch.js"></script>
  </body>
</html>

              
            
!

CSS

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

JS

              
                /* PDM Course: Sound Unit

Example of Tone.js Tremolo Effect

Code by Anthony T. Marasco [2018]
*/


let player, trem, button, freqSlider, depthSlider, wetMix;

let baseURL = "https://s3-us-west-1.amazonaws.com/leesamples/samples/"; 

function preload(){
  
  /*Here is where we build our audio effect, and connect its output directly to the master output */
  trem = new Tone.Tremolo(4, 0.6).toMaster().start();
  
  /* Here is where we build our Samplers and connect their outputs to the input of the audio effect. We do this using the .connect() method, and passing in the variable name of the effect we want to connect to*/
 
  player = new Tone.Player(baseURL + "Hits/BBQ+Lid+Hit.mp3").connect(trem); 
}

function setup() {
  createCanvas(windowWidth,windowHeight);
   
  wetMix = createSlider(0,1,1,0);
  wetMix.style("width","200px");
  wetMix.position(width/2-100, height/2-10);
  
  freqSlider= createSlider(0,10,6,0);
  freqSlider.style("width","200px");
  freqSlider.position(width/2-100, height/2+70);
  
  depthSlider= createSlider(0,1,0.7,0);
  depthSlider.style("width","200px");
  depthSlider.position(width/2-100, height/2+140);
  
  button =createButton("Play Sound");
  button.position(width/2-50, height/2-80);
  button.mousePressed(play1);
}

function draw() {
 /*Avoiding putting any sound triggering functions in draw() for this example
  */
  
  trem.wet.value = wetMix.value();
  trem.frequency.value =freqSlider.value();
  trem.depth.value =depthSlider.value();
  
  background(255,216,199);
  textAlign(CENTER);
  textFont("Helvetica");
  textSize(17);
  text("Tremolo Example", width/2, height/2-200);
  
  
  textSize(10);
  fill(120);
  text(int(wetMix.value() *100)+ "% effected sound", wetMix.x+100, wetMix.y-10); 
  
  textAlign(CENTER);
  text( "Tremolo Frequency parameter: "+ freqSlider.value().toFixed(2), freqSlider.x+100, freqSlider.y-25); 
  
   
  textAlign(CENTER);
  text( "Depth parameter: "+ depthSlider.value().toFixed(2), depthSlider.x+100, depthSlider.y-20); 
}

function play1(){
  player.start();
}




              
            
!
999px

Console