Skip to content

Commit

Permalink
Merge pull request #22 from risgk/develop
Browse files Browse the repository at this point in the history
v2.2.0
  • Loading branch information
risgk authored Jan 26, 2024
2 parents 99cce80 + f4b76b2 commit 65eb4f8
Show file tree
Hide file tree
Showing 14 changed files with 432 additions and 196 deletions.
20 changes: 11 additions & 9 deletions Digital-Synth-PRA32-U/Digital-Synth-PRA32-U.ino
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#define PRA32_U_PWM_AUDIO_L_PIN (28)
#define PRA32_U_PWM_AUDIO_R_PIN (27)

//#define PRA32_U_USE_PWM_AUDIO_DITHERING_INSTEAD_OF_ERROR_DIFFUSION

#define PRA32_U_USE_2_CORES_FOR_SIGNAL_PROCESSING

#define PRA32_U_USE_EMULATED_EEPROM
Expand All @@ -52,7 +54,7 @@ MIDI_CREATE_INSTANCE(Adafruit_USBD_MIDI, usbd_midi, USB_MIDI);
#endif // defined(PRA32_U_USE_USB_MIDI)

#if defined(PRA32_U_USE_UART_MIDI)
MIDI_CREATE_INSTANCE(HardwareSerial, Serial2, SERIAL_MIDI);
MIDI_CREATE_INSTANCE(HardwareSerial, Serial2, UART_MIDI);
#endif

