Fixes for internal drum organization.

dev
Holger Wirtz 2 years ago
parent b752880735
commit 6454ceeb9a
  1. 31
      MicroDexed.ino
  2. 4
      UI.hpp
  3. 20
      addon/tools/wav2c.sh
  4. 6
      config.h
  5. 8
      dexed_sd.cpp
  6. 45
      drums.h
  7. 238743
      drumset.h

@ -46,7 +46,6 @@
#include "UI.hpp" #include "UI.hpp"
#if NUM_DRUMS > 0 #if NUM_DRUMS > 0
#include "midinotes.h" #include "midinotes.h"
#include "drums.h"
#include "drumset.h" #include "drumset.h"
#endif #endif
#ifdef SGTL5000_AUDIO_ENHANCE #ifdef SGTL5000_AUDIO_ENHANCE
@ -405,7 +404,7 @@ int16_t* ep_delayline_l;
#endif #endif
#if NUM_DRUMS > 0 #if NUM_DRUMS > 0
extern drum_config_t drum_config[NUM_DRUMSET_CONFIG]; //extern drum_config_t drum_config[NUM_DRUMSET_CONFIG];
uint8_t drum_counter; uint8_t drum_counter;
uint8_t drum_type[NUM_DRUMS]; uint8_t drum_type[NUM_DRUMS];
#endif #endif
@ -983,9 +982,9 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity) {
} }
for (uint8_t d = 0; d < NUM_DRUMSET_CONFIG; d++) { for (uint8_t d = 0; d < NUM_DRUMSET_CONFIG; d++) {
if (inNumber == drum_config[d].midinote) { if (inNumber == configuration.drums.midinote[d]) {
uint8_t slot = drum_get_slot(drum_config[d].drum_class); uint8_t slot = drum_get_slot(drum_config[d].drum_class);
float pan = mapfloat(drum_config[d].pan, -1.0, 1.0, 0.0, 1.0); float pan = mapfloat(configuration.drums.pan[d], -127.0, 127.0, 0.0, 1.0);
drum_mixer_r.gain(slot, (1.0 - pan) * volume_transform(mapfloat(inVelocity, 0, 127, drum_config[d].vol_min, drum_config[d].vol_max))); drum_mixer_r.gain(slot, (1.0 - pan) * volume_transform(mapfloat(inVelocity, 0, 127, drum_config[d].vol_min, drum_config[d].vol_max)));
drum_mixer_l.gain(slot, pan * volume_transform(mapfloat(inVelocity, 0, 127, drum_config[d].vol_min, drum_config[d].vol_max))); drum_mixer_l.gain(slot, pan * volume_transform(mapfloat(inVelocity, 0, 127, drum_config[d].vol_min, drum_config[d].vol_max)));
@ -994,9 +993,9 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity) {
drum_reverb_send_mixer_l.gain(slot, pan * volume_transform(drum_config[d].reverb_send)); drum_reverb_send_mixer_l.gain(slot, pan * volume_transform(drum_config[d].reverb_send));
#endif #endif
if (drum_config[d].drum_data != NULL && drum_config[d].len > 0) { if (drum_config[d].drum_data != NULL && drum_config[d].len > 0) {
if (drum_config[d].pitch != 0.0) { if (configuration.drums.pitch[d] != 0) {
Drum[slot]->enableInterpolation(true); Drum[slot]->enableInterpolation(true);
Drum[slot]->setPlaybackRate(drum_config[d].pitch); Drum[slot]->setPlaybackRate(configuration.drum.pitch[d] / 10.0f);
} }
Drum[slot]->playRaw((int16_t*)drum_config[d].drum_data, drum_config[d].len, 1); Drum[slot]->playRaw((int16_t*)drum_config[d].drum_data, drum_config[d].len, 1);
#ifdef DEBUG #ifdef DEBUG
@ -1005,14 +1004,10 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity) {
} }
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("Drum ")); Serial.print(F("Drum Slot ["));
Serial.print(drum_config[d].shortname);
Serial.print(F(" ["));
Serial.print(drum_config[d].name);
Serial.print(F("], Slot ["));
Serial.print(slot); Serial.print(slot);
Serial.print(F("]: Velocity=")); Serial.print(F("]: Velocity="));
Serial.print(mapfloat(inVelocity, 0, 127, drum_config[d].vol_min, drum_config[d].vol_max), 2); Serial.print(mapfloat(inVelocity, 0, 127, configuration.drums.vol_min[d], configuration.drums.vol_max[d]), 2);
Serial.print(F(" Pan=")); Serial.print(F(" Pan="));
Serial.print(pan, 2); Serial.print(pan, 2);
Serial.print(F(" ReverbSend=")); Serial.print(F(" ReverbSend="));
@ -1973,12 +1968,12 @@ void check_configuration_drums(void) {
configuration.drums.midi_channel = constrain(configuration.drums.midi_channel, DRUMS_MIDI_CHANNEL_MIN, DRUMS_MIDI_CHANNEL_MAX); configuration.drums.midi_channel = constrain(configuration.drums.midi_channel, DRUMS_MIDI_CHANNEL_MIN, DRUMS_MIDI_CHANNEL_MAX);
for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG - 1; i++) { for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG - 1; i++) {
drum_config[i].midinote = constrain(drum_config[i].midinote, DRUMS_MIDI_NOTE_MIN, DRUMS_MIDI_NOTE_MAX); configuration.drums.midinote[i] = constrain(drum_config[i].midinote, DRUMS_MIDI_NOTE_MIN, DRUMS_MIDI_NOTE_MAX);
drum_config[i].pitch = constrain(drum_config[i].pitch, DRUMS_PITCH_MIN, DRUMS_PITCH_MAX); configuration.drums.pitch[i] = mapfloat(drum_config[i].pitch, -12.0, 12.0, DRUMS_PITCH_MIN, DRUMS_PITCH_MAX);
drum_config[i].pan = constrain(drum_config[i].pan, DRUMS_PANORAMA_MIN, DRUMS_PANORAMA_MAX); configuration.drums.pan[i] = mapfloat(drum_config[i].pan, 0.0, 1.0, DRUMS_PANORAMA_MIN, DRUMS_PANORAMA_MAX);
drum_config[i].vol_max = constrain(drum_config[i].vol_max, DRUMS_VOL_MIN, DRUMS_VOL_MAX); configuration.drums.vol_max[i] = mapfloat(drum_config[i].vol_max, 0.0, 1.0, DRUMS_VOL_MIN, DRUMS_VOL_MAX);
drum_config[i].vol_min = constrain(drum_config[i].vol_min, DRUMS_VOL_MIN, DRUMS_VOL_MAX); configuration.drums.vol_min[i] = mapfloat(drum_config[i].vol_min, 0.0, 1.0, DRUMS_VOL_MIN, DRUMS_VOL_MAX);
drum_config[i].reverb_send = constrain(drum_config[i].reverb_send, DRUMS_REVERB_SEND_MIN, DRUMS_REVERB_SEND_MAX); configuration.drums.reverb_send[i] = mapfloat(drum_config[i].reverb_send, 0.0, 1.0, DRUMS_REVERB_SEND_MIN, DRUMS_REVERB_SEND_MAX);
} }
} }

