Skip to content

Commit

Permalink
Added drum presets.
Browse files Browse the repository at this point in the history
  • Loading branch information
severak2 committed Sep 11, 2024
1 parent c3c3d9e commit e5e73dc
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 55 deletions.
126 changes: 71 additions & 55 deletions groovebox.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
summary { margin-bottom: 5px; }

.device { padding: 10px; border-bottom: 1px double black; }
.pad { padding: 1em; }
.lpad { padding-left: 1em;}

.drum-tones { border-collapse: collapse; border-right: 1px solid darkgray; }
Expand Down Expand Up @@ -104,9 +105,9 @@
<div class="ub-container">
<br><br>

<div class="ub-box lpad" id="box_welcome">
<div class="ub-box pad" id="box_welcome">
<img src="img/groovebox-mixing.jpg" class="ub-fit-img" alt="cherrypicking depiction">
<p>This is my attempt to construct ideal software groovebox. It's not finished yet but it works already.</p>
<p>This is my attempt to construct ideal software groovebox. It's not finished yet but you can use it already.</p>
<p>Feel free to test it and report bugs <a href="https://github.com/severak/cyber-music-studio/issues" target="_blank">here</a>.</p>
<center><button id="power" class="ub-button">OK</button></center>
</div>
Expand Down Expand Up @@ -143,42 +144,46 @@ <h1>Severák's ideal Groovebox</h1>
<summary>Dr. GROOVE</summary>
<div class="lpad">
<details open>
<summary>DRUM KIT
<!-- <button>load preset -></button>
<select>
<option>trash</option>
</select> -->
</summary>
<summary>DRUM KIT</summary>

<select id="drum_preset_selector">
<option value="presets/mc3a.json">cheap keyboard drums</option>
<option value="presets/dr660.json">DR660</option>
<option value="presets/dr660industrial.json">DR660 (Industrial edition)</option>
<option value="presets/empty.json">=== empty ===</option>
</select>
<button id="load_drum_preset">load kit</button> <small>&lt;-- use this or load some samples from your machine</small>

<table class="drum-tones">
<tr>
<td id="dr_name_1">---</td>
<td id="dr_name_2">---</td>
<td id="dr_name_3">---</td>
<td id="dr_name_4">---</td>
<td id="dr_name_5">---</td>
<td id="dr_name_6">---</td>
<td id="dr_name_7">---</td>
<td id="dr_name_8">---</td>
<td id="dr_name_1" class="name">---</td>
<td id="dr_name_2" class="name">---</td>
<td id="dr_name_3" class="name">---</td>
<td id="dr_name_4" class="name">---</td>
<td id="dr_name_5" class="name">---</td>
<td id="dr_name_6" class="name">---</td>
<td id="dr_name_7" class="name">---</td>
<td id="dr_name_8" class="name">---</td>
</tr>
<tr>
<td id="dr_change_1"><button>CHANGE</button></td>
<td id="dr_change_2"><button>CHANGE</button></td>
<td id="dr_change_3"><button>CHANGE</button></td>
<td id="dr_change_4"><button>CHANGE</button></td>
<td id="dr_change_5"><button>CHANGE</button></td>
<td id="dr_change_6"><button>CHANGE</button></td>
<td id="dr_change_7"><button>CHANGE</button></td>
<td id="dr_change_8"><button>CHANGE</button></td>
<td id="dr_change_1"><button>LOAD...</button></td>
<td id="dr_change_2"><button>LOAD...</button></td>
<td id="dr_change_3"><button>LOAD...</button></td>
<td id="dr_change_4"><button>LOAD...</button></td>
<td id="dr_change_5"><button>LOAD...</button></td>
<td id="dr_change_6"><button>LOAD...</button></td>
<td id="dr_change_7"><button>LOAD...</button></td>
<td id="dr_change_8"><button>LOAD...</button></td>
</tr>
<tr>
<td><webaudio-knob id="dr_tune_1" value="0" min="-100" max="100" step="1"></webaudio-knob></td>
<td><webaudio-knob id="dr_tune_2" value="0" min="-100" max="100" step="1"></webaudio-knob></td>
<td><webaudio-knob id="dr_tune_3" value="0" min="-100" max="100" step="1"></webaudio-knob></td>
<td><webaudio-knob id="dr_tune_4" value="0" min="-100" max="100" step="1"></webaudio-knob></td>
<td><webaudio-knob id="dr_tune_5" value="0" min="-100" max="100" step="1"></webaudio-knob></td>
<td><webaudio-knob id="dr_tune_6" value="0" min="-100" max="100" step="1"></webaudio-knob></td>
<td><webaudio-knob id="dr_tune_7" value="0" min="-100" max="100" step="1"></webaudio-knob></td>
<td><webaudio-knob id="dr_tune_8" value="0" min="-100" max="100" step="1"></webaudio-knob></td>
<td><webaudio-knob id="dr_tune_1" value="0" min="-600" max="600" step="1"></webaudio-knob></td>
<td><webaudio-knob id="dr_tune_2" value="0" min="-600" max="600" step="1"></webaudio-knob></td>
<td><webaudio-knob id="dr_tune_3" value="0" min="-600" max="600" step="1"></webaudio-knob></td>
<td><webaudio-knob id="dr_tune_4" value="0" min="-600" max="600" step="1"></webaudio-knob></td>
<td><webaudio-knob id="dr_tune_5" value="0" min="-600" max="600" step="1"></webaudio-knob></td>
<td><webaudio-knob id="dr_tune_6" value="0" min="-600" max="600" step="1"></webaudio-knob></td>
<td><webaudio-knob id="dr_tune_7" value="0" min="-600" max="600" step="1"></webaudio-knob></td>
<td><webaudio-knob id="dr_tune_8" value="0" min="-600" max="600" step="1"></webaudio-knob></td>
</tr>
<tr>
<td>tune</td>
Expand All @@ -202,7 +207,7 @@ <h1>Severák's ideal Groovebox</h1>
</tr>
<tr>
<td>pan</td>
<td>tune</td>
<td>pan</td>
<td>pan</td>
<td>pan</td>
<td>pan</td>
Expand Down Expand Up @@ -355,28 +360,6 @@ <h1>Severák's ideal Groovebox</h1>
hb.chain(me['panner_' + ch], me['gain_' + ch], me.output);
}

