Skip to content

Commit

Permalink
Merge pull request #7 from risgk/develop
Browse files Browse the repository at this point in the history
v1.3.0
  • Loading branch information
risgk authored Nov 3, 2022
2 parents 6a4ea28 + 7e6be4f commit 603503a
Show file tree
Hide file tree
Showing 17 changed files with 1,071 additions and 98 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@

# Others
*.wav
DigitalSynthVRA8U/build/*
7 changes: 4 additions & 3 deletions DigitalSynthVRA8U/DigitalSynthVRA8U.ino
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////
// Digital Synth VRA8-U -- We strongly recommend Arduino AVR Boards core 1.8.5 //
/////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
// Digital Synth VRA8-U -- We strongly recommend Arduino AVR Boards version 1.8.5 (or 1.8.3) //
///////////////////////////////////////////////////////////////////////////////////////////////

//#define DEBUG

Expand All @@ -13,6 +13,7 @@

#define ENABLE_SPECIAL_PROGRAM_CHANGE // Program Change by Control Change (112-119)
// Interpret Program Change 8-15 as 0-7
#define ENABLE_STABLE_MODE



Expand Down
3 changes: 1 addition & 2 deletions DigitalSynthVRA8U/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const uint8_t P_BEND_BY_CC = 35;

const uint8_t OSC_1_WAVE = 24;
const uint8_t OSC_1_SHAPE = 102;
const uint8_t OSC_1_SHAPE_II = 103;
const uint8_t OSC_1_MORPH = 103;
const uint8_t MIXER_SUB_OSC = 26;

const uint8_t OSC_2_WAVE = 55;
Expand Down Expand Up @@ -119,7 +119,6 @@ const uint8_t MONO_MODE_ON = 126;
const uint8_t POLY_MODE_ON = 127;

const uint8_t OSC_WAVE_SAW = 0;
const uint8_t OSC_WAVE_1_S_SAW = 32;
const uint8_t OSC_WAVE_TRIANGLE = 64;
const uint8_t OSC_WAVE_1_PULSE = 96;
const uint8_t OSC_WAVE_2_NOISE = 96;
Expand Down
3 changes: 1 addition & 2 deletions DigitalSynthVRA8U/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

OSC_1_WAVE = 24
OSC_1_SHAPE = 102
OSC_1_SHAPE_II = 103
OSC_1_MORPH = 103
MIXER_SUB_OSC = 26

OSC_2_WAVE = 55
Expand Down Expand Up @@ -119,7 +119,6 @@
POLY_MODE_ON = 127

OSC_WAVE_SAW = 0
OSC_WAVE_1_S_SAW = 32
OSC_WAVE_TRIANGLE = 64
OSC_WAVE_1_PULSE = 96
OSC_WAVE_2_NOISE = 96
Expand Down
19 changes: 14 additions & 5 deletions DigitalSynthVRA8U/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class Filter {
static int16_t m_y_2;
static uint8_t m_cutoff_current;
static int16_t m_cutoff_candidate;
static uint8_t m_cutoff;
static uint8_t m_cutoff_control;
static uint8_t m_cutoff_control_effective;
static int8_t m_cutoff_eg_amt;
static int8_t m_cutoff_lfo_amt;
static int8_t m_cutoff_pitch_amt;
Expand Down Expand Up @@ -52,7 +53,7 @@ class Filter {
value = 124;
}

m_cutoff = value;
m_cutoff_control = value;
}

INLINE static void set_resonance(uint8_t controller_value) {
Expand Down Expand Up @@ -117,7 +118,11 @@ class Filter {
#endif

#if 1
#if defined(ENABLE_STABLE_MODE)
int16_t x_0 = audio_input;
#else
int16_t x_0 = audio_input >> (16 - AUDIO_FRACTION_BITS);
#endif
int16_t tmp = mul_sq16_sq16(x_0 + (m_x_1 << 1) + m_x_2, m_b_2_over_a_0);
tmp -= mul_sq16_sq8( m_y_1, m_a_1_over_a_0_high);
tmp -= mul_sq16_sq16(m_y_2, m_a_2_over_a_0);
Expand All @@ -142,15 +147,15 @@ class Filter {

private:
INLINE static void update_coefs_0th(uint8_t eg_input) {
m_cutoff_candidate = m_cutoff;
m_cutoff_candidate = m_cutoff_control_effective;
m_cutoff_candidate += high_sbyte((m_cutoff_eg_amt * eg_input) << 1);
m_cutoff_candidate += m_cutoff_offset;
}

INLINE static void update_coefs_1st(int16_t lfo_input) {
m_cutoff_candidate -= high_sbyte(mul_sq16_sq8(lfo_input, m_cutoff_lfo_amt) << 1);

// OSC Pitch is processed here (not in Voice) for performance reasons
// OSC Pitch is handled here (not in Voice) for performance reasons
uint16_t osc_pitch = IOsc<0>::get_osc_pitch();
if (m_cutoff_pitch_amt == 1) {
m_cutoff_candidate += static_cast<int8_t>(high_byte(osc_pitch + 128) - 60);
Expand All @@ -167,6 +172,9 @@ class Filter {
} else {
m_cutoff_current = m_cutoff_candidate;
}

m_cutoff_control_effective += (m_cutoff_control_effective < m_cutoff_control);
m_cutoff_control_effective -= (m_cutoff_control_effective > m_cutoff_control);
}

INLINE static void update_coefs_3rd() {
Expand All @@ -189,7 +197,8 @@ template <uint8_t T> int16_t Filter<T>::m_y_1;
template <uint8_t T> int16_t Filter<T>::m_y_2;
template <uint8_t T> uint8_t Filter<T>::m_cutoff_current;
template <uint8_t T> int16_t Filter<T>::m_cutoff_candidate;
template <uint8_t T> uint8_t Filter<T>::m_cutoff;
template <uint8_t T> uint8_t Filter<T>::m_cutoff_control;
template <uint8_t T> uint8_t Filter<T>::m_cutoff_control_effective;
template <uint8_t T> int8_t Filter<T>::m_cutoff_eg_amt;
template <uint8_t T> int8_t Filter<T>::m_cutoff_lfo_amt;
template <uint8_t T> int8_t Filter<T>::m_cutoff_pitch_amt;
Expand Down
7 changes: 7 additions & 0 deletions DigitalSynthVRA8U/generate-osc-table.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
FOR_ARDUINO_NANO = false

require_relative 'constants'

$file = File.open("osc-table.h", "w")
Expand Down Expand Up @@ -104,6 +106,11 @@ def last_harmonic(freq, organ = false, organ_last)
last = 5 if last == 6
last = 3 if last == 4
last = [last, 127].min
if FOR_ARDUINO_NANO == true
last = 11 if last == 13
last = 7 if last == 9
last = 3 if last == 5
end
last
end

Expand Down
Loading

0 comments on commit 603503a

Please sign in to comment.