Commit before merge.

pull/58/head
Holger Wirtz 3 years ago
parent c2ce0c270d
commit 3197d138ad
  1. 38
      MicroDexed.ino
  2. 7
      UI.hpp
  3. 0
      addon/SD/drm/CFGDrums.json
  4. 2
      config.h
  5. 12
      dexed_sd.cpp
  6. 63
      drums.cpp
  7. 18
      drums.h
  8. 2
      sequencer.cpp

@ -245,8 +245,6 @@ void create_audio_dexed_chain(uint8_t instance_id)
#ifdef DEBUG
Serial.print(F("Dexed-Instance: "));
Serial.println(instance_id);
Serial.print(F("Dynamic-Connection-Counter="));
Serial.println(nDynamic);
#endif
}
@ -274,6 +272,7 @@ void create_audio_drum_chain(uint8_t instance_id)
}
#endif
StaticJsonDocument<JSON_BUFFER> data_json;
uint8_t sd_card = 0;
Sd2Card card;
SdVolume volume;
@ -325,10 +324,7 @@ int perform_release_mod[NUM_DEXED] = { 0 };
int16_t delayline[NUM_DEXED][MOD_DELAY_SAMPLE_BUFFER];
#endif
#if NUM_DRUMS > 1
extern uint8_t drum_counter;
extern uint8_t drum_type[NUM_DRUMS];
extern drum_config_t drum_config[NUM_DRUMCONFIG];
#if NUM_DRUMS > 0
extern void sequencer(void);
#endif
@ -472,32 +468,6 @@ void setup()
#endif
create_audio_drum_chain(instance_id);
File json;
// first check if file exists...
AudioNoInterrupts();
if (SD.exists("/DRM/CFG_MDDrums.json"))
{
// ... and if: load
#ifdef DEBUG
Serial.println(F("Found drum configuration file."));
#endif
json = SD.open("/DRM/CFG_MDDrums.json");
if (json)
{
StaticJsonDocument<JSON_BUFFER> data_json;
JsonObject object = data_json.to<JsonObject>();
deserializeJson(data_json, json);
deserializeJson(data_json, Serial);
json.close();
Serial.print(F("objects: "));
Serial.println(object["drums"].size());
}
}
AudioInterrupts();
drum_mixer_r.gain(instance_id, 1.0);
drum_mixer_l.gain(instance_id, 1.0);
drum_reverb_send_mixer_r.gain(instance_id, 0.0);
@ -542,6 +512,8 @@ void setup()
}
else
{
read_drum_config();
check_and_create_directories();
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
@ -788,7 +760,7 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity)
{
if (inNumber == drum_config[d].midinote)
{
uint8_t slot = drum_get_slot(drum_config[d].type);
uint8_t slot = drum_get_slot(drum_config[d].drum_class);
float fsin = mapfloat(arm_sin_f32(drum_config[d].pan * PI / 2.0), -1.0, 1.0, 0.0, 1.0);
drum_mixer_r.gain(slot, (1.0 - fsin) * pseudo_log_curve(mapfloat(inVelocity, 0, 127, drum_config[d].vol_min, drum_config[d].vol_max)));

@ -37,6 +37,9 @@
#include "effect_freeverbf.h"
#endif
#include "synth_dexed.h"
#if NUM_DRUMS > 0
#include "drums.h"
#endif
#include <LCDMenuLib2.h>
#include <MD_REncoder.h>
@ -78,9 +81,6 @@ extern bool seq_button_r;
extern uint8_t seq_chain_select_menu;
extern uint8_t seq_chain_active_menu;
extern uint8_t seq_chain_active_chainstep;
#if NUM_DRUMS > 0
#include "drums.h"
#endif
#ifdef DISPLAY_LCD_SPI
extern void change_disp_sd(bool d);
@ -123,7 +123,6 @@ extern int perform_release_mod[NUM_DEXED];
extern float midi_ticks_factor[10];
extern uint8_t midi_bpm;
/***********************************************************************
GLOBAL
************************************************************************/

@ -611,7 +611,7 @@
#define EQ_TREBLE_DEFAULT 0
// Buffer for load/save configuration as JSON
#define JSON_BUFFER 1024
#define JSON_BUFFER 3072
// Internal configuration structure
typedef struct dexed_s {

@ -35,6 +35,7 @@ extern void init_MIDI_send_CC(void);
extern void check_configuration_dexed(uint8_t instance_id);
extern void check_configuration_performance(void);
extern void check_configuration_fx(void);
extern StaticJsonDocument<JSON_BUFFER> data_json;
/******************************************************************************
SD BANK/VOICE LOADING
@ -424,8 +425,6 @@ bool load_sd_voiceconfig_json(int8_t vc, uint8_t instance_id)
json = SD.open(filename);
if (json)
{
StaticJsonDocument<JSON_BUFFER> data_json;
deserializeJson(data_json, json);
json.close();
@ -519,8 +518,6 @@ bool save_sd_voiceconfig_json(uint8_t vc, uint8_t instance_id)
json = SD.open(filename, FILE_WRITE);
if (json)
{
StaticJsonDocument<JSON_BUFFER> data_json;
data_json["lowest_note"] = configuration.dexed[instance_id].lowest_note;
data_json["highest_note"] = configuration.dexed[instance_id].highest_note;
data_json["transpose"] = configuration.dexed[instance_id].transpose;
@ -608,8 +605,6 @@ bool load_sd_fx_json(int8_t fx)
json = SD.open(filename);
if (json)
{
StaticJsonDocument<JSON_BUFFER> data_json;
deserializeJson(data_json, json);
json.close();
@ -694,8 +689,6 @@ bool save_sd_fx_json(uint8_t fx)
json = SD.open(filename, FILE_WRITE);
if (json)
{
StaticJsonDocument<JSON_BUFFER> data_json;
for (uint8_t i = 0; i < MAX_DEXED; i++)
{
data_json["filter_cutoff"][i] = configuration.fx.filter_cutoff[i];
@ -775,7 +768,6 @@ bool load_sd_performance_json(int8_t p)
json = SD.open(filename);
if (json)
{
StaticJsonDocument<JSON_BUFFER> data_json;
deserializeJson(data_json, json);
json.close();
AudioInterrupts();
@ -876,8 +868,6 @@ bool save_sd_performance_json(uint8_t p)
json = SD.open(filename, FILE_WRITE);
if (json)
{
StaticJsonDocument<JSON_BUFFER> data_json;
for (uint8_t i = 0; i < MAX_DEXED; i++)
{
data_json["bank"][i] = configuration.performance.bank[i];

@ -0,0 +1,63 @@
/*
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-2021 H. Wirtz <wirtz@parasitstudio.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
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.
*/
#include <Arduino.h>
#include <ArduinoJson.h>
#include <Audio.h>
#include "config.h"
void read_drum_config(void)
{
File json;
AudioNoInterrupts();
if (SD.exists("/DRM/CFGDrums.json"))
{
#ifdef DEBUG
Serial.println(F("Found drum configuration file."));
#endif
json = SD.open("/DRM/CFGDrums.json");
if (json)
{
DynamicJsonDocument drums_json(5000);
deserializeJson(drums_json, json);
#ifdef DEBUG
Serial.println("Drums:");
serializeJsonPretty(drums_json, Serial);
Serial.println();
Serial.print(F("Drum Objects: "));
Serial.println(drums_json["drums"].size());
#endif
json.close();
while (1);
}
}
AudioInterrupts();
}

@ -25,18 +25,18 @@
THE SOFTWARE.
*/
#pragma once
#include <Arduino.h>
#include "config.h"
#if NUM_DRUMS >1
uint8_t drum_counter;
uint8_t drum_type[NUM_DRUMS];
#ifndef _DRUMS_H
#define _DRUMS_H
enum {DRUM_NONE, DRUM_BASS, DRUM_SNARE, DRUM_HIHAT, DRUM_HANDCLAP, DRUM_RIDE, DRUM_CHRASH, DRUM_LOWTOM, DRUM_MIDTOM, DRUM_HIGHTOM, DRUM_PERCUSSION};
void read_drum_config(void);
typedef struct drum_config_s {
uint8_t type; // Type of drum
uint8_t drum_class; // Type of drum
uint8_t midinote; // Triggered by note
char filename[18]; // 44.1kHz mono LSB raw-sample to play
char filename[18]; // 44.1kHz mono LSB wav-sample
char shortname[2]; // 1 char name for sequencer
float32_t pan; // Panorama (-1.0 - +1.0)
float32_t vol_max; // max. Volume (0.0 - 1.0)
@ -44,6 +44,10 @@ typedef struct drum_config_s {
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_CHRASH, DRUM_LOWTOM, DRUM_MIDTOM, DRUM_HIGHTOM, DRUM_PERCUSSION};
uint8_t drum_counter;
uint8_t drum_type[NUM_DRUMS];
#define NUM_DRUMCONFIG 15
drum_config_t drum_config[NUM_DRUMCONFIG] = {
{

@ -12,7 +12,7 @@ extern void handleNoteOff(byte , byte , byte );
extern void UI_func_sequencer(uint8_t);
extern const char* seq_find_shortname(uint8_t);
void sequencer()
void sequencer(void)
{
bool seq_noteoffsent = false;

Loading…
Cancel
Save