// generated sounds as preset
ub.gebi('dr_name_1').innerText = 'noise';
ub.gebi('drseq_name_1').innerText = 'noise';
me.samples_1 = hb.generateWaveformBuffer(function(n) { return (Math.random() * 2 -1) * (1 - n); }, {}, hb.ac.sampleRate * 0.1);
ub.gebi('dr_name_2').innerText = 'sin';
ub.gebi('drseq_name_2').innerText = 'sin';
me.samples_2 = hb.generateWaveformBuffer(hb.generators.sin, {}, hb.midi2cps(36));
/*
ub.gebi('dr_name_3').innerText = 'triangle';
ub.gebi('drseq_name_3').innerText = 'triangle';
me.samples_3 = hb.generateWaveformBuffer(hb.generators.triangle);
ub.gebi('dr_name_4').innerText = 'saw';
ub.gebi('drseq_name_4').innerText = 'saw';
me.samples_4 = hb.generateWaveformBuffer(hb.generators.saw);
ub.gebi('dr_name_5').innerText = 'sqr';
ub.gebi('drseq_name_5').innerText = 'sqe';
me.samples_5 = hb.generateWaveformBuffer(hb.generators.sqr);
ub.gebi('dr_name_6').innerText = 'pulse';
ub.gebi('drseq_name_6').innerText = 'pulse';
me.samples_6 = hb.generateWaveformBuffer(hb.generators.pulse);
*/

me.param = function (name, val) {
me[name] = val;
[paramName, paramNo] = name.split('_');
Expand Down Expand Up @@ -440,6 +423,19 @@ <h1>Severák's ideal Groovebox</h1>
reader.readAsArrayBuffer(file);
});

me.loadSampleIntoSlot = function (slot, filename, buffer, tune, vol) {
if (!buffer) buffer = hb.generateWaveformBuffer(function (){return 0;}, {}, 0);
me['samples_' + slot] = buffer;
ub.gebi('dr_name_'+slot).innerText = filename;
ub.gebi('drseq_name_'+slot).innerText = filename;
if (!tune) tune = 0;
me['tune_' + slot] = tune;
ub.gebi('dr_tune_'+slot).value = tune;
if (!vol) vol = 0.5;
me['vol_' + slot] = vol;
ub.gebi('dr_vol_'+slot).value = vol;
};

