mirror of
https://github.com/kaythomas0/noisedash.git
synced 2025-11-17 13:38:05 +00:00
Implement sample playback mode, fix loop points bug
This commit is contained in:
@@ -802,7 +802,6 @@
|
||||
class="mx-3"
|
||||
:disabled="sample.playbackMode != 'sporadic' || playDisabled"
|
||||
:rules="[validateSporadicRange(sample)]"
|
||||
@change="updateSporadicPlayNext"
|
||||
/>
|
||||
|
||||
<v-text-field
|
||||
@@ -812,7 +811,6 @@
|
||||
class="mx-3"
|
||||
:disabled="sample.playbackMode != 'sporadic' || playDisabled"
|
||||
:rules="[validateSporadicRange(sample)]"
|
||||
@change="updateSporadicPlayNext"
|
||||
/>
|
||||
</v-row>
|
||||
</v-form>
|
||||
@@ -1009,7 +1007,7 @@
|
||||
<v-checkbox
|
||||
v-model="previewSampleLoopPointsEnabled"
|
||||
:disabled="previewSamplePlaying"
|
||||
label="Use Loop Points"
|
||||
label="Use Loop Points (Continuous Playback Mode Only)"
|
||||
@change="updatePreviewSampleLoopPoints"
|
||||
/>
|
||||
</v-row>
|
||||
|
||||
@@ -128,6 +128,9 @@ export default {
|
||||
settings.push(s.reverbPreDelay)
|
||||
settings.push(s.reverbDecay)
|
||||
settings.push(s.reverbWet)
|
||||
settings.push(s.playbackMode)
|
||||
settings.push(s.sporadicMin)
|
||||
settings.push(s.sporadicMax)
|
||||
})
|
||||
|
||||
return settings
|
||||
@@ -188,6 +191,8 @@ export default {
|
||||
this.players.player(s.id).fadeIn = s.fadeIn
|
||||
if (s.loopPointsEnabled) {
|
||||
this.players.player(s.id).setLoopPoints(s.loopStart, s.loopEnd)
|
||||
} else {
|
||||
this.players.player(s.id).setLoopPoints(0, this.players.player(s.id).buffer.duration)
|
||||
}
|
||||
this.players.player(s.id).volume.value = s.volume
|
||||
|
||||
@@ -217,10 +222,13 @@ export default {
|
||||
|
||||
this.loadedSamples.forEach(s => {
|
||||
if (s.playbackMode === 'sporadic') {
|
||||
s.playNextTime = Math.floor(Math.random() * (s.sporadicMax - s.sporadicMin + 1) + s.sporadicMin)
|
||||
console.log('PLAY NEXT TIME: ', s.playNextTime)
|
||||
this.players.player(s.id).loop = false
|
||||
s.sporadicInterval = setInterval(() => this.playSporadicSample(), s.playNextTime * 1000)
|
||||
|
||||
const maxInt = parseInt(s.sporadicMax, 10)
|
||||
const minInt = parseInt(s.sporadicMin, 10)
|
||||
const rand = Math.floor(Math.random() * (maxInt - minInt + 1) + minInt)
|
||||
|
||||
this.initialSporadicPlayInterval = setInterval(() => this.playSporadicSample(), rand * 1000)
|
||||
} else {
|
||||
this.players.player(s.id).loop = true
|
||||
this.players.player(s.id).unsync().sync().start(0)
|
||||
@@ -231,13 +239,19 @@ export default {
|
||||
Tone.Transport.start('+0.1')
|
||||
},
|
||||
playSporadicSample () {
|
||||
clearInterval(this.initialSporadicPlayInterval)
|
||||
|
||||
this.loadedSamples.forEach(s => {
|
||||
if (s.playbackMode === 'sporadic') {
|
||||
this.players.player(s.id).unsync().sync().start()
|
||||
clearInterval(s.sporadicInterval)
|
||||
s.playNextTime = Math.floor(Math.random() * (s.sporadicMax - s.sporadicMin + 1) + s.sporadicMin)
|
||||
|
||||
this.players.player(s.id).unsync().sync().start()
|
||||
|
||||
const maxInt = parseInt(s.sporadicMax, 10)
|
||||
const minInt = parseInt(s.sporadicMin, 10)
|
||||
s.playNextTime = Math.floor(Math.random() * (maxInt - minInt + 1) + minInt)
|
||||
|
||||
s.sporadicInterval = setInterval(() => this.playSporadicSample(), s.playNextTime * 1000)
|
||||
console.log('PLAY NEXT TIME: ', s.playNextTime)
|
||||
}
|
||||
})
|
||||
},
|
||||
@@ -250,6 +264,7 @@ export default {
|
||||
this.timeRemaining = 0
|
||||
this.duration = 0
|
||||
|
||||
clearInterval(this.initialSporadicPlayInterval)
|
||||
this.loadedSamples.forEach(s => {
|
||||
if (s.playbackMode === 'sporadic') {
|
||||
clearInterval(s.sporadicInterval)
|
||||
@@ -858,14 +873,6 @@ export default {
|
||||
this.updateProfile()
|
||||
this.confirmSwitchProfileDialog = false
|
||||
},
|
||||
updateSporadicPlayNext () {
|
||||
this.loadedSamples.forEach(s => {
|
||||
if (s.playbackMode === 'sporadic') {
|
||||
clearInterval(s.sporadicInterval)
|
||||
s.playNextTime = Math.floor(Math.random() * (s.sporadicMax - s.sporadicMin + 1) + s.sporadicMin)
|
||||
}
|
||||
})
|
||||
},
|
||||
validateSporadicRange (sample) {
|
||||
const min = parseInt(sample.sporadicMin, 10)
|
||||
const max = parseInt(sample.sporadicMax, 10)
|
||||
|
||||
Reference in New Issue
Block a user