mirror of
https://github.com/kaythomas0/noisedash.git
synced 2025-11-15 12:47:58 +00:00
Support multiple sporadic samples
This commit is contained in:
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "noisedash",
|
"name": "noisedash",
|
||||||
"version": "0.5.0",
|
"version": "0.6.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "noisedash",
|
"name": "noisedash",
|
||||||
"version": "0.5.0",
|
"version": "0.6.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"author": "Kay Thomas <kaythomas@pm.me> (https://kaythomas.dev)",
|
"author": "Kay Thomas <kaythomas@pm.me> (https://kaythomas.dev)",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ export default {
|
|||||||
const minInt = parseInt(s.sporadicMin, 10)
|
const minInt = parseInt(s.sporadicMin, 10)
|
||||||
const rand = Math.floor(Math.random() * (maxInt - minInt + 1) + minInt)
|
const rand = Math.floor(Math.random() * (maxInt - minInt + 1) + minInt)
|
||||||
|
|
||||||
this.initialSporadicPlayInterval = setInterval(() => this.playSporadicSample(), rand * 1000)
|
s.initialSporadicPlayInterval = setInterval(() => this.playSporadicSample(s.id), rand * 1000)
|
||||||
} else {
|
} else {
|
||||||
this.players.player(s.id).loop = true
|
this.players.player(s.id).loop = true
|
||||||
this.players.player(s.id).unsync().sync().start(0)
|
this.players.player(s.id).unsync().sync().start(0)
|
||||||
@@ -238,22 +238,19 @@ export default {
|
|||||||
|
|
||||||
Tone.Transport.start('+0.1')
|
Tone.Transport.start('+0.1')
|
||||||
},
|
},
|
||||||
playSporadicSample () {
|
playSporadicSample (id) {
|
||||||
clearInterval(this.initialSporadicPlayInterval)
|
const sample = this.loadedSamples.find(s => s.id === id)
|
||||||
|
|
||||||
this.loadedSamples.forEach(s => {
|
clearInterval(sample.initialSporadicPlayInterval)
|
||||||
if (s.playbackMode === 'sporadic') {
|
clearInterval(sample.sporadicInterval)
|
||||||
clearInterval(s.sporadicInterval)
|
|
||||||
|
|
||||||
this.players.player(s.id).unsync().sync().start()
|
this.players.player(id).unsync().sync().start()
|
||||||
|
|
||||||
const maxInt = parseInt(s.sporadicMax, 10)
|
const maxInt = parseInt(sample.sporadicMax, 10)
|
||||||
const minInt = parseInt(s.sporadicMin, 10)
|
const minInt = parseInt(sample.sporadicMin, 10)
|
||||||
s.playNextTime = Math.floor(Math.random() * (maxInt - minInt + 1) + minInt)
|
sample.playNextTime = Math.floor(Math.random() * (maxInt - minInt + 1) + minInt)
|
||||||
|
|
||||||
s.sporadicInterval = setInterval(() => this.playSporadicSample(), s.playNextTime * 1000)
|
sample.sporadicInterval = setInterval(() => this.playSporadicSample(id), sample.playNextTime * 1000)
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
stop () {
|
stop () {
|
||||||
clearInterval(this.transportInterval)
|
clearInterval(this.transportInterval)
|
||||||
@@ -264,9 +261,9 @@ export default {
|
|||||||
this.timeRemaining = 0
|
this.timeRemaining = 0
|
||||||
this.duration = 0
|
this.duration = 0
|
||||||
|
|
||||||
clearInterval(this.initialSporadicPlayInterval)
|
|
||||||
this.loadedSamples.forEach(s => {
|
this.loadedSamples.forEach(s => {
|
||||||
if (s.playbackMode === 'sporadic') {
|
if (s.playbackMode === 'sporadic') {
|
||||||
|
clearInterval(s.initialSporadicPlayInterval)
|
||||||
clearInterval(s.sporadicInterval)
|
clearInterval(s.sporadicInterval)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -832,11 +829,11 @@ export default {
|
|||||||
|
|
||||||
this.players.player(s.id).disconnect()
|
this.players.player(s.id).disconnect()
|
||||||
if (s.reverbEnabled) {
|
if (s.reverbEnabled) {
|
||||||
const reverb = new Tone.Reverb(s.reverbDecay).toDestination()
|
const reverb = new Tone.Reverb(s.reverbDecay).connect(this.recorder).toDestination()
|
||||||
reverb.set({ preDelay: s.reverbPreDelay, wet: s.reverbWet })
|
reverb.set({ preDelay: s.reverbPreDelay, wet: s.reverbWet })
|
||||||
this.players.player(s.id).connect(reverb)
|
this.players.player(s.id).connect(reverb)
|
||||||
} else {
|
} else {
|
||||||
this.players.player(s.id).toDestination()
|
this.players.player(s.id).connect(this.recorder).toDestination()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -850,7 +847,7 @@ export default {
|
|||||||
const minInt = parseInt(s.sporadicMin, 10)
|
const minInt = parseInt(s.sporadicMin, 10)
|
||||||
const rand = Math.floor(Math.random() * (maxInt - minInt + 1) + minInt)
|
const rand = Math.floor(Math.random() * (maxInt - minInt + 1) + minInt)
|
||||||
|
|
||||||
this.initialSporadicPlayInterval = setInterval(() => this.playSporadicSample(), rand * 1000)
|
s.initialSporadicPlayInterval = setInterval(() => this.playSporadicSample(s.id), rand * 1000)
|
||||||
} else {
|
} else {
|
||||||
this.players.player(s.id).loop = true
|
this.players.player(s.id).loop = true
|
||||||
this.players.player(s.id).unsync().sync().start(0)
|
this.players.player(s.id).unsync().sync().start(0)
|
||||||
@@ -873,9 +870,9 @@ export default {
|
|||||||
|
|
||||||
clearInterval(this.recordingInterval)
|
clearInterval(this.recordingInterval)
|
||||||
|
|
||||||
clearInterval(this.initialSporadicPlayInterval)
|
|
||||||
this.loadedSamples.forEach(s => {
|
this.loadedSamples.forEach(s => {
|
||||||
if (s.playbackMode === 'sporadic') {
|
if (s.playbackMode === 'sporadic') {
|
||||||
|
clearInterval(s.initialSporadicPlayInterval)
|
||||||
clearInterval(s.sporadicInterval)
|
clearInterval(s.sporadicInterval)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user