Smaller additions.

Fixes.
pull/4/head
Holger Wirtz 7 years ago
parent 5078331a8c
commit ffe25453d5
  1. 74
      MicroDexed.ino
  2. 17
      dexed.cpp
  3. 12
      dexed.h

@ -12,7 +12,12 @@
#include <MIDI.h>
#include "dexed.h"
#define DEBUG 1
//#define TEST_MIDI 1
#define TEST_NOTE 40
#define TEST_VEL_MIN 60
#define TEST_VEL_MAX 110
//#define DEBUG 1
#define SERIAL_SPEED 38400
#define VOLUME 0.5
#define SAMPLE_RATE 44100
@ -21,10 +26,6 @@
#define SHOW_XRUN 1
#define SHOW_CPU_LOAD_MSEC 5000
#define MAX_NOTES 10
//#define TEST_MIDI 1
#define TEST_NOTE 40
#define TEST_VEL_MIN 60
#define TEST_VEL_MAX 110
//#define ADD_EFFECT_CHORUS 1
#ifdef ADD_EFFECT_CHORUS
#define AUDIO_MEM 6
@ -88,10 +89,6 @@ void setup()
{
sd_card_available = true;
}
load_sysex_file("ROM1A.SYX");
#ifdef DEBUG
show_patch();
#endif
MIDI.begin(MIDI_CHANNEL_OMNI);
@ -121,6 +118,10 @@ void setup()
}
#endif
load_sysex("ROM1A.SYX", 5);
#ifdef DEBUG
show_patch();
#endif
dexed->activate();
dexed->setMaxNotes(MAX_NOTES);
@ -128,6 +129,19 @@ void setup()
chorus1.begin(delayline, CHORUS_DELAY_LENGTH, 8);
#endif
#ifdef SHOW_CPU_LOAD_MSEC
sched.begin(cpu_and_mem_usage, SHOW_CPU_LOAD_MSEC * 1000);
#endif
Serial.print(F("AUDIO_BLOCK_SAMPLES="));
Serial.println(AUDIO_BLOCK_SAMPLES);
Serial.println(F("setup end"));
cpu_and_mem_usage();
//dexed->setEngineType(DEXED_ENGINE_MODERN);
//dexed->setEngineType(DEXED_ENGINE_MARKI);
//dexed->setEngineType(DEXED_ENGINE_OPL);
#ifdef TEST_MIDI
delay(200);
randomSeed(analogRead(A0));
@ -150,13 +164,6 @@ void setup()
delay(200);
#endif
#ifdef SHOW_CPU_LOAD_MSEC
sched.begin(cpu_and_mem_usage, SHOW_CPU_LOAD_MSEC * 1000);
#endif
Serial.print(F("AUDIO_BLOCK_SAMPLES="));
Serial.println(AUDIO_BLOCK_SAMPLES);
Serial.println(F("setup end"));
cpu_and_mem_usage();
}
void loop()
@ -220,7 +227,7 @@ void cpu_and_mem_usage(void)
}
#endif
void load_sysex_file(char *name)
void load_sysex(char *name, uint8_t voice_number)
{
File root;
@ -240,7 +247,7 @@ void load_sysex_file(char *name)
{
Serial.println(entry.name());
check_sysex(entry);
load_sysex(entry, 5);
load_sysex_voice(entry, voice_number);
entry.close();
break;
}
@ -342,12 +349,18 @@ void show_patch(void)
Serial.print(F("["));
Serial.print(voicename);
Serial.println(F("]"));
for (i = 155; i < 173; i++)
{
Serial.print(i, DEC);
Serial.print(F(": "));
Serial.println(dexed->data[i]);
}
Serial.println();
}
#endif
bool load_sysex(File sysex, uint8_t voice_number)
bool load_sysex_voice(File sysex, uint8_t voice_number)
{
File file;
@ -357,13 +370,15 @@ bool load_sysex(File sysex, uint8_t voice_number)
uint8_t i;
uint8_t tmp;
dexed->notes_off();
file.seek(6 + (voice_number * 128));
for (i = 0; i < 6; i++)
{
file.read(p_data + (i * 21), 11); // R1, R2, R3, R4, L1, L2, L3, L4, LEV SCL BRK PT, SCL LEFT DEPTH, SCL RGHT DEPTH
tmp = file.read();
*(p_data + 11 + (i * 21)) = (tmp & 0x0c) >> 2;
*(p_data + 12 + (i * 21)) = (tmp & 0x3);
*(p_data + 11 + (i * 21)) = (tmp & 0x3);
*(p_data + 12 + (i * 21)) = (tmp & 0x0c) >> 2;
tmp = file.read();
*(p_data + 13 + (i * 21)) = (tmp & 0x78) >> 3;
*(p_data + 14 + (i * 21)) = (tmp & 0x07);
@ -396,11 +411,24 @@ bool load_sysex(File sysex, uint8_t voice_number)
*(p_data + 170) = 1;
*(p_data + 171) = 1;
*(p_data + 172) = MAX_NOTES;
}
dexed->activate();
dexed->setOPs((*(p_data + 166) << 5) | (*(p_data + 167) << 4) | (*(p_data + 168) << 3) | (*(p_data + 166) << 2) | (*(p_data + 170) << 1) | *(p_data + 171));
dexed->setMaxNotes(dexed->data[172]);
dexed->panic();
dexed->doRefreshVoice();
char voicename[11];
memset(voicename, 0, sizeof(voicename));
strncpy(voicename, (char *)&dexed->data[144], sizeof(voicename) - 1);
Serial.print(F("["));
Serial.print(voicename);
Serial.println(F("]"));
return (true);
}
else
return (false);
}
bool check_sysex(File sysex)
{

@ -1,6 +1,6 @@
/**
Copyright (c) 2016-2017 Holger Wirtz <dcoredump@googlemail.com>
Copyright (c) 2016-2018 Holger Wirtz <dcoredump@googlemail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -90,11 +90,7 @@ Dexed::Dexed(int rate)
sustain = false;
memset(&voiceStatus, 0, sizeof(VoiceStatus));
setEngineType(DEXED_ENGINE_MODERN);
//setEngineType(DEXED_ENGINE_MARKI);
//setEngineType(DEXED_ENGINE_OPL);
}
Dexed::~Dexed()
@ -119,7 +115,7 @@ void Dexed::activate(void)
void Dexed::deactivate(void)
{
; // nothing to do...
panic();
}
void Dexed::GetSamples(uint16_t n_samples, int16_t* buffer)
@ -354,6 +350,15 @@ void Dexed::keyup(uint8_t pitch) {
TRACE("Bye");
}
void Dexed::doRefreshVoice(void)
{
refreshVoice = true;
}
void Dexed::setOPs(uint8_t ops)
{
controllers.opSwitch = ops;
}
/*
void Dexed::onParam(uint8_t param_num, float param_val)
{

@ -31,8 +31,6 @@
#include "EngineMkI.h"
#include "EngineOpl.h"
#define PARAM_CHANGE_LEVEL 10 // when a sound change is recognized
struct ProcessorVoice {
uint8_t midi_note;
uint8_t velocity;
@ -69,8 +67,10 @@ class Dexed
void panic(void);
void notes_off(void);
void setMaxNotes(uint8_t n);
void doRefreshVoice(void);
void setOPs(uint8_t ops);
Controllers controllers;
VoiceStatus voiceStatus;
uint8_t data[173] = {
95, 29, 20, 50, 99, 95, 00, 00, 41, 00, 19, 00, 00, 03, 00, 06, 79, 00, 01, 00, 14, // OP6 eg_rate_1-4, level_1-4, kbd_lev_scl_brk_pt, kbd_lev_scl_lft_depth, kbd_lev_scl_rht_depth, kbd_lev_scl_lft_curve, kbd_lev_scl_rht_curve, kbd_rate_scaling, amp_mod_sensitivity, key_vel_sensitivity, operator_output_level, osc_mode, osc_freq_coarse, osc_freq_fine, osc_detune
@ -107,12 +107,6 @@ class Dexed
FmCore* engineMsfa;
EngineMkI* engineMkI;
EngineOpl* engineOpl;
private:
uint8_t _k_rate_counter;
uint8_t _param_change_counter;
};
#endif // PLUGINPROCESSOR_H_INCLUDED

Loading…
Cancel
Save