pull/44/head
Holger Wirtz 3 years ago
parent b009c0cecb
commit 33e33e9a9a
  1. 39
      MicroDexed.ino
  2. 2
      UI.hpp
  3. 11
      config.h
  4. 4
      dexed_sd.h
  5. 4
      synth_dexed.cpp
  6. 53
      synth_dexed.h

@ -29,6 +29,7 @@
#include <EEPROM.h>
#include <SD.h>
#include <SPI.h>
#include "OpenAudio_ArduinoLibrary.h"
#include "midi_devices.hpp"
#include "synth_dexed.h"
#include "dexed_sd.h"
@ -43,7 +44,8 @@
#include "UI.hpp"
// Audio engines
AudioSynthDexed* MicroDexed[NUM_DEXED];
AudioSynthDexed_F32* MicroDexed[NUM_DEXED];
AudioConvert_F32toI16* convertf32toi16[NUM_DEXED];
#if defined(USE_FX)
AudioSynthWaveform* chorus_modulator[NUM_DEXED];
#if MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT
@ -165,15 +167,19 @@ AudioConnection patchCord24(audio_thru_mixer_l, 0, i2s1, 1);
//
uint16_t nDynamic = 0;
#if defined(USE_FX) && MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT
AudioConnection * dynamicConnections[NUM_DEXED * 16];
//AudioConnection * dynamicConnections[NUM_DEXED * 16];
AudioConnection * dynamicConnections[NUM_DEXED * 17];
#elif defined(USE_FX) && MOD_FILTER_OUTPUT == MOD_NO_FILTER_OUTPUT
AudioConnection * dynamicConnections[NUM_DEXED * 15];
//AudioConnection * dynamicConnections[NUM_DEXED * 15];
AudioConnection * dynamicConnections[NUM_DEXED * 16];
#else
AudioConnection * dynamicConnections[NUM_DEXED * 4];
//AudioConnection * dynamicConnections[NUM_DEXED * 4];
AudioConnection * dynamicConnections[NUM_DEXED * 5];
#endif
void create_audio_engine_chain(uint8_t instance_id)
{
MicroDexed[instance_id] = new AudioSynthDexed(SAMPLE_RATE);
MicroDexed[instance_id] = new AudioSynthDexed_F32(SAMPLE_RATE);
convertf32toi16[instance_id] = new AudioConvert_F32toI16();
mono2stereo[instance_id] = new AudioEffectMonoStereo();
#if defined(USE_FX)
chorus_modulator[instance_id] = new AudioSynthWaveform();
@ -187,10 +193,15 @@ void create_audio_engine_chain(uint8_t instance_id)
delay_mixer[instance_id] = new AudioMixer4();
#endif
dynamicConnections[nDynamic++] = new AudioConnection(*MicroDexed[instance_id], 0, microdexed_peak_mixer, instance_id);
//dynamicConnections[nDynamic++] = new AudioConnection(*MicroDexed[instance_id], 0, microdexed_peak_mixer, instance_id);
dynamicConnections[nDynamic++] = new AudioConnection(*MicroDexed[instance_id], 0, *convertf32toi16[instance_id], 0);
dynamicConnections[nDynamic++] = new AudioConnection(*convertf32toi16[instance_id], 0, microdexed_peak_mixer, instance_id);
#if defined(USE_FX)
dynamicConnections[nDynamic++] = new AudioConnection(*MicroDexed[instance_id], 0, *chorus_mixer[instance_id], 0);
dynamicConnections[nDynamic++] = new AudioConnection(*MicroDexed[instance_id], 0, *modchorus[instance_id], 0);
//dynamicConnections[nDynamic++] = new AudioConnection(*MicroDexed[instance_id], 0, *chorus_mixer[instance_id], 0);
//dynamicConnections[nDynamic++] = new AudioConnection(*MicroDexed[instance_id], 0, *modchorus[instance_id], 0);
dynamicConnections[nDynamic++] = new AudioConnection(*convertf32toi16[instance_id], 0, *chorus_mixer[instance_id], 0);
dynamicConnections[nDynamic++] = new AudioConnection(*convertf32toi16[instance_id], 0, *modchorus[instance_id], 0);
#if MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT
dynamicConnections[nDynamic++] = new AudioConnection(*chorus_modulator[instance_id], 0, *modchorus_filter[instance_id], 0);
dynamicConnections[nDynamic++] = new AudioConnection(*modchorus_filter[instance_id], 0, *modchorus[instance_id], 1);
@ -207,7 +218,8 @@ void create_audio_engine_chain(uint8_t instance_id)
dynamicConnections[nDynamic++] = new AudioConnection(*mono2stereo[instance_id], 0, reverb_mixer_r, instance_id);
dynamicConnections[nDynamic++] = new AudioConnection(*mono2stereo[instance_id], 1, reverb_mixer_l, instance_id);
#else
dynamicConnections[nDynamic++] = new AudioConnection(*MicroDexed[instance_id], 0, *mono2stereo[instance_id], 0);
//dynamicConnections[nDynamic++] = new AudioConnection(*MicroDexed[instance_id], 0, *mono2stereo[instance_id], 0);
dynamicConnections[nDynamic++] = new AudioConnection(*convertf32toi16[instance_id], 0, *mono2stereo[instance_id], 0);
#endif
dynamicConnections[nDynamic++] = new AudioConnection(*mono2stereo[instance_id], 0, master_mixer_r, instance_id);
dynamicConnections[nDynamic++] = new AudioConnection(*mono2stereo[instance_id], 1, master_mixer_l, instance_id);
@ -274,6 +286,7 @@ void setup()
// Start audio system
//AudioNoInterrupts();
AudioMemory(AUDIO_MEM);
AudioMemory_F32(AUDIO_MEM_F32);
#ifdef DISPLAY_LCD_SPI
pinMode(SDCARD_CS_PIN, OUTPUT);
@ -454,6 +467,7 @@ void setup()
// Initialize processor and memory measurements
AudioProcessorUsageMaxReset();
AudioMemoryUsageMaxReset();
AudioMemoryUsageMaxReset_F32();
#ifdef DEBUG
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
@ -2227,6 +2241,12 @@ void show_cpu_and_mem_usage(void)
Serial.print(AudioProcessorUsageMax(), 2);
Serial.print(F("%|CPUMAXCNT:"));
Serial.print(cpumax, DEC);
Serial.print(F("|MEM_F32:"));
Serial.print(AudioMemoryUsage_F32(), DEC);
Serial.print(F("|MEMMAX_F32:"));
Serial.print(AudioMemoryUsageMax_F32(), DEC);
Serial.print(F("|AUDIO_MEM_MAX_F32:"));
Serial.print(AUDIO_MEM_F32, DEC);
Serial.print(F("|MEM:"));
Serial.print(AudioMemoryUsage(), DEC);
Serial.print(F("|MEMMAX:"));
@ -2263,6 +2283,7 @@ void show_cpu_and_mem_usage(void)
#endif
AudioProcessorUsageMaxReset();
AudioMemoryUsageMaxReset();
AudioMemoryUsageMaxReset_F32();
}
#endif