return me;
}

Expand Down Expand Up @@ -484,6 +480,26 @@ <h1>Severák's ideal Groovebox</h1>
ub.on('dr_play_'+ch, 'click', function (ev){ ub.stop(ev); drums.trigger(ch, 100); });
}

ub.on('load_drum_preset', 'click', function (ev){
ub.stop(ev);
fetch(ub.gebi('drum_preset_selector').value).then((response) => {
return response.json();
}).then(function (presetData){
//console.log(presetData);
for (let ch = 0; ch < 7; ch++) {
console.log(presetData.samples[ch]);
if (presetData.samples[ch]) {
hb.ac.decodeAudioData(_base64ToArrayBuffer(presetData.samples[ch].b64), function (buffer) {
drums.loadSampleIntoSlot(ch+1, presetData.samples[ch].name, buffer, presetData.samples[ch].tune, presetData.samples[ch].vol);
});
} else {
drums.loadSampleIntoSlot(ch+1, '---');
}
}
});

});

ub.on('drum_sequencer', 'click', 'tr.notes td', function (ev) {
if (ub.hasClass(ev.target, 'active')) {
ub.delClass(ev.target, 'active');
Expand Down
1 change: 1 addition & 0 deletions presets/dr660.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions presets/dr660industrial.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions presets/empty.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"samples":[]}
62 changes: 62 additions & 0 deletions presets/gen.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
// generates presets for Groovebox:

class DrGroovePreset
{
protected $samples = [];

public function addSample($path, $alias='', $tune=0, $vol=0.5)
{
if (!$alias) $alias = basename($path);
$data = file_get_contents($path);

$this->samples[] = [
'name'=>$alias,
'b64'=>base64_encode($data),
'tune'=>$tune,
'vol'=>$vol
];

return $this;
}

public function save($file)
{
file_put_contents($file, json_encode(['samples'=>$this->samples]));
}
}

// these paths are not commited but these are trivial to reconstruct if you need them

// lofi MC3a
(new DrGroovePreset())
->addSample('../../paleta/mc3a_kick.wav', 'kick')
->addSample('../../paleta/mc3a_snare.wav', 'snare')
->addSample('../../paleta/mc3_open_hat.wav', 'open hat')
->addSample('../../paleta/mc3a_closed_hat.wav', 'closed hat')
->addSample('../../paleta/mc3a_bongo.wav', 'bongo')
->save('mc3a.json');

// DR660
(new DrGroovePreset())
->addSample('../../samples_external/legowelt_dr660/DR660 Bassdrum modest.wav', 'kick')
->addSample('../../samples_external/legowelt_dr660/DR660 Snare Yeah.wav', 'snare')
->addSample('../../samples_external/legowelt_dr660/DR660 Hihat Real Open.wav', 'open hat')
->addSample('../../samples_external/legowelt_dr660/DR660 Hihat Real Closed.wav', 'closed hat')
->addSample('../../samples_external/legowelt_dr660/DR660 808 Cowbell.wav', 'cowbell low', -300)
->addSample('../../samples_external/legowelt_dr660/DR660 808 Cowbell.wav', 'cowbell', 0)
->addSample('../../samples_external/legowelt_dr660/DR660 808 Cowbell.wav', 'cowbell hi', +300)
->save('dr660.json');

// DR660 industrial
(new DrGroovePreset())
->addSample('../../samples_external/legowelt_dr660/DR660 Bassdrum Industrial.wav', 'kick')
->addSample('../../samples_external/legowelt_dr660/DR660 Snare Dark and Big.wav', 'snare')
->addSample('../../samples_external/legowelt_dr660/DR660 Anvil.wav', 'anvil')
->addSample('../../samples_external/legowelt_dr660/DR660 Industrial Sound.wav', 'hammer')
->addSample('../../samples_external/legowelt_dr660/DR660 Cowbell.wav', 'cowbell')
->addSample('../../samples_external/legowelt_dr660/DR660 Clap verb.wav', 'clap')
->save('dr660industrial.json');

(new DrGroovePreset())
->save('empty.json');
1 change: 1 addition & 0 deletions presets/mc3a.json

Large diffs are not rendered by default.

0 comments on commit e5e73dc

Please sign in to comment.