@ -71,11 +71,11 @@ extern void eeprom_update(void);
#if NUM_DRUMS > 0 #if NUM_DRUMS > 0
#include "midinotes.h" #include "midinotes.h"
#include "drums.h" #include "drumset.h"
extern void get_sd_performance_name_json(uint8_t number); extern void get_sd_performance_name_json(uint8_t number);
extern bool save_sd_performance_json(uint8_t p); extern bool save_sd_performance_json(uint8_t p);
extern uint8_t drum_midi_channel; extern uint8_t drum_midi_channel;
extern drum_config_t drum_config[NUM_DRUMSET_CONFIG]; //extern drum_config_t drum_config[NUM_DRUMSET_CONFIG];
uint8_t activesample = 0; uint8_t activesample = 0;
#endif #endif

@ -90,12 +90,28 @@ mkdir -p "${TMP}"
cat >> "${DRUMSET_H}" << EOF cat >> "${DRUMSET_H}" << EOF
#pragma once #pragma once
#include "drums.h" #include <Arduino.h>
typedef struct drum_config_s {
uint8_t drum_class; // Type of drum
uint8_t midinote; // Triggered by note
char name[DRUM_NAME_LEN];
const uint8_t* drum_data;
char shortname[2]; // 1 char name for sequencer
uint32_t len; // number of elements in drum_data
float32_t pitch; // variable pitch per note for sequencer
float32_t pan; // Panorama (-1.0 - +1.0)
float32_t vol_max; // max. Volume (0.0 - 1.0)
float32_t vol_min; // min. Volume (0.0 - 1.0, should be <= vol_max)
float32_t reverb_send; // how much signal to send to the reverb (0.0 - 1.0)
} drum_config_t;
enum {DRUM_NONE, DRUM_BASS, DRUM_SNARE, DRUM_HIHAT, DRUM_HANDCLAP, DRUM_RIDE, DRUM_CRASH, DRUM_LOWTOM, DRUM_MIDTOM, DRUM_HIGHTOM, DRUM_PERCUSSION, DRUM_POLY};
EOF EOF
rm -f "${DRUMS_H}" rm -f "${DRUMS_H}"
cat >> "${DRUMS_H}" << EOF cat >> "${DRUMS_H}" << EOF
drum_config_t drum_config[NUM_DRUMSET_CONFIG] = PROGMEM const drum_config_t drum_config[NUM_DRUMSET_CONFIG] =
{ {
EOF EOF

@ -923,6 +923,12 @@ typedef struct performance_s {
typedef struct drums_s { typedef struct drums_s {
uint8_t main_vol; uint8_t main_vol;
uint8_t midi_channel; uint8_t midi_channel;
uint8_t midinote[NUM_DRUMSET_CONFIG];
int8_t pitch[NUM_DRUMSET_CONFIG];
uint8_t pan[NUM_DRUMSET_CONFIG];
uint8_t vol_max[NUM_DRUMSET_CONFIG];
uint8_t vol_min[NUM_DRUMSET_CONFIG];
uint8_t reverb_send[NUM_DRUMSET_CONFIG];
} drum_t; } drum_t;
typedef struct configuration_s { typedef struct configuration_s {

@ -32,9 +32,9 @@
#include "dexed_sd.h" #include "dexed_sd.h"
#include "synth_dexed.h" #include "synth_dexed.h"
#if NUM_DRUMS > 0 #if NUM_DRUMS > 0
#include "drums.h" #include "drumset.h"
extern void set_drums_volume(float vol); extern void set_drums_volume(float vol);
extern drum_config_t drum_config[]; //extern drum_config_t drum_config[];
#endif #endif
extern void init_MIDI_send_CC(void); extern void init_MIDI_send_CC(void);
@ -433,12 +433,12 @@ bool load_sd_drumsettings_json(uint8_t number) {
configuration.drums.midi_channel = data_json["midi_channel"]; configuration.drums.midi_channel = data_json["midi_channel"];
for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG - 1; i++) { for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG - 1; i++) {
drum_config[i].midinote = data_json["note"][i]; /* drum_config[i].midinote = data_json["note"][i];
drum_config[i].pitch = data_json["pitch"][i]; drum_config[i].pitch = data_json["pitch"][i];
drum_config[i].pan = data_json["pan"][i]; drum_config[i].pan = data_json["pan"][i];
drum_config[i].vol_max = data_json["vol_max"][i]; drum_config[i].vol_max = data_json["vol_max"][i];
drum_config[i].vol_min = data_json["vol_min"][i]; drum_config[i].vol_min = data_json["vol_min"][i];
drum_config[i].reverb_send = data_json["reverb_send"][i]; drum_config[i].reverb_send = data_json["reverb_send"][i]; */
} }
check_configuration_drums(); check_configuration_drums();
return (true); return (true);

@ -1,45 +0,0 @@
/*
MicroDexed
MicroDexed is a port of the Dexed sound engine
Dexed ist heavily based on https://github.com/google/music-synthesizer-for-android
(c)2018-2022 H. Wirtz <wirtz@parasitstudio.de>
(c)2021-2022 H. Wirtz <wirtz@parasitstudio.de>, M. Koslowski <positionhigh@gmx.de>
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
THE SOFTWARE.
*/
#pragma once
#include <Arduino.h>
typedef struct drum_config_s {
uint8_t drum_class; // Type of drum
uint8_t midinote; // Triggered by note
char name[DRUM_NAME_LEN];
const uint8_t* drum_data;
char shortname[2]; // 1 char name for sequencer
uint32_t len; // number of elements in drum_data
float32_t pitch; // variable pitch per note for sequencer
float32_t pan; // Panorama (-1.0 - +1.0)
float32_t vol_max; // max. Volume (0.0 - 1.0)
float32_t vol_min; // min. Volume (0.0 - 1.0, should be <= vol_max)
float32_t reverb_send; // how much signal to send to the reverb (0.0 - 1.0)
} drum_config_t;
enum {DRUM_NONE, DRUM_BASS, DRUM_SNARE, DRUM_HIHAT, DRUM_HANDCLAP, DRUM_RIDE, DRUM_CRASH, DRUM_LOWTOM, DRUM_MIDTOM, DRUM_HIGHTOM, DRUM_PERCUSSION, DRUM_POLY};

238743
drumset.h

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