Pen Settings

HTML

CSS

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

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

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.

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>
  
    <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 PingPong Delay Effect

Code by Anthony T. Marasco [2018]
*/


let player;

let pingPongDelay;
let button;
let timeSlider;
let feedbackSlider;
let 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 */
  pingPongDelay = new Tone.PingPongDelay(0.5, 0.1).toDestination();
  
  /* 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 + "Rhythmics/60+bpm/Ping+Pong+Ping.mp3").connect(pingPongDelay); 
}

function setup() {
  createCanvas(windowWidth,windowHeight);
   
  wetMix = createSlider(0,1,1,0);
  wetMix.style("width","200px");
  wetMix.position(width/2-100, height/2-10);
  
  timeSlider= createSlider(0,2,0.5,0);
  timeSlider.style("width","200px");
  timeSlider.position(width/2-100, height/2+70);
  
  feedbackSlider= createSlider(0,1,0.1,0);
  feedbackSlider.style("width","200px");
  feedbackSlider.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
  */
  
  pingPongDelay.wet.value = wetMix.value();
  pingPongDelay.delayTime.value =timeSlider.value();
  pingPongDelay.feedback.value =feedbackSlider.value();
  
  background(255,252,193);
 
  textFont("Helvetica");
  textSize(17);
  text("PingPong Delay Example", width/2, height/2-200);
  textSize(10);
  fill(120);
  textAlign(CENTER);
  
  text(int(wetMix.value() *100)+ "% effected sound", wetMix.x+100, wetMix.y-10); 
  
  textAlign(CENTER);
  text( "Delay Time parameter: "+ timeSlider.value().toFixed(2) +" seconds", timeSlider.x+100, timeSlider.y-25); 
  
   
  textAlign(CENTER);
  text( "Feedback parameter: "+ feedbackSlider.value().toFixed(2) +" %", feedbackSlider.x+100, feedbackSlider.y-20); 
}

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




              
            
!
999px

Console