Getting there

This commit is contained in:
Halfdan 2024-01-27 05:58:07 +01:00
parent 54340ef585
commit d2ccead3f2
4 changed files with 41 additions and 16 deletions

11
app.py
View file

@ -15,10 +15,17 @@ def spe():
# Socket IO stuff
@socketio.on('action')
def hey():
print('action')
def action():
socketio.emit('all_action')
@socketio.on('noise')
def noise():
socketio.emit('all_noise')
@socketio.on('stop')
def stop():
socketio.emit('all_stop')
if __name__ == '__main__':
socketio.run(
app,

View file

@ -33,16 +33,16 @@ reverb.connect(Tone.Master)
instrument.connect(channel)
const voice = new Tone.Player("/static/recordings/tts.mp3").connect(channel)
voice.playbackRate = 0.75
voice.playbackRate = 0.65
voice.loop = true
voice.autostart = false
const noise = new Tone.Noise("brown")
noise.connect("channel")
let playloop = undefined
let schedule = undefined
const pathway = pick([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
const pathway = pick([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
const play = () => {
// Determine which of our patterns to play
@ -79,7 +79,7 @@ const play = () => {
const interval = pick(["5m", "6m", "7m"])
const schedule = Tone.Transport.scheduleRepeat((time) => {
schedule = Tone.Transport.scheduleRepeat((time) => {
pianoPart.stop()
pianoPart.start()
}, interval, "0")
@ -99,9 +99,9 @@ const play = () => {
break
case 3:
playloop = new Tone.Loop((time) => {
instrument.triggerAttackRelease(NOTE, "16n")
}, SPACE).start(0)
playloop = new Tone.Player("/static/recordings/" + RECORDING).connect(channel)
playloop.loop = true
playloop.autostart = true
break
case 4:
@ -112,13 +112,13 @@ const play = () => {
case 5:
playloop = new Tone.Loop((time) => {
instrument.triggerAttackRelease(NOTE, "9n")
instrument.triggerAttackRelease(NOTE, "16n")
}, SPACE).start(0)
break
case 6:
playloop = new Tone.Loop((time) => {
instrument.triggerAttackRelease(NOTE, "8n")
instrument.triggerAttackRelease(NOTE, "16n")
}, SPACE).start(0)
break
@ -130,11 +130,29 @@ const play = () => {
case 8:
playloop = new Tone.Loop((time) => {
instrument.triggerAttackRelease(NOTE, "6n")
instrument.triggerAttackRelease(NOTE, "8n")
}, SPACE).start(0)
break
case 9:
playloop = new Tone.Loop((time) => {
instrument.triggerAttackRelease(NOTE, "8n")
}, SPACE).start(0)
break
case 10:
playloop = new Tone.Loop((time) => {
instrument.triggerAttackRelease(NOTE, "6n")
}, SPACE).start(0)
break
case 11:
playloop = new Tone.Loop((time) => {
instrument.triggerAttackRelease(NOTE, "6n")
}, SPACE).start(0)
break
case 12:
playloop = new Tone.Loop((time) => {
instrument.triggerAttackRelease(NOTE, "6n")
}, SPACE).start(0)
@ -147,18 +165,18 @@ const play = () => {
(function() {
socket.on('all_action', () => {
document.body.style.background = "orange"
voice.start()
})
socket.on('all_noise', () => {
document.body.style.background = "black"
voice.stop()
channel.disconnect(pingpong)
noise.connect(Tone.Master)
noise.start()
})
socket.on('all_stop', () => {
noise.stop()
})
const flowers = ["🌼", "🌸", "💮", "🌺", "🪷", "🏵️"]

View file

@ -6,7 +6,7 @@ export const NOTE = pick(NOTES)
const SPACING = ["7h", "8h", "9h", "10h"]
export const SPACE = pick(SPACING)
const RECORDINGS = ["birds.mp3", "stairs.mp3"]
const RECORDINGS = ["birds.mp3", "stairs.mp3", "train.mp3"]
export const RECORDING = pick(RECORDINGS)
Tone.Transport.bpm.value = 60;

BIN
static/recordings/train.mp3 Normal file

Binary file not shown.