Skip to content

Commit

Permalink
Merge pull request #5 from risgk/v0.1/develop
Browse files Browse the repository at this point in the history
v0.1.2
  • Loading branch information
risgk authored Jul 8, 2023
2 parents b112645 + 0d2cef0 commit da3601c
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 49 deletions.
52 changes: 32 additions & 20 deletions DigitalSynthPRA32U/DigitalSynthPRA32U.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,23 @@

//#define DEBUG_PRINT

#define USE_USB_MIDI // Select USB Stack "Adafruit TinuUSB" in the Arduino IDE "Tools" menu
#define USE_USB_MIDI // Select USB Stack: "Adafruit TinuUSB" in the Arduino IDE "Tools" menu
//#define USE_SERIAL1_MIDI

#define SERIAL1_MIDI_SPEED (31250)
//#define SERIAL1_MIDI_SPEED (38400)
#define SERIAL1_MIDI_SPEED (31250)
//#define SERIAL1_MIDI_SPEED (38400)

#define MIDI_CH (0) // 0-based
#define MIDI_CH (0) // 0-based

#define I2S_DATA_PIN (9)
#define I2S_BCLK_PIN (10) // I2S_LRCLK_PIN is I2S_BCLK_PIN + 1
#define I2S_BITS_PER_SAMPLE (16) // 16, 24, or 32
#define I2S_BUFFERS (3)
#define I2S_BUFFER_WORDS (8)
#define I2S_DAC_MUTE_OFF_PIN (22)

#define I2S_DATA_PIN (9)
#define I2S_BCLK_PIN (10) // I2S_LRCLK_PIN is I2S_BCLK_PIN + 1
#define I2S_SWAP_BCLK_AND_LRCLK_PINS (false)

#define I2S_BITS_PER_SAMPLE (16) // 16, 24, or 32
#define I2S_BUFFERS (3)
#define I2S_BUFFER_WORDS (8)

////////////////////////////////////////////////////////////////

Expand All @@ -37,7 +41,7 @@ MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI);

#include <I2S.h>

I2S i2s_output(OUTPUT);
I2S g_i2s_output(OUTPUT);

