First working version of drum sampleplayer.

pull/48/head
Holger Wirtz 3 years ago
parent 4764799bb9
commit 42291e8a94
  1. 60
      MicroDexed.ino
  2. 112
      drums.h
  3. 2075
      mixer8.cpp
  4. 1452
      mixer8.h

@ -41,6 +41,9 @@
#include "effect_freeverbf.h"
#endif
#include "UI.hpp"
#if NUM_DRUMS > 0
#include "drums.h"
#endif
// Audio engines
AudioSynthDexed* MicroDexed[NUM_DEXED];
@ -84,6 +87,7 @@ AudioMixer4 audio_thru_mixer_l;
// Drumset
#if NUM_DRUMS > 0
AudioPlaySdRaw* Drum[NUM_DRUMS];
AudioAmplifier* drum_volume[NUM_DRUMS];
AudioEffectMonoStereo* drum_mono2stereo[NUM_DRUMS];
AudioMixer4 drum_mixer_r;
AudioMixer4 drum_mixer_l;
@ -175,11 +179,11 @@ AudioConnection patchCord22(drum_mixer_l, 0, master_mixer_l, 2);
//
uint8_t nDynamic = 0;
#if defined(USE_FX) && MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT
AudioConnection* dynamicConnections[NUM_DEXED * 16 + NUM_DRUMS * 3 ];
AudioConnection* dynamicConnections[NUM_DEXED * 16 + NUM_DRUMS * 4 ];
#elif defined(USE_FX) && MOD_FILTER_OUTPUT == MOD_NO_FILTER_OUTPUT
AudioConnection* dynamicConnections[NUM_DEXED * 15 + NUM_DRUMS * 3];
AudioConnection* dynamicConnections[NUM_DEXED * 15 + NUM_DRUMS * 4];
#else
AudioConnection* dynamicConnections[NUM_DEXED * 4 + NUM_DRUMS * 3];
AudioConnection* dynamicConnections[NUM_DEXED * 4 + NUM_DRUMS * 4];
#endif
void create_audio_dexed_chain(uint8_t instance_id)
{
@ -237,9 +241,11 @@ void create_audio_dexed_chain(uint8_t instance_id)
void create_audio_drum_chain(uint8_t instance_id)
{
Drum[instance_id] = new AudioPlaySdRaw();
drum_volume[instance_id] = new AudioAmplifier();
drum_mono2stereo[instance_id] = new AudioEffectMonoStereo();
dynamicConnections[nDynamic++] = new AudioConnection(*Drum[instance_id], 0, *drum_mono2stereo[instance_id], 0);
dynamicConnections[nDynamic++] = new AudioConnection(*Drum[instance_id], 0, *drum_volume[instance_id], 0);
dynamicConnections[nDynamic++] = new AudioConnection(*drum_volume[instance_id], 0, *drum_mono2stereo[instance_id], 0);
dynamicConnections[nDynamic++] = new AudioConnection(*drum_mono2stereo[instance_id], 0, drum_mixer_r, instance_id);
dynamicConnections[nDynamic++] = new AudioConnection(*drum_mono2stereo[instance_id], 1, drum_mixer_l, instance_id);
@ -303,10 +309,11 @@ int perform_release_mod[NUM_DEXED] = { 0 };
// Allocate the delay lines for chorus
int16_t delayline[NUM_DEXED][MOD_DELAY_SAMPLE_BUFFER];
#endif
#if NUM_DRUMS > 1
static uint8_t drum_counter;
static uint8_t drum_type[NUM_DRUMS];
enum {DRUM_NONE, DRUM_BASS, DRUM_SNAREDRUM, DRUM_HIHAT, DRUM_HANDCLAP, DRUM_RIDE, DRUM_CHRASH, DRUM_LOWTOM, DRUM_MIDTOM, DRUM_HIGHTOM};
extern uint8_t drum_counter;
extern uint8_t drum_type[NUM_DRUMS];
extern drum_config_t drum_config[NUM_DRUMCONFIG];
#endif
#ifdef ENABLE_LCD_UI
@ -709,6 +716,7 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity)
Serial.print(inChannel, DEC);
Serial.println();
#endif
return;
}
}
}
@ -729,40 +737,18 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity)
Serial.println(note_name);
#endif
switch (inNumber - 48)
for (uint8_t d = 0; d < NUM_DRUMCONFIG; d++)
{
case 0:
Drum[drum_get_slot(DRUM_BASS)]->play("/DRM/BD01.RAW");
break;
case 1:
Drum[drum_get_slot(DRUM_HANDCLAP)]->play("/drm/cp02.raw");
break;
case 2:
Drum[drum_get_slot(DRUM_SNAREDRUM)]->play("/drm/sd15.raw");
break;
case 6:
Drum[drum_get_slot(DRUM_HIHAT)]->play("/drm/hh01.wav");
break;
case 8:
Drum[drum_get_slot(DRUM_HIHAT)]->play("/drm/hh02.wav");
break;
case 10:
Drum[drum_get_slot(DRUM_HIHAT)]->play("/drm/oh02.wav");
break;
case 5:
Drum[drum_get_slot(DRUM_LOWTOM)]->play("/drm/lt01.raw");
break;
case 7:
Drum[drum_get_slot(DRUM_HIGHTOM)]->play("/drm/ht01.raw");
break;
case 13:
Drum[drum_get_slot(DRUM_RIDE)]->play("/drm/rd01.raw");
break;
case 15:
Drum[drum_get_slot(DRUM_RIDE)]->play("/drm/rd02.raw");
if (inNumber == drum_config[d].midinote)
{
uint8_t slot = drum_get_slot(drum_config[d].type);
drum_volume[slot]->gain(drum_config[d].vol);
drum_mono2stereo[slot]->panorama(drum_config[d].pan);
Drum[slot]->play(drum_config[d].filename);
break;
}
}
}
#endif
}