#if defined(PRA32_U_USE_PWM_AUDIO_INSTEAD_OF_I2S)
Expand Down Expand Up @@ -130,13 +132,13 @@ void __not_in_flash_func(setup)() {
#if defined(PRA32_U_USE_UART_MIDI)
Serial2.setTX(PRA32_U_UART_MIDI_TX_PIN);
Serial2.setRX(PRA32_U_UART_MIDI_RX_PIN);
SERIAL_MIDI.setHandleNoteOn(handleNoteOn);
SERIAL_MIDI.setHandleNoteOff(handleNoteOff);
SERIAL_MIDI.setHandleControlChange(handleControlChange);
SERIAL_MIDI.setHandleProgramChange(handleHandleProgramChange);
SERIAL_MIDI.setHandlePitchBend(handleHandlePitchBend);
SERIAL_MIDI.begin(MIDI_CHANNEL_OMNI);
SERIAL_MIDI.turnThruOff();
UART_MIDI.setHandleNoteOn(handleNoteOn);
UART_MIDI.setHandleNoteOff(handleNoteOff);
UART_MIDI.setHandleControlChange(handleControlChange);
UART_MIDI.setHandleProgramChange(handleHandleProgramChange);
UART_MIDI.setHandlePitchBend(handleHandlePitchBend);
UART_MIDI.begin(MIDI_CHANNEL_OMNI);
UART_MIDI.turnThruOff();
Serial2.begin(PRA32_U_UART_MIDI_SPEED);
#endif // defined(PRA32_U_USE_UART_MIDI)

Expand Down Expand Up @@ -179,7 +181,7 @@ void __not_in_flash_func(loop)() {
#endif // defined(PRA32_U_USE_USB_MIDI)

#if defined(PRA32_U_USE_UART_MIDI)
SERIAL_MIDI.read();
UART_MIDI.read();
#endif
}

Expand Down
4 changes: 2 additions & 2 deletions Digital-Synth-PRA32-U/pra32-u-program-table.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const uint8_t g_preset_table_OSC_2_COARSE [] = {64 , 64 , 64 , 64 , 64 , 64 ,
const uint8_t g_preset_table_OSC_2_PITCH [] = {109, 72 , 72 , 72 , 72 , 72 , 72 , 72 , 109, 72 , 72 , 72 , 72 , 72 , 72 , 72 };
const uint8_t g_preset_table_MIXER_OSC_MIX [] = {64 , 64 , 64 , 64 , 64 , 64 , 64 , 0 , 64 , 64 , 64 , 64 , 64 , 64 , 64 , 0 };

const uint8_t g_preset_table_FILTER_CUTOFF [] = {115, 115, 91 , 103, 55 , 115, 79 , 127, 115, 115, 91 , 103, 55 , 115, 79 , 127};
const uint8_t g_preset_table_FILTER_CUTOFF [] = {115, 115, 91 , 103, 55 , 115, 67 , 127, 115, 115, 91 , 103, 55 , 115, 67 , 127};
const uint8_t g_preset_table_FILTER_RESO [] = {64 , 0 , 32 , 32 , 64 , 64 , 32 , 0 , 64 , 0 , 32 , 32 , 64 , 64 , 32 , 0 };
const uint8_t g_preset_table_FILTER_EG_AMT [] = {64 , 64 , 88 , 16 , 112, 64 , 64 , 64 , 64 , 64 , 88 , 16 , 112, 64 , 64 , 64 };
const uint8_t g_preset_table_FILTER_KEY_TRK [] = {64 , 64 , 64 , 64 , 64 , 64 , 64 , 0 , 64 , 64 , 64 , 64 , 64 , 64 , 64 , 0 };
Expand All @@ -36,7 +36,7 @@ const uint8_t g_preset_table_LFO_FADE_TIME [] = {0 , 0 , 0 , 0 , 0 , 0 ,
const uint8_t g_preset_table_LFO_OSC_AMT [] = {96 , 96 , 64 , 64 , 64 , 96 , 64 , 64 , 96 , 96 , 64 , 64 , 64 , 96 , 64 , 64 };
const uint8_t g_preset_table_LFO_OSC_DST [] = {0 , 0 , 0 , 0 , 0 , 127, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 127, 0 , 0 };
const uint8_t g_preset_table_LFO_FILTER_AMT [] = {64 , 64 , 88 , 88 , 88 , 64 , 88 , 64 , 64 , 64 , 88 , 88 , 88 , 64 , 88 , 64 };
const uint8_t g_preset_table_AMP_GAIN [] = {100, 100, 100, 100, 100, 100, 127, 100, 100, 100, 100, 100, 100, 100, 127, 100};
const uint8_t g_preset_table_AMP_GAIN [] = {90 , 90 , 90 , 90 , 90 , 90 , 127, 90 , 90 , 90 , 90 , 90 , 90 , 90 , 127, 90 };

const uint8_t g_preset_table_AMP_ATTACK [] = {0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 };
const uint8_t g_preset_table_AMP_DECAY [] = {0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 };
Expand Down
27 changes: 25 additions & 2 deletions Digital-Synth-PRA32-U/pra32-u-synth.h
Original file line number Diff line number Diff line change
Expand Up @@ -1061,9 +1061,32 @@ class PRA32_U_Synth {
int16_t delay_fx_output_l = m_delay_fx.process(chorus_fx_output_l, chorus_fx_output_r, delay_fx_output_r);

#if defined(PRA32_U_USE_PWM_AUDIO_INSTEAD_OF_I2S)
#if defined(PRA32_U_USE_PWM_AUDIO_DITHERING_INSTEAD_OF_ERROR_DIFFUSION)
// Dithering
right_level = delay_fx_output_r + ((noise_int15 + 16384) >> 11);
return delay_fx_output_l + ((noise_int15 + 16384) >> 11);
right_level = delay_fx_output_r + (((noise_int15 + 16384) >> 11) - 8);
return delay_fx_output_l + (((noise_int15 + 16384) >> 11) - 8);
#else // defined(PRA32_U_USE_PWM_AUDIO_DITHERING_INSTEAD_OF_ERROR_DIFFUSION)
// Error diffusion
static uint16_t s_output_error_l = 0;
static uint16_t s_output_error_r = 0;

uint32_t pwm_audio_l = delay_fx_output_l + 0x8000;
uint32_t pwm_audio_r = delay_fx_output_r + 0x8000;
pwm_audio_l += ((noise_int15 + 16384) >> 14);
pwm_audio_r += !((noise_int15 + 16384) >> 14);
pwm_audio_l *= 3075;
pwm_audio_r *= 3075;
pwm_audio_l += s_output_error_l;
pwm_audio_r += s_output_error_r;

volatile uint16_t prev_output_error_l = s_output_error_l;
volatile uint16_t prev_output_error_r = s_output_error_r;
s_output_error_l = pwm_audio_l & 0xFFFF;
s_output_error_r = pwm_audio_r & 0xFFFF;

right_level = delay_fx_output_r + (prev_output_error_r > s_output_error_r) * 22;
return delay_fx_output_l + (prev_output_error_l > s_output_error_l) * 22;
#endif // defined(PRA32_U_USE_PWM_AUDIO_DITHERING_INSTEAD_OF_ERROR_DIFFUSION)
#else // defined(PRA32_U_USE_PWM_AUDIO_INSTEAD_OF_I2S)
right_level = delay_fx_output_r;
return delay_fx_output_l;
Expand Down
65 changes: 65 additions & 0 deletions PRA32-U-Change-History.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
## Digital Synth PRA32-U Change History

- v2.2.0 (2024-01-26):
- Use error diffusion for PWM audio output by default
- Eliminate noise when PWM audio output is silent
- Change the display of PRA32-U CTRL
- Modify Presets;
- Tested with Adafruit TinyUSB Library version 2.3.3
- v2.1.0 (2024-01-14):
- Reduce noise from PMIC (Turn off RT6150 Power Save);
- Support Osc 1 Sine Wave Phase Modulation (Osc 1 Shape and Osc 1 Morph);
- Add the function of writing the parameters to Program #8-15 and the flash;
- Modify Presets;
- Add JSON files for PRA32-U CTRL;
- Use core 0 for main processing;
- Rename constant macros;
- Officially support PWM audio output option;
- Rename Serial MIDI to UART MIDI;
- Enable UART MIDI to be used at the same time as USB MIDI;
- Use Serial1 for Debug Print and Serial2 for UART MIDI;
- Raspberry Pi Pico/RP2040 core version 3.6.3 is recommended
- v2.0.1 (2024-01-05):
- Fix Ping Pong Delay to start from the left
- Fix Parameter Guide (Filter Resonance)
- v2.0.0 (2024-01-04):
- Add Delay Mode (Ping Pong Delay);
- Support Breath Controller (Breath Filter Amt and Breath Amp Mod);
- Support Note ON Velocity (EG Velocity Sensitivity and Amp Velocity Sensitivity);
- Modify EG and Amp EG;
- Modify Presets;
- Change the control numbers of Control Changes
(Voice Mode: 27 -> 14, LFO Wave: 18 -> 12, Filter Mode: 86 -> 78, EG Amp Mod: 87 -> 28, and Chorus Mix: 93 -> 27);
- Change the meanings of the values of Control Changes
(Osc 1 Wave, Osc 2 Wave, EG Osc Dst, Voice Mode, LFO Wave, LFO Osc Dst, Filter Mode, EG Amp Mod, Release = Decay, Breath Amp Mod, and Delay Mode);
- Increase DMA buffer size (audio latency: 2.7 ms -> 5.3 ms);
- Use 2 cores for signal processing in Polyphonic and Paraphonic Modes;
- Add PWM audio output option (experimental)
- v1.2.1: Fixed an oscillation problem caused by Delay Feedback
- v1.2.0: Renew High Pass Filter; Raspberry Pi Pico/RP2040 core version 3.6.2 is recommended
- v1.1.1: Revert Filter clipping in High Pass mode
- v1.1.0: Fix Filter clipping (behavior during oscillation); Extend Pitch Bend Range;
Delete the code for Waveshare Pico-Audio Rev2.1
- v1.0.3: Fix a problem with received MIDI messages being dropped; Improve README; Fix UF2 files
- v1.0.2: Turn MIDI Thru Off
- v1.0.1: Fix unstable PRA32-U CTRL operation when using Serial MIDI (DIN/TRS MIDI); Fix README
- v1.0.0: Change Control Numbers of Control Changes;
Change the meanings of the values of Osc 1/2 Wave, Voice Mode, and LFO Wave; Add Sine Wave to Osc 1 and 2;
Limit the change range and the change rate of Osc 1 Shape; Change Noise specifications;
Change Sub Osc Triangle Wave to Sine Wave; Change LFO Triangle Wave 2 to Sine Wave;
Improve resolution of Filter Resonance; Limit the change rate of Filter Cutoff due to modulation;
Change Amp Level to Amp Gain; Change Chorus Mode to Chorus Mix; Add Delay Fx;
Delete Chorus Delay Time, Chorus Bypass, and Pitch Bend by CC; Update Presets; Other changes
- v0.4.0 (Prototype): Extend Osc 2 Coarse range; Change Osc 2 Fine curve; Rename "Osc 2 Fine" to "Osc 2 Pitch";
Change LFO Osc/Filter Amt curve; Update Presets
- v0.3.1 (Prototype): Adjust smoothing time when parameters change; Update Presets; Fix LFO Osc/Filter Amt; Other changes
- v0.3.0 (Prototype): Extend Note Number range; Remove drift of Oscillators; Improve Triangle Wave; Change Portamento curve;
Improve Filter Low Cut Mode; Rename Filter Mode LC (Low Cut) to HP (High Pass); Modify Filter coefficients;
Change EG curve; Extend LFO Rate curve; Change LFO Fade Time; Change Chorue Rate curve; Update Presets;
Fix Filter Key Track (Fix problem with strange sound when pitch is outside of note number range);
Fix behavior when Portamento is 0 (Off); Other changes
- v0.2.0 (Prototype): Change Sampling Rate to 48000 Hz; Support MCLK for I2S; Support Polyphonic Mode;
Extend Filter Cutoff frequency change range to 10+ octaves;
Change "Mixer Sub Osc" to "Mixer Noise/Sub Osc"; Add "EG Amp Mod", "Release = Decay", and "Filter Mode";
Enable Osc 1 Shape, Morph, Noise/Sub Osc, and Osc 2 in Paraphonic and Polyphonic Modes; Other changes
- v0.1.0 (Prototype): The first release
4 changes: 2 additions & 2 deletions PRA32-U-MIDI-Implementation-Chart.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
```
[Polyphonic/Paraphonic Synthesizer] Date: 2024-01-14
Model: Digital Synth PRA32-U MIDI Implementation Chart Version: 2.1.0
[Polyphonic/Paraphonic Synthesizer] Date: 2024-01-26
Model: Digital Synth PRA32-U MIDI Implementation Chart Version: 2.2.0
+-------------------------------+---------------+---------------+-------------------------------------+
| Function... | Transmitted | Recognized | Remarks |
+-------------------------------+---------------+---------------+-------------------------------------+
Expand Down
4 changes: 2 additions & 2 deletions PRA32-U-Parameter-Guide.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Digital Synth PRA32-U Parameter Guide v2.1.0
# Digital Synth PRA32-U Parameter Guide v2.2.0

- 2024-01-14 ISGK Instruments
- 2024-01-26 ISGK Instruments
- <https://github.com/risgk/digital-synth-pra32-u>

## Control Change Parameters
Expand Down
Loading

0 comments on commit 65eb4f8

Please sign in to comment.