Implement reverb

This commit is contained in:
Kay Thomas
2022-08-13 23:58:39 -07:00
parent 496b71ee7b
commit 3dbbf4c85d
4 changed files with 132 additions and 5 deletions

View File

@@ -73,6 +73,15 @@ module.exports = function () {
db.run('PRAGMA user_version = 2') db.run('PRAGMA user_version = 2')
} }
if (userVersion < 3) {
db.run('ALTER TABLE profiles_samples ADD COLUMN reverb_enabled INTEGER DEFAULT 0')
db.run('ALTER TABLE profiles_samples ADD COLUMN reverb_pre_delay REAL DEFAULT 0')
db.run('ALTER TABLE profiles_samples ADD COLUMN reverb_decay REAL DEFAULT 0')
db.run('ALTER TABLE profiles_samples ADD COLUMN reverb_wet INTEGER DEFAULT 0')
db.run('PRAGMA user_version = 3')
}
} }
}) })
}) })

View File

@@ -59,10 +59,22 @@ router.post('/profiles', (req, res) => {
profileID = this.lastID profileID = this.lastID
req.body.samples.forEach(s => { req.body.samples.forEach(s => {
db.run('INSERT INTO profiles_samples (profile, sample, volume) VALUES (?, ?, ?)', [ db.run(`INSERT INTO profiles_samples(
profile,
sample,
volume,
reverb_enabled,
reverb_pre_delay,
reverb_decay,
reverb_wet)
VALUES (?, ?, ?, ?, ?, ?, ?)`, [
profileID, profileID,
s.id, s.id,
s.volume s.volume,
s.reverbEnabled,
s.reverbPreDelay,
s.reverbDecay,
s.reverbWet
], ],
(err) => { (err) => {
if (err) { if (err) {
@@ -204,10 +216,22 @@ router.put('/profiles/:profileId', (req, res) => {
}) })
req.body.samples.forEach(s => { req.body.samples.forEach(s => {
db.run('INSERT INTO profiles_samples (profile, sample, volume) VALUES (?, ?, ?)', [ db.run(`INSERT INTO profiles_samples(
profile,
sample,
volume,
reverb_enabled,
reverb_pre_delay,
reverb_decay,
reverb_wet)
VALUES (?, ?, ?, ?, ?, ?, ?)`, [
req.params.profileId, req.params.profileId,
s.id, s.id,
s.volume s.volume,
s.reverbEnabled,
s.reverbPreDelay,
s.reverbDecay,
s.reverbWet
], ],
(err) => { (err) => {
if (err) { if (err) {
@@ -355,6 +379,10 @@ router.get('/profiles/:profileId', (req, res) => {
samples.id, samples.id,
name, name,
profiles_samples.volume, profiles_samples.volume,
profiles_samples.reverb_enabled as reverbEnabled,
profiles_samples.reverb_pre_delay as reverbPreDelay,
profiles_samples.reverb_decay as reverbDecay,
profiles_samples.reverb_wet as reverbWet,
fade_in as fadeIn, fade_in as fadeIn,
loop_points_enabled as loopPointsEnabled, loop_points_enabled as loopPointsEnabled,
loop_start as loopStart, loop_start as loopStart,
@@ -382,6 +410,10 @@ router.get('/profiles/:profileId', (req, res) => {
sample.loopPointsEnabled = row.loopPointsEnabled === 1 sample.loopPointsEnabled = row.loopPointsEnabled === 1
sample.loopStart = row.loopStart sample.loopStart = row.loopStart
sample.loopEnd = row.loopEnd sample.loopEnd = row.loopEnd
sample.reverbEnabled = row.reverbEnabled === 1
sample.reverbPreDelay = row.reverbPreDelay
sample.reverbDecay = row.reverbDecay
sample.reverbWet = row.reverbWet
samples.push(sample) samples.push(sample)
}) })

View File

@@ -652,7 +652,9 @@
<v-row <v-row
justify="center" justify="center"
> >
<h2 class="headline font-weight-bold mb-5">
{{ sample.name }} {{ sample.name }}
</h2>
</v-row> </v-row>
<v-row> <v-row>
@@ -679,6 +681,84 @@
<p>{{ loadedSamples[index].volume }}</p> <p>{{ loadedSamples[index].volume }}</p>
</div> </div>
</v-row> </v-row>
<v-row
justify="center"
>
<h2 class="headline mb-5">
Effects
</h2>
</v-row>
<v-row justify="center">
<v-checkbox
v-model="sample.reverbEnabled"
label="Reverb"
/>
</v-row>
<v-row justify="center">
<v-slider
v-model="sample.reverbPreDelay"
:disabled="!sample.reverbEnabled"
label="Pre Delay"
thumb-label
max="16"
min="0"
step="0.5"
class="mx-3"
@input="updateReverbPreDelay(sample.id, index)"
/>
<div
class="mx-3"
>
<p>{{ sample.reverbPreDelay }}</p>
</div>
</v-row>
<v-row justify="center">
<v-slider
v-model="sample.reverbDecay"
:disabled="!sample.reverbEnabled"
label="Decay"
thumb-label
max="16"
min="0"
step="0.5"
class="mx-3"
@input="updateVolume"
/>
<div
class="mx-3"
>
<p> {{ sample.reverbDecay }}</p>
</div>
</v-row>
<v-row justify="center">
<v-slider
v-model="sample.reverbWet"
:disabled="!sample.reverbEnabled"
label="Wet"
thumb-label
max="1"
min="0"
step="0.01"
class="mx-3"
@input="updateVolume"
/>
<div
class="mx-3"
>
<p>{{ sample.reverbWet }}%</p>
</div>
</v-row>
<v-row>
<v-divider
class="mb-7"
/>
</v-row>
</v-container> </v-container>
</v-row> </v-row>

View File

@@ -185,6 +185,12 @@ export default {
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 this.players.player(s.id).volume.value = s.volume
if (s.reverbEnabled) {
const reverb = new Tone.Reverb(s.reverbDecay).toDestination()
reverb.set({ preDelay: s.reverbPreDelay, wet: s.reverbWet })
this.players.player(s.id).connect(reverb)
}
}) })
if (this.isTimerEnabled) { if (this.isTimerEnabled) {