cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <div id="audio1"></div>
<div id="audio2"></div>
<div id="box"></div>
            
          
!
            
              #audio1 {
  position:absolute;
  width: 1000px;
  height: 30px;
  right: 630px;
  background: black;
}

#audio2 {
  position: absolute;
  right: 0px;
  width: 600px;
  height: 30px;
  bottom: 10px;
  background: #66CC99;
}

#box {
  position: absolute;
  width: 2500px;
  background: #FF0066;
  height: 100px;
  top: 75px;
  left: 0;
}
            
          
!
            
              var backgroundNoise = true;

var sound1url =    "http://kclathrop.com/interactiveMusic/_week2/_soundAguas.wav";
   
var sound2url = "http://kclathrop.com/interactiveMusic/_week2/_inho1Aguas.wav";

var sound3url = "http://kclathrop.com/interactiveMusic/_week2/_aguasPianohigh.wav";
 
var sound1 = new Tone.Player(sound1url).toMaster();
sound1.retrigger = true;
var sound2 = new Tone.Player(sound2url).toMaster();
sound2.retrigger = true;
var sound3 = new Tone.Player(sound3url).toMaster();
sound3.retrigger= true;

var sound1Prob = [1, 0.5, 0, 0.5, 1, 1, 0, 0.2];
var sound2Prob = [0, 0, 0.5, 1, 1, 0, 0.2, 1];
var sound3Prob = [0, 0.5, 1, 0, 1, 0.5, 0.2, 1];

var beatTime = 0.25;
var beats = 8 * 8;

$("#audio2").on("mousedown", function() {
  console.log("mouse is down")
  //Tone.Buffer.on("load", function(){
    //console.log("buffer is loaded")
	var now = sound1.now();
    for (var i = 0; i < beats; i++){
      
  	var measureBeat = i % sound1Prob.length;
    var measureTime = i * beatTime + now;
 		  if (Math.random() < sound1Prob[measureBeat]){
    	sound1.start(measureTime);
      }
      if (Math.random() < sound2Prob[measureBeat]){
    	sound2.start(measureTime);
      }
      if (Math.random() < sound3Prob[measureBeat]){
    	sound3.start(measureTime);
      }
    
    };
});

   

                
var chain = new Tone.CtrlMarkov({
  "B3" : [{value: "A3", probability: 0.25}, 
          {value : "C4", probability : .75}],
  "A3" : ["E5", "A3"],
  "C4" : "A3",
  "E5" : "B3"
});
var beats= 40;
var synth = new Tone.SimpleSynth().toMaster();

chain.value = "B3";

$("#audio1").on("mousedown", function() {
 
  for (var i=0; i < beats; i++){
    synth.triggerAttackRelease(chain.value, .5 "+" + (i*.3));
    chain.next();
  
  }
}).on("mouseup", function() {
  synth.triggerRelease();
    //chain.next();
  i = 0;
});
  

 if (backgroundNoise==true) {
   
 

var whistlesURL = "https://kclathrop.com/interactiveMusic/_week2/_aguasWhistleSoft.wav";

var cymbalsURL = "https://kclathrop.com/interactiveMusic/_week2/_cymbalAguas.wav";

var jazzURL = "https://kclathrop.com/interactiveMusic/_week2/_jazzAguas.wav";

var whistles = new Tone.Player(whistlesURL).toMaster();
whistles.retrigger = true;

var cymbals = new Tone.Player(cymbalsURL).toMaster();
cymbals.retrigger = true;

var jazz = new Tone.Player(jazzURL).toMaster();
jazz.retrigger = true;

var whistlesProb =  [.5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];

var cymbalsProb = [0, 0, 1, 0, .5, 0, 1, .3, 0, .2, 1, 0, 0, 0, 1, 0];

var jazzProb =    [0, 1, 1, 1, 0, 0.3, 0.5, 1, 0.5, 1, 0, 1, 0.1, 1, 0.5, 1];

var beatTime = 0.25;
var beats = 8 * 16;

Tone.Buffer.on("load", function() {
  var now = whistles.now();
  
  for (var i=0; i < beats; i++) {
    var measureBeat = i % whistlesProb.length;
    var measureTime = i * beatTime + now;
    if(Math.random() < whistlesProb[measureBeat]) {
      whistles.start(measureTime);
    }
    if(Math.random() < cymbalsProb[measureBeat] ) {
      cymbals.start(measureTime);
    }
    if(Math.random() < jazzProb[measureBeat]) {
      jazz.start(measureTime);
    };
  };
});
}


            
          
!
999px
Loading ..................

Console