Dream

An endless musical journey of imagination, totally generated by code. All notes fall in the realm of 13567, namely do, mi, sol, la, ti.

by Wangshu Sun

HTML

<script src="https://tonejs.github.io/CDN/r6/Tone.js"></script>

JavaScript

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

var startTime = 2;

// note part
var synth1 = new Tone.SimpleSynth( {
	oscillator : {
  	type : "triangle"
  },
  envelope : {
  	attack : 0.005,
    decay : 0.07,
    sustain : 0.5,
    release : 1
  }
}).connect(freeverb);

var synth2 = new Tone.SimpleSynth( {
	oscillator : {
  	type : "sine"
  },
  envelope : {
  	attack : 0.005,
    decay : 0.07,
    sustain : 0.5,
    release : 0.5
  }
}).connect(freeverb);

var synth3 = new Tone.SimpleSynth( {
	oscillator : {
  	type : "triangle"
  },
  envelope : {
  	attack : 0.005,
    decay : 0.07,
    sustain : 0.5,
    release : 0.7
  }
}).connect(freeverb);

var synth4 = new Tone.SimpleSynth( {
	oscillator : {
  	type : "sine"
  },
  envelope : {
  	attack : 0.005,
    decay : 0.07,
    sustain : 0.5,
    release : 0.7
  }
}).connect(freeverb);

synth1.volume.value = -21;
synth2.volume.value = -28;
synth3.volume.value = -28;
synth4.volume.value = -28;

var dream_random = ["C4","E4","G4","A4","B4","C5","E5","G5","A5","B5","C6"];
var dream13567 = ["C3","E3","G3","A3","B3",0,"C3","E3","G3","A3","B3",0,"C3","E3","G3","A3","B3",0,"B3","C4","B3","G3","E3",0,];
var dream13567_high = ["C4","E4","G4","A4","B4",0,"C4","E4","G4","A4","B4",0,"C4","E4","G4","A4","B4",0,"B4","C5","B4","G4","E4",0,];
var sentence2 = ["E6","G6","E6","G6","E6","G6"];

for (var i = 0; i < 10000; i++) {
	var index = Math.floor(Math.random() * dream_random.length);
  var index_up = (index + 1) % dream_random.length;
  var index_down = (dream_random.length + index - 1) % dream_random.length;  
  var tone = dream_random[index];
  var tone_up = 0;
  var tone_down = 0;
  var chance = Math.random();
  if (i % 6 == 5) {
    if (chance > 0.8) {
      tone = 0;
    }
  }
  if (Math.floor(i/48) % 4 == 0) {
    if (chance > 0) {
      tone = 0;
    }
    if (tone != 0) {
      tone_down = dream_random[index_down];
    }
  } else...