void handleNoteOn(byte channel, byte pitch, byte velocity);
void handleNoteOff(byte channel, byte pitch, byte velocity);
Expand Down Expand Up @@ -70,16 +74,24 @@ void __not_in_flash_func(setup1)() {
Serial1.begin(SERIAL1_MIDI_SPEED);
#endif

i2s_output.setDATA(I2S_DATA_PIN);
i2s_output.setBCLK(I2S_BCLK_PIN);
i2s_output.setBitsPerSample(I2S_BITS_PER_SAMPLE);
i2s_output.setBuffers(I2S_BUFFERS, I2S_BUFFER_WORDS);
i2s_output.setFrequency(SAMPLING_RATE);
i2s_output.begin();
g_i2s_output.setDATA(I2S_DATA_PIN);
g_i2s_output.setBCLK(I2S_BCLK_PIN);
g_i2s_output.setBitsPerSample(I2S_BITS_PER_SAMPLE);
g_i2s_output.setBuffers(I2S_BUFFERS, I2S_BUFFER_WORDS);
g_i2s_output.setFrequency(SAMPLING_RATE);
if (I2S_SWAP_BCLK_AND_LRCLK_PINS) {
g_i2s_output.swapClocks();
}
g_i2s_output.begin();

#if defined(I2S_DAC_MUTE_OFF_PIN)
pinMode(I2S_DAC_MUTE_OFF_PIN, OUTPUT);
digitalWrite(I2S_DAC_MUTE_OFF_PIN, HIGH);
#endif

#if defined(DEBUG_PRINT)
#if defined(USE_SERIAL1_MIDI)
Serial.begin(0); // Select USB Stack "Pico SDK" in the Arduino IDE "Tools" menu
Serial.begin(0); // Select USB Stack: "Pico SDK" in the Arduino IDE "Tools" menu
#else
Serial1.begin(115200);
#endif
Expand Down Expand Up @@ -110,11 +122,11 @@ void __not_in_flash_func(loop1)() {

for (uint32_t i = 0; i < I2S_BUFFER_WORDS; i++) {
#if (I2S_BITS_PER_SAMPLE == 16)
i2s_output.write16(left_buffer[i], right_buffer[i]);
g_i2s_output.write16(left_buffer[i], right_buffer[i]);
#elif (I2S_BITS_PER_SAMPLE == 24)
i2s_output.write24(left_buffer[i] << 16, right_buffer[i] << 16);
g_i2s_output.write24(left_buffer[i] << 16, right_buffer[i] << 16);
#elif (I2S_BITS_PER_SAMPLE == 32)
i2s_output.write32(left_buffer[i] << 16, right_buffer[i] << 16);
g_i2s_output.write32(left_buffer[i] << 16, right_buffer[i] << 16);
#endif
}

Expand Down
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 @@
```
[United Synthesizer] Date: 2023-05-09
Model: Digital Synth PRA32-U MIDI Implementation Chart Version: 0.1.1
[United Synthesizer] Date: 2023-07-08
Model: Digital Synth PRA32-U MIDI Implementation Chart Version: 0.1.2
+-------------------------------+---------------+---------------+----------------------------------+
| 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 v0.1.1
# Digital Synth PRA32-U Parameter Guide v0.1.2

- 2023-05-09 ISGK Instruments
- 2023-07-08 ISGK Instruments
- <https://github.com/risgk/digital-synth-pra32-u>

## Control Change Parameters
Expand Down
69 changes: 46 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Digital Synth PRA32-U v0.1.1
# Digital Synth PRA32-U v0.1.2

- 2023-05-09 ISGK Instruments
- 2023-07-08 ISGK Instruments
- <https://github.com/risgk/digital-synth-pra32-u>


Expand All @@ -13,7 +13,7 @@
- Controlled by MIDI -- PRA32-U is a MIDI sound module
- The sound of **PRA32-U v0.1** is very similar to that of **VRA8-U (type-16) v2.2**
- <https://github.com/risgk/digital-synth-vra8-u>
- An **I2S DAC** hardware (e.g. Pico Audio Pack) is required
- An **I2S DAC** hardware (e.g. Pimoroni Pico Audio Pack and Pimoroni Pico VGA Demo Base) is required
- **NOTE**: Large noise is generated during the sketch upload!
- **Arduino IDE** and **Raspberry Pi Pico/RP2040** (by Earle F. Philhower, III) core are required
- Additional Board Manager URL: <https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json>
Expand All @@ -22,29 +22,52 @@

## Change History

- v0.1.1: Fix a bug where 0-velocity Note ON is not processed as Note OFF
- v0.1.2: Add I2S_DAC_MUTE_OFF_PIN and I2S_SWAP_BCLK_AND_LRCLK_PINS configurations
- v0.1.2: Fix a bug where 0-velocity Note ON is not processed as Note OFF
- v0.1.0: The first release


## Features

- USB MIDI In
- **NOTE**: Select USB Stack "Adafruit TinuUSB" in the Arduino IDE "Tools" menu
- MIDI Device Name: "Pico"
- Serial MIDI (31.25 kbps or 38.4 kbps) can also be used instead of USB MIDI
- Comment out `#define USE_USB_MIDI` and uncomment out `//#define USE_SERIAL1_MIDI` in `"DigitalSynthPRA32U.ino"`
- Audio Out
- I2S DAC (e.g. PCM5100A), Sampling Rate: 31.25 kHz, Bit Depth: 16 bit
- The default setting is for Pimoroni's [Pico Audio Pack](https://shop.pimoroni.com/products/pico-audio-pack)
- Modify `I2S_DATA_PIN` and `I2S_BCLK_PIN` in `"DigitalSynthPRA32U.ino"` to match the hardware configuration
- Files
- `"digital-synth-pra32-u-0.1.1.uf2"` (in the directory `"bin"`) is a UF2 file for Pico Audio Pack
- `"DigitalSynthPRA32U.ino"` is a Arduino sketch for Raspberry Pi Pico/RP2040 core
- `"make-sample-wav-file.cc"` is for debugging on PC
- GCC (g++) for PC is required
- `"make-sample-wav-file-cc.bat"` makes a sample WAV file (working on Windows)
- `"generate-*.rb"` generates source or header files
- A Ruby execution environment is required
### USB MIDI In

- **NOTE**: Select USB Stack: "Adafruit TinuUSB" in the Arduino IDE "Tools" menu
- MIDI Device Name: "Pico"
- Serial MIDI (31.25 kbps or 38.4 kbps) can also be used instead of USB MIDI
- Comment out `#define USE_USB_MIDI` and uncomment out `//#define USE_SERIAL1_MIDI` in `"DigitalSynthPRA32U.ino"`


### Audio Out

- Use an I2S DAC that does not require MCLK input (e.g. PCM5100A), Sampling Rate: 31.25 kHz, Bit Depth: 16 bit
- Modify `I2S_DAC_MUTE_OFF_PIN`, `I2S_DATA_PIN`, `I2S_BCLK_PIN`, and `I2S_SWAP_BCLK_AND_LRCLK_PINS` in `"Digital-Synth-PRA32-U.ino"` to match the hardware configuration
- The default setting is for Pimoroni [Pico Audio Pack](https://shop.pimoroni.com/products/pico-audio-pack) [PIM544]
```
#define I2S_DAC_MUTE_OFF_PIN (22)
#define I2S_DATA_PIN (9)
#define I2S_BCLK_PIN (10) // I2S_LRCLK_PIN is I2S_BCLK_PIN + 1
#define I2S_SWAP_BCLK_AND_LRCLK_PINS (false)
```
- The following is setting is for [Pimoroni Pico VGA Demo Base](https://shop.pimoroni.com/products/pimoroni-pico-vga-demo-base) [PIM553]
```
//#define I2S_DAC_MUTE_OFF_PIN (22)
#define I2S_DATA_PIN (26)
#define I2S_BCLK_PIN (27) // I2S_LRCLK_PIN is I2S_BCLK_PIN + 1
#define I2S_SWAP_BCLK_AND_LRCLK_PINS (false)
```


### Files

- `"digital-synth-pra32-u-0.1.2-for-pimoroni-pico-audio-pack.uf2"` (in the directory `"bin"`) is a UF2 file for Pimoroni Pico Audio Pack
- `"DigitalSynthPRA32U.ino"` is a Arduino sketch for Raspberry Pi Pico/RP2040 core
- `"make-sample-wav-file.cc"` is for debugging on PC
- GCC (g++) for PC is required
- `"make-sample-wav-file-cc.bat"` makes a sample WAV file (working on Windows)
- `"generate-*.rb"` generates source or header files
- A Ruby execution environment is required


## Limitations
Expand Down Expand Up @@ -115,11 +138,11 @@ graph LR

![CC0](http://i.creativecommons.org/p/zero/1.0/88x31.png)

**Digital Synth PRA32-U v0.1.1 by ISGK Instruments (Ryo Ishigaki)**
**Digital Synth PRA32-U v0.1.2 by ISGK Instruments (Ryo Ishigaki)**

To the extent possible under law, ISGK Instruments (Ryo Ishigaki)
has waived all copyright and related or neighboring rights
to Digital Synth PRA32-U v0.1.1.
to Digital Synth PRA32-U v0.1.2.

You should have received a copy of the CC0 legalcode along with this
work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
Binary file not shown.
2 changes: 1 addition & 1 deletion pra32-u-ctrl.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
}
</style>
<script>
const APP_NAME_VERSION = "PRA32-U CTRL v0.1.1";
const APP_NAME_VERSION = "PRA32-U CTRL v0.1.2";

const MIDI_CH = 0; // 0-based

Expand Down
2 changes: 1 addition & 1 deletion pra32-u-prog-preset.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"_version " : "PRA32-U CTRL v0.1.1",
"_version " : "PRA32-U CTRL v0.1.2",
"_comment " : " CURRENT #8 #9 #10 #11 #12 #13 #14 #15 ",
"OSC_1_WAVE " : [ [0 ], [0 , 0 , 0 , 0 , 0 , 96 , 0 , 0 ] ],
"OSC_1_SHAPE " : [ [0 ], [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ],
Expand Down

0 comments on commit da3601c

Please sign in to comment.