mirror of
https://github.com/kaythomas0/noisedash.git
synced 2025-11-14 20:27:59 +00:00
Add sample edit feature
This commit is contained in:
@@ -61,7 +61,6 @@ module.exports = function () {
|
|||||||
|
|
||||||
if (userVersion === 0) {
|
if (userVersion === 0) {
|
||||||
db.run('ALTER TABLE samples ADD COLUMN fade_in REAL DEFAULT 0')
|
db.run('ALTER TABLE samples ADD COLUMN fade_in REAL DEFAULT 0')
|
||||||
db.run('ALTER TABLE samples ADD COLUMN fade_out REAL DEFAULT 0')
|
|
||||||
db.run('ALTER TABLE samples ADD COLUMN loop_points_enabled INTEGER DEFAULT 0')
|
db.run('ALTER TABLE samples ADD COLUMN loop_points_enabled INTEGER DEFAULT 0')
|
||||||
db.run('ALTER TABLE samples ADD COLUMN loop_start REAL DEFAULT 0')
|
db.run('ALTER TABLE samples ADD COLUMN loop_start REAL DEFAULT 0')
|
||||||
db.run('ALTER TABLE samples ADD COLUMN loop_end REAL DEFAULT 0')
|
db.run('ALTER TABLE samples ADD COLUMN loop_end REAL DEFAULT 0')
|
||||||
|
|||||||
@@ -351,7 +351,9 @@ router.get('/profiles/:profileId', (req, res) => {
|
|||||||
sampleQueryArgs.push(row.sample)
|
sampleQueryArgs.push(row.sample)
|
||||||
})
|
})
|
||||||
|
|
||||||
db.all(`SELECT samples.id, name, profiles_samples.volume
|
db.all(`SELECT samples.id, name, profiles_samples.volume,
|
||||||
|
fade_in as fadeIn, loop_points_enabled as loopPointsEnabled,
|
||||||
|
loop_start as loopStart, loop_end as loopEnd
|
||||||
FROM samples
|
FROM samples
|
||||||
INNER JOIN profiles_samples
|
INNER JOIN profiles_samples
|
||||||
ON profiles_samples.sample = samples.id
|
ON profiles_samples.sample = samples.id
|
||||||
@@ -371,6 +373,10 @@ router.get('/profiles/:profileId', (req, res) => {
|
|||||||
sample.id = row.id
|
sample.id = row.id
|
||||||
sample.name = row.name
|
sample.name = row.name
|
||||||
sample.volume = row.volume
|
sample.volume = row.volume
|
||||||
|
sample.fadeIn = row.fadeIn
|
||||||
|
sample.loopPointsEnabled = row.loopPointsEnabled === 1
|
||||||
|
sample.loopStart = row.loopStart
|
||||||
|
sample.loopEnd = row.loopEnd
|
||||||
|
|
||||||
samples.push(sample)
|
samples.push(sample)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -158,16 +158,13 @@ router.put('/samples/:sampleId', (req, res) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
db.run(`UPDATE samples SET
|
db.run(`UPDATE samples SET
|
||||||
name = ?,
|
|
||||||
fade_in = ?,
|
fade_in = ?,
|
||||||
fade_out = ?,
|
|
||||||
loop_points_enabled = ?,
|
loop_points_enabled = ?,
|
||||||
loop_start = ?,
|
loop_start = ?,
|
||||||
loop_end = ?,
|
loop_end = ?
|
||||||
WHERE id = ?`, [
|
WHERE id = ?`, [
|
||||||
req.body.name,
|
|
||||||
req.body.fadeIn,
|
req.body.fadeIn,
|
||||||
req.body.loopPointsEnabled,
|
req.body.loopPointsEnabled ? 1 : 0,
|
||||||
req.body.loopStart,
|
req.body.loopStart,
|
||||||
req.body.loopEnd,
|
req.body.loopEnd,
|
||||||
req.params.sampleId
|
req.params.sampleId
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
fab
|
fab
|
||||||
large
|
large
|
||||||
color="primary"
|
color="primary"
|
||||||
|
:loading="mainPlayLoading"
|
||||||
@click="play"
|
@click="play"
|
||||||
>
|
>
|
||||||
<v-icon>mdi-play</v-icon>
|
<v-icon>mdi-play</v-icon>
|
||||||
@@ -699,6 +700,7 @@
|
|||||||
<v-form
|
<v-form
|
||||||
ref="editSampleForm"
|
ref="editSampleForm"
|
||||||
v-model="isEditSampleValid"
|
v-model="isEditSampleValid"
|
||||||
|
lazy-validation
|
||||||
>
|
>
|
||||||
<v-card>
|
<v-card>
|
||||||
<v-card-title>
|
<v-card-title>
|
||||||
@@ -719,12 +721,12 @@
|
|||||||
</v-row>
|
</v-row>
|
||||||
|
|
||||||
<v-row>
|
<v-row>
|
||||||
<p>Sample Length (Seconds): {{ previewSampleLength }} </p>
|
<p>Sample Length: {{ Math.round(previewSampleLength * 100) / 100 }} Seconds </p>
|
||||||
</v-row>
|
</v-row>
|
||||||
|
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-checkbox
|
<v-checkbox
|
||||||
v-model="useLoopPoints"
|
v-model="loopPointsEnabled"
|
||||||
:disabled="samplePreviewPlaying"
|
:disabled="samplePreviewPlaying"
|
||||||
label="Use Loop Points"
|
label="Use Loop Points"
|
||||||
class="mx-3"
|
class="mx-3"
|
||||||
@@ -737,7 +739,7 @@
|
|||||||
type="number"
|
type="number"
|
||||||
label="Loop Start Time"
|
label="Loop Start Time"
|
||||||
class="mx-3"
|
class="mx-3"
|
||||||
:disabled="!useLoopPoints || samplePreviewPlaying"
|
:disabled="!loopPointsEnabled || samplePreviewPlaying"
|
||||||
:rules="[rules.gt(-1)]"
|
:rules="[rules.gt(-1)]"
|
||||||
@change="updatePreviewSamplePlayerLoopPoints"
|
@change="updatePreviewSamplePlayerLoopPoints"
|
||||||
/>
|
/>
|
||||||
@@ -747,7 +749,7 @@
|
|||||||
type="number"
|
type="number"
|
||||||
label="Loop End Time"
|
label="Loop End Time"
|
||||||
class="mx-3"
|
class="mx-3"
|
||||||
:disabled="!useLoopPoints || samplePreviewPlaying"
|
:disabled="!loopPointsEnabled || samplePreviewPlaying"
|
||||||
:rules="[rules.gt(-1), rules.lt(previewSampleLength)]"
|
:rules="[rules.gt(-1), rules.lt(previewSampleLength)]"
|
||||||
@change="updatePreviewSamplePlayerLoopPoints"
|
@change="updatePreviewSamplePlayerLoopPoints"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ export default {
|
|||||||
name: 'Noise',
|
name: 'Noise',
|
||||||
|
|
||||||
data: () => ({
|
data: () => ({
|
||||||
|
mainPlayLoading: true,
|
||||||
isTimerValid: false,
|
isTimerValid: false,
|
||||||
selectedProfile: {},
|
selectedProfile: {},
|
||||||
profileItems: [],
|
profileItems: [],
|
||||||
@@ -47,8 +48,7 @@ export default {
|
|||||||
uploadSampleDialog: false,
|
uploadSampleDialog: false,
|
||||||
addSampleDialog: false,
|
addSampleDialog: false,
|
||||||
editSampleDialog: false,
|
editSampleDialog: false,
|
||||||
editSampleName: '',
|
loopPointsEnabled: false,
|
||||||
useLoopPoints: false,
|
|
||||||
loopStart: 0,
|
loopStart: 0,
|
||||||
loopEnd: 0,
|
loopEnd: 0,
|
||||||
fadeIn: 0,
|
fadeIn: 0,
|
||||||
@@ -107,6 +107,10 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
play () {
|
play () {
|
||||||
|
if (!this.players.loaded) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
this.playDisabled = true
|
this.playDisabled = true
|
||||||
Transport.cancel()
|
Transport.cancel()
|
||||||
|
|
||||||
@@ -136,9 +140,10 @@ export default {
|
|||||||
this.loadedSamples.forEach(s => {
|
this.loadedSamples.forEach(s => {
|
||||||
this.players.player(s.id).loop = true
|
this.players.player(s.id).loop = true
|
||||||
this.players.player(s.id).fadeIn = s.fadeIn
|
this.players.player(s.id).fadeIn = s.fadeIn
|
||||||
if (s.loopPointEnabled) {
|
if (s.loopPointsEnabled) {
|
||||||
this.players.player(s.id).setLoopPoints(s.loopStart, s.loopEnd)
|
this.players.player(s.id).setLoopPoints(s.loopStart, s.loopEnd)
|
||||||
}
|
}
|
||||||
|
this.players.player(s.id).volume.value = s.volume
|
||||||
})
|
})
|
||||||
|
|
||||||
if (this.isTimerEnabled) {
|
if (this.isTimerEnabled) {
|
||||||
@@ -380,6 +385,7 @@ export default {
|
|||||||
this.players.add(s.id, '/samples/' + s.user + '_' + s.name).toDestination()
|
this.players.add(s.id, '/samples/' + s.user + '_' + s.name).toDestination()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
this.mainPlayLoading = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -459,6 +465,11 @@ export default {
|
|||||||
closeEditSampleForm () {
|
closeEditSampleForm () {
|
||||||
this.editSampleDialog = false
|
this.editSampleDialog = false
|
||||||
this.previewSampleLoading = true
|
this.previewSampleLoading = true
|
||||||
|
if (this.samplePreviewPlaying) {
|
||||||
|
this.samplePreviewPlaying = false
|
||||||
|
this.previewSampleButtonText = 'Preview Sample'
|
||||||
|
this.samplePreviewPlayer.stop()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
openImportDialog () {
|
openImportDialog () {
|
||||||
this.profileMoreDialog = false
|
this.profileMoreDialog = false
|
||||||
@@ -571,18 +582,22 @@ export default {
|
|||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
const sample = response.data.sample
|
const sample = response.data.sample
|
||||||
|
|
||||||
|
await this.samplePreviewPlayer.load('/samples/' + sample.user + '_' + sample.name)
|
||||||
|
|
||||||
this.fadeIn = sample.fadeIn
|
this.fadeIn = sample.fadeIn
|
||||||
|
this.loopPointsEnabled = sample.loopPointsEnabled
|
||||||
if (sample.loopPointsEnabled) {
|
if (sample.loopPointsEnabled) {
|
||||||
this.loopStart = sample.loopStart
|
this.loopStart = sample.loopStart
|
||||||
this.loopEnd = sample.loopEnd
|
this.loopEnd = sample.loopEnd
|
||||||
|
|
||||||
this.samplePreviewPlayer.setLoopPoints(this.loopStart, this.loopEnd)
|
this.samplePreviewPlayer.setLoopPoints(this.loopStart, this.loopEnd)
|
||||||
|
} else {
|
||||||
|
this.loopStart = 0
|
||||||
|
this.loopEnd = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
this.samplePreviewPlayer.fadeIn = this.fadeIn
|
this.samplePreviewPlayer.fadeIn = this.fadeIn
|
||||||
|
|
||||||
await this.samplePreviewPlayer.load('/samples/' + sample.user + '_' + sample.name)
|
|
||||||
|
|
||||||
this.previewSampleLength = this.samplePreviewPlayer.buffer.duration
|
this.previewSampleLength = this.samplePreviewPlayer.buffer.duration
|
||||||
|
|
||||||
this.previewSampleLoading = false
|
this.previewSampleLoading = false
|
||||||
@@ -602,15 +617,18 @@ export default {
|
|||||||
},
|
},
|
||||||
editSample () {
|
editSample () {
|
||||||
this.$http.put('/samples/'.concat(this.selectedEditSample.id), {
|
this.$http.put('/samples/'.concat(this.selectedEditSample.id), {
|
||||||
name: this.editSampleName,
|
|
||||||
fadeIn: this.fadeIn,
|
fadeIn: this.fadeIn,
|
||||||
loopPointsEnabled: this.loopPointEnabled,
|
loopPointsEnabled: this.loopPointsEnabled,
|
||||||
loopStart: this.loopStart,
|
loopStart: this.loopStart,
|
||||||
loopEnd: this.loopEnd
|
loopEnd: this.loopEnd
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
this.infoSnackbarText = 'Sample Saved'
|
this.infoSnackbarText = 'Sample Saved'
|
||||||
this.infoSnackbar = true
|
this.infoSnackbar = true
|
||||||
|
|
||||||
|
this.getSamples()
|
||||||
|
this.loadProfile()
|
||||||
|
this.closeEditSampleForm()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user