Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions dsp/Params.cmajor
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ namespace Percupuff
float crash1Midi;
float crash2Midi;
float crash3Midi;
float rideBellLevel;
float rideBellPanning;
float rideBellVelocity;
float rideBellMidi;
float bongoLevel;
float bongoPanning;
float bongoVelocity;
Expand Down Expand Up @@ -82,10 +86,6 @@ namespace Percupuff
float cowbellPanning;
float cowbellVelocity;
float cowbellMidi;
float rideBellLevel;
float rideBellPanning;
float rideBellVelocity;
float rideBellMidi;
float sideStickLevel;
float sideStickPanning;
float sideStickVelocity;
Expand Down Expand Up @@ -130,6 +130,10 @@ namespace Percupuff
p.crash1Midi = 49.0f;
p.crash2Midi = 57.0f;
p.crash3Midi = 52.0f;
p.rideBellLevel = 50.0f;
p.rideBellPanning = 0.0f;
p.rideBellVelocity = 100.0f;
p.rideBellMidi = 53.0f;
p.bongoLevel = 50.0f;
p.bongoPanning = 0.0f;
p.bongoVelocity = 100.0f;
Expand Down Expand Up @@ -169,10 +173,6 @@ namespace Percupuff
p.cowbellPanning = 0.0f;
p.cowbellVelocity = 100.0f;
p.cowbellMidi = 56.0f;
p.rideBellLevel = 50.0f;
p.rideBellPanning = 0.0f;
p.rideBellVelocity = 100.0f;
p.rideBellMidi = 53.0f;
p.sideStickLevel = 50.0f;
p.sideStickPanning = 0.0f;
p.sideStickVelocity = 100.0f;
Expand Down Expand Up @@ -217,6 +217,10 @@ namespace Percupuff
input event float crash1Midi [[ name: "crash1Midi", min: 0, max: 127, init: 49, step: 1 ]];
input event float crash2Midi [[ name: "crash2Midi", min: 0, max: 127, init: 57, step: 1 ]];
input event float crash3Midi [[ name: "crash3Midi", min: 0, max: 127, init: 52, step: 1 ]];
input event float rideBellLevel [[ name: "rideBellLevel", min: 0, max: 100, init: 50, step: 1 ]];
input event float rideBellPanning [[ name: "rideBellPanning", min: -100, max: 100, init: 0, step: 5 ]];
input event float rideBellVelocity [[ name: "rideBellVelocity", min: 0, max: 100, init: 100, step: 1 ]];
input event float rideBellMidi [[ name: "rideBellMidi", min: 0, max: 127, init: 53, step: 1 ]];
input event float bongoLevel [[ name: "bongoLevel", min: 0, max: 100, init: 50, step: 1 ]];
input event float bongoPanning [[ name: "bongoPanning", min: -100, max: 100, init: 0, step: 5 ]];
input event float bongoVelocity [[ name: "bongoVelocity", min: 0, max: 100, init: 100, step: 1 ]];
Expand Down Expand Up @@ -256,10 +260,6 @@ namespace Percupuff
input event float cowbellPanning [[ name: "cowbellPanning", min: -100, max: 100, init: 0, step: 5 ]];
input event float cowbellVelocity [[ name: "cowbellVelocity", min: 0, max: 100, init: 100, step: 1 ]];
input event float cowbellMidi [[ name: "cowbellMidi", min: 0, max: 127, init: 56, step: 1 ]];
input event float rideBellLevel [[ name: "rideBellLevel", min: 0, max: 100, init: 50, step: 1 ]];
input event float rideBellPanning [[ name: "rideBellPanning", min: -100, max: 100, init: 0, step: 5 ]];
input event float rideBellVelocity [[ name: "rideBellVelocity", min: 0, max: 100, init: 100, step: 1 ]];
input event float rideBellMidi [[ name: "rideBellMidi", min: 0, max: 127, init: 53, step: 1 ]];
input event float sideStickLevel [[ name: "sideStickLevel", min: 0, max: 100, init: 50, step: 1 ]];
input event float sideStickPanning [[ name: "sideStickPanning", min: -100, max: 100, init: 0, step: 5 ]];
input event float sideStickVelocity [[ name: "sideStickVelocity", min: 0, max: 100, init: 100, step: 1 ]];
Expand Down Expand Up @@ -307,6 +307,10 @@ namespace Percupuff
event crash1Midi (float f) { params.crash1Midi = f; update(); }
event crash2Midi (float f) { params.crash2Midi = f; update(); }
event crash3Midi (float f) { params.crash3Midi = f; update(); }
event rideBellLevel (float f) { params.rideBellLevel = f; update(); }
event rideBellPanning (float f) { params.rideBellPanning = f; update(); }
event rideBellVelocity (float f) { params.rideBellVelocity = f; update(); }
event rideBellMidi (float f) { params.rideBellMidi = f; update(); }
event bongoLevel (float f) { params.bongoLevel = f; update(); }
event bongoPanning (float f) { params.bongoPanning = f; update(); }
event bongoVelocity (float f) { params.bongoVelocity = f; update(); }
Expand Down Expand Up @@ -346,10 +350,6 @@ namespace Percupuff
event cowbellPanning (float f) { params.cowbellPanning = f; update(); }
event cowbellVelocity (float f) { params.cowbellVelocity = f; update(); }
event cowbellMidi (float f) { params.cowbellMidi = f; update(); }
event rideBellLevel (float f) { params.rideBellLevel = f; update(); }
event rideBellPanning (float f) { params.rideBellPanning = f; update(); }
event rideBellVelocity (float f) { params.rideBellVelocity = f; update(); }
event rideBellMidi (float f) { params.rideBellMidi = f; update(); }
event sideStickLevel (float f) { params.sideStickLevel = f; update(); }
event sideStickPanning (float f) { params.sideStickPanning = f; update(); }
event sideStickVelocity (float f) { params.sideStickVelocity = f; update(); }
Expand Down
1 change: 1 addition & 0 deletions dsp/Percupuff.cmajor
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ namespace Percupuff
noise -> clap.noiseIn;
noise -> crash.noiseIn;
noise -> claves.noiseIn;
noise -> sideStick.noiseIn;

// Take the output from all of our sounds, mix it together and put
// it into the gain limiter to adjust how loud they are.
Expand Down
65 changes: 49 additions & 16 deletions dsp/drums/SideStick.cmajor
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
// sound inspired by https://www.youtube.com/watch?v=cs9wltg-Nmo

namespace Percupuff
{
namespace Drums
{
// This processor tries to create a realistic side stick sound.
// Additive synthesis is used to create the initial impact of the stick on the rim of the snare,
// with filtered white noise mixed in for more brightness.
processor SideStick {
input event (std::notes::NoteOn) eventIn;
output stream float<2> out;
input event Params paramsIn;
input stream float noiseIn;
output stream float<2> out;

float triggerVelocity = 0.0f;
int midiNotePitch = 0;
float outputLevel = 0.5f;
float panning = 0.0f;

// Velocity sensitivity is not implemented yet
float velocitySensitivity = 1.0f;

event paramsIn(Params p) {
midiNotePitch = int(p.sideStickMidi);
outputLevel = p.sideStickLevel * 0.01f;
panning = p.sideStickPanning;
velocitySensitivity = p.sideStickVelocity;
}

event eventIn(std::notes::NoteOn n) {
Expand All @@ -29,13 +31,41 @@ namespace Percupuff
}

node envelope = Envelope;
node osc1 = Oscillator(OscillatorShape::triangle);

node osc = OscillatorBank(OscillatorShape::triangle);

// Filters that shape the white noise.
Lpf lpf = (0.0f, 0.0f);
NotchFilter notch;

void main()
{
envelope.attackIn <- .001f;
osc1.frequencyIn <- 587.0f;

envelope.releaseIn <- .25f;

osc.frequencyIn <- float<8>(
676.0f,
724.0f,
987.0f,
1030.0f,
1170.0f,
1224.0f,
1380.0f,
1436.0f
);

osc.levelIn <- float<8>(
0.8f,
0.7f,
0.6f,
0.9f,
0.9f,
0.4f,
0.3f,
0.2f
);

let invSampleRate = 1.0f / float(processor.frequency);
notch.setCoefficients(8000.0f, 0.9f, float(processor.frequency));

loop
{
while (triggerVelocity == 0) {
Expand All @@ -44,21 +74,24 @@ namespace Percupuff

let vel = triggerVelocity;
triggerVelocity = 0.0f;

envelope.releaseIn <- .2f + vel * 0.4f;
envelope.triggerIn <- void;
envelope.advance();
float gain = envelope.gainOut;

while (gain > 0.0f && triggerVelocity == 0.0f) {
osc1.frequencyModIn <- gain * 0.1f;
let outSample = osc1.out * gain * 0.5f * vel * outputLevel;
osc.frequencyModIn <- gain * 0.01f;

float lpSample = lpf.getSample(noiseIn, 4000.0f + vel * 10000.0f, invSampleRate);
float filteredLpSample = notch.getSample(lpSample);

let outSample = ((sin(osc.out * (1.0f + vel * 0.5f)) + filteredLpSample * 0.4f) * gain * (0.5f + vel * 0.5f)) * outputLevel;

float pan = panning * 0.01f;
float leftGain = 0.5f * (1.0f - pan);
float rightGain = 0.5f * (1.0f + pan);
out <- (outSample * leftGain, outSample * rightGain);

osc1.advance();
osc.advance();

gain = envelope.gainOut;
envelope.advance();
Expand All @@ -68,4 +101,4 @@ namespace Percupuff
}
}
}
}
}
1 change: 1 addition & 0 deletions view/src/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const instruments = {
snare2: { name: "Electric Snare", group: "Snares", midi: 40 },
clap1: { name: "Clap", group: "Snares", midi: 39 },


hihat1: { name: "Closed Hihat", group: "Hihats", midi: 42 },
hihat2: { name: "Pedal Hihat", group: "Hihats", midi: 44 },
hihat3: { name: "Open Hihat", group: "Hihats", midi: 46 },
Expand Down