@ -0,0 +1,112 @@
/*
Copyright (c) 2019-2021 H. Wirtz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#pragma once
#if NUM_DRUMS >1
uint8_t drum_counter;
uint8_t drum_type[NUM_DRUMS];
enum {DRUM_NONE, DRUM_BASS, DRUM_SNARE, DRUM_HIHAT, DRUM_HANDCLAP, DRUM_RIDE, DRUM_CHRASH, DRUM_LOWTOM, DRUM_MIDTOM, DRUM_HIGHTOM};
typedef struct drum_config_s {
uint8_t type; // Type of drum
uint8_t midinote; // Triggered by note
char filename[18]; // 44.1kHz mono LSB raw-sample to play
float32_t pan; // Panorama (-1.0 - +1.0)
float32_t vol; // Volume (0.0 - 1.0)
} drum_config_t;
#define NUM_DRUMCONFIG 10
drum_config_t drum_config[NUM_DRUMCONFIG] = {
{
DRUM_BASS,
MIDI_C3,
"/drm/bd01.raw",
0.0,
0.8
},
{
DRUM_HANDCLAP,
MIDI_CIS3,
"/drm/cp02.raw",
-0.4,
0.6
},
{
DRUM_SNARE,
MIDI_D3,
"/drm/sd15.raw",
0.2,
0.8
},
{
DRUM_HIHAT,
MIDI_FIS3,
"/drm/hh01.raw",
0.8,
0.8
},
{
DRUM_HIHAT,
MIDI_GIS3,
"/drm/hh02.raw",
0.8,
0.8
},
{
DRUM_HIHAT,
MIDI_AIS3,
"/drm/oh02.raw",
0.8,
0.8
},
{
DRUM_LOWTOM,
MIDI_G3,
"/drm/lt01.raw",
-0.7,
0.8
},
{
DRUM_HIGHTOM,
MIDI_A3,
"/drm/ht01.raw",
-0.5,
0.8
},
{
DRUM_RIDE,
MIDI_CIS4,
"/drm/rd01.raw",
-0.6,
0.8
},
{
DRUM_RIDE,
MIDI_DIS4,
"/drm/rd02.raw",
-0.6,
0.8
}
};
#endif

File diff suppressed because it is too large Load Diff

1452
mixer8.h

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save