[Week 04] Random duo

http://jsfiddle.net/sunwangshu/rbnxe9s6/

It’s basically a static part playing together with random choice of notes.

Every six notes there’s a chance of rest.

 

var freeverb = new Tone.Freeverb().toMaster();
freeverb.dampening.value = 2000;
freeverb.roomSize.value = 0.9;
freeverb.wet.value = 1;

// note part
var synth1 = new Tone.SimpleSynth( {
	oscillator : {
  	type : "sine"
  },
  envelope : {
  	attack : 0.02,
    decay : 0.8,
    sustain : 0.7,
    release : 2
  }
}).connect(freeverb);

var synth2 = new Tone.SimpleSynth( {
	oscillator : {
  	type : "sine"
  },
  envelope : {
  	attack : 0.02,
    decay : 0.8,
    sustain : 0.7,
    release : 2
  }
}).connect(freeverb);

var dream_random = ["C4","E4","G4","A4","B4","C5","E5","G5","A5","B5","C6"];
var dream13567 = ["C4","E4","G4","A4","B4",0,"C4","E4","G4","A4","B4",0,"C4","E4","G4","A4","B4",0,"B4","C5","B4","G4","E4",0,];

for (var i = 0; i < 1000; i++) {
	var index = Math.floor(Math.random() * dream_random.length);
  var tone = dream_random[index];
  if (i % 6 == 5) {
  	var chance = Math.random();
    if (chance > 0.5) {
    	tone = 0;
    }
  }
  synth1.triggerAttackRelease(tone, "4n", i * 0.4);
  var index2 = i % dream13567.length;
  var tone2 = dream13567[index2];
  synth2.triggerAttackRelease(tone2, "4n", i * 0.4);
}

Leave a Reply

Your email address will not be published.