@ -70,7 +70,7 @@ extern void change_disp_sd(bool d);
#endif
extern AudioControlSGTL5000 sgtl5000_1;
extern AudioSynthDexed* MicroDexed[NUM_DEXED];
extern AudioSynthDexed_F32* MicroDexed[NUM_DEXED];
#if defined(USE_FX)
extern AudioSynthWaveform* chorus_modulator[NUM_DEXED];
extern AudioEffectModulatedDelay* modchorus[NUM_DEXED];

@ -128,11 +128,12 @@
//* AUDIO SOFTWARE SETTINGS
//*************************************************************************************************
#define SAMPLE_RATE 44100
#if AUDIO_BLOCK_SAMPLES == 64
#define AUDIO_MEM 256
#else
#define AUDIO_MEM 128
#endif
//#if AUDIO_BLOCK_SAMPLES == 64
//#define AUDIO_MEM 256
//#else
#define AUDIO_MEM 300
#define AUDIO_MEM_F32 10
//#endif
#ifdef TEENSY_AUDIO_BOARD
/*

@ -24,13 +24,13 @@
*/
#include "config.h"
#include "synth_dexed.h"
#ifndef DEXED_SYSEX_H_INCLUDED
#define DEXED_SYSEX_H_INCLUDED
extern uint8_t sd_card;
extern Dexed* dexed;
extern AudioSynthDexed * MicroDexed[NUM_DEXED];
extern AudioSynthDexed_F32* MicroDexed[NUM_DEXED];
extern void show_patch(uint8_t instance_id);
extern void send_sysex_voice(uint8_t midi_channel, uint8_t* data);

@ -409,7 +409,7 @@ void Dexed::getSamples(uint16_t n_samples, float32_t* buffer)
{
for (i = 0; i < max_notes; i++)
{
if ( voices[i].live )
if (voices[i].live)
voices[i].dx7_note->update(data, voices[i].midi_note, voices[i].velocity, voices[i].porta, &controllers);
}
lfo.reset(data + 137);
@ -437,7 +437,7 @@ void Dexed::getSamples(uint16_t n_samples, float32_t* buffer)
for (j = 0; j < _N_; ++j)
{
buffer[i + j] += static_cast<float>(audiobuf.get()[j]) / 32768;
buffer[i + j] += static_cast<float>(audiobuf.get()[j]) / 32768.0f;
audiobuf.get()[j] = 0;
}
}

@ -1,9 +1,7 @@
#include <Arduino.h>
#include <Audio.h>
#include <OpenAudio_ArduinoLibrary.h>
#include "config.h"
#if defined(USE_OPEN_AUDIO_LIB)
#include "OpenAudio_ArduinoLibrary.h"
#endif
/*****************************************************
CODE; orig_code/synth.h
@ -1171,54 +1169,6 @@ struct Porta {
CODE; orig_code/source_microdexed.h
*****************************************************/
class AudioSynthDexed : public AudioStream, public Dexed {
public:
const uint16_t audio_block_time_us = 1000000 / (SAMPLE_RATE / AUDIO_BLOCK_SAMPLES);
uint32_t xrun = 0;
uint16_t render_time_max = 0;
AudioSynthDexed(int sample_rate) : AudioStream(0, NULL), Dexed(sample_rate) { };
void update(void)
{
if (in_update == true)
{
xrun++;
return;
}
else
in_update = true;
elapsedMicros render_time;
audio_block_t *lblock;
lblock = allocate();
if (!lblock)
{
in_update = false;
return;
}
getSamples(AUDIO_BLOCK_SAMPLES, lblock->data);
if (render_time > audio_block_time_us) // everything greater audio_block_time_us (2.9ms for buffer size of 128) is a buffer underrun!
xrun++;
if (render_time > render_time_max)
render_time_max = render_time;
transmit(lblock, 0);
release(lblock);
in_update = false;
};
private:
volatile bool in_update = false;
};
#if defined(USE_OPEN_AUDIO_LIB)
class AudioSynthDexed_F32 : public AudioStream_F32, public Dexed {
public:
const uint16_t audio_block_time_us = 1000000 / (SAMPLE_RATE / AUDIO_BLOCK_SAMPLES);
@ -1265,4 +1215,3 @@ class AudioSynthDexed_F32 : public AudioStream_F32, public Dexed {
private:
volatile bool in_update = false;
};
#endif

Loading…
Cancel
Save