Removing old app.js file, from an earlier experiment
This commit is contained in:
parent
bb354fc4f8
commit
54340ef585
|
@ -1,85 +0,0 @@
|
||||||
import { amsynth } from "./modules/instruments/amsynth.js"
|
|
||||||
import { duosynth } from "./modules/instruments/duosynth.js"
|
|
||||||
import { monosynth } from "./modules/instruments/monosynth.js"
|
|
||||||
import { plucksynth } from "./modules/instruments/plucksynth.js"
|
|
||||||
|
|
||||||
let FILTER_FREQ = 400
|
|
||||||
let REV_RANGE = 12
|
|
||||||
let REV = Math.random() * REV_RANGE
|
|
||||||
|
|
||||||
let NOTES = ["A3", "A2", "C4", "C3", "F3", "F2"]
|
|
||||||
let NOTE = NOTES[ Math.floor(Math.random() * NOTES.length)]
|
|
||||||
|
|
||||||
let SPACING = ["7h", "8h", "9h", "10h"]
|
|
||||||
let SPACE = SPACING[Math.floor(Math.random() * SPACING.length)]
|
|
||||||
|
|
||||||
Tone.Transport.bpm.value = 60;
|
|
||||||
|
|
||||||
let INSTRUMENTS = [amsynth, monosynth, plucksynth]
|
|
||||||
let INSTRUMENT = INSTRUMENTS[Math.floor(Math.random() * INSTRUMENTS.length)]
|
|
||||||
|
|
||||||
const channel = new Tone.Channel();
|
|
||||||
const freeverb = new Tone.Freeverb({ roomSize: 0.98, wet : 0.4 })
|
|
||||||
const filter = new Tone.Filter({type:"lowpass", frequency:800})
|
|
||||||
|
|
||||||
channel.chain(freeverb, filter, Tone.Master)
|
|
||||||
|
|
||||||
for (let inst of INSTRUMENTS) {
|
|
||||||
inst.connect(channel)
|
|
||||||
}
|
|
||||||
|
|
||||||
const play = () => {
|
|
||||||
let r = Math.random()
|
|
||||||
if (r > 0.7) {
|
|
||||||
const a = new Tone.Loop((time) => {
|
|
||||||
INSTRUMENT.triggerAttackRelease(NOTE, "16n")
|
|
||||||
}, SPACE).start(0)
|
|
||||||
} else if (r > 0.3) {
|
|
||||||
const a = new Tone.Loop((time) => {
|
|
||||||
amsynth.triggerAttack(NOTE, "16n")
|
|
||||||
}, SPACE).start(0)
|
|
||||||
|
|
||||||
} else {
|
|
||||||
freeverb.wet.value = 0.0
|
|
||||||
const bassPart = new Tone.Sequence(((time, note) => {
|
|
||||||
plucksynth.triggerAttack(note);
|
|
||||||
}), ["C7", "C8", "C7", "C5", "C#8"], "8n").start(0);
|
|
||||||
|
|
||||||
bassPart.probability = 0.6;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let ac_x = document.getElementById("ac_x")
|
|
||||||
let ac_y = document.getElementById("ac_y")
|
|
||||||
let ac_z = document.getElementById("ac_z")
|
|
||||||
|
|
||||||
if (window.DeviceOrientationEvent) {
|
|
||||||
window.addEventListener(
|
|
||||||
"deviceorientation",
|
|
||||||
(event) => {
|
|
||||||
const rotateDegrees = event.alpha; // alpha: rotation around z-axis
|
|
||||||
const leftToRight = event.gamma; // gamma: left to right
|
|
||||||
const frontToBack = event.beta; // beta: front back motion
|
|
||||||
|
|
||||||
// ac_x.innerHTML = rotateDegrees
|
|
||||||
ac_y.innerHTML = leftToRight
|
|
||||||
// ac_z.innerHTML = frontToBack
|
|
||||||
|
|
||||||
filter.frequency.value = (180 + leftToRight) * 6
|
|
||||||
|
|
||||||
ac_x.innerHTML = filter.frequency.value
|
|
||||||
},
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
document.getElementById('start').addEventListener('click', function() {
|
|
||||||
Tone.context.resume().then(() => {
|
|
||||||
Tone.start()
|
|
||||||
Tone.Transport.start()
|
|
||||||
|
|
||||||
play()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})()
|
|
Loading…
Reference in a new issue