mirror of
https://github.com/dwhinham/mt32-pi.git
synced 2026-10-26 22:11:05 +00:00
Add ability to configure GPIO MIDI baud rate
This commit is contained in:
1 parent
e0909b767f
commit
20c9e5f402
5 files changed
+29
-2
No files matched your search
@@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
### Added
|
||||
|
||||
- Ability to configure initial MIDI channel assignment (new configuration file option).
|
||||
- Ability to set custom baud rates for GPIO MIDI (new configuration file option).
|
||||
* This could be useful for those wanting to use [SoftMPU](http://bjt42.github.io/softmpu/)'s serial MIDI mode.
|
||||
|
||||
### Changed
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ Turn your Raspberry Pi into a dedicated emulation of the [famous multi-timbre so
|
||||
* [GPIO MIDI interface](#gpio-midi-interface)
|
||||
+ [Schematic](#schematic)
|
||||
+ [Breadboard example](#breadboard-example)
|
||||
+ [Serial ports](#serial-ports)
|
||||
- [🔊 I2S DAC support](#-i2s-dac-support)
|
||||
* [Setup](#setup)
|
||||
* [Compatibility](#compatibility-1)
|
||||
@@ -113,6 +114,12 @@ You can build a simple circuit based on an opto-isolator, a diode, and a few res
|
||||
#### Breadboard example
|
||||

|
||||
|
||||
#### Serial ports
|
||||
|
||||
You can also skip the MIDI circuitry and drive `mt32-pi` using a serial port directly using software such as [Hairless MIDI] or [SoftMPU] and suitable cabling. Use the `gpio_baud_rate` option in the configuration file to match up `mt32-pi` with your host's serial port baud rate.
|
||||
|
||||
> ⚠️ **Note:** Remember that the Raspberry Pi expects no more than 3.3V on its GPIO pins, so make sure that you use appropriate level shifting when interfacing with other hardware to prevent damage to the Pi.
|
||||
|
||||
## 🔊 I2S DAC support
|
||||
|
||||
The Raspberry Pi's headphone jack is a simple PWM device, and not designed for high-fidelity audio. This becomes very obvious when you use `mt32-pi` - distortion in the sound is apparent when quieter sounds are playing.
|
||||
@@ -291,6 +298,7 @@ This project, just like [Munt], has no affiliation with Roland Corporation. Use
|
||||
[Circle]: https://github.com/rsta2/circle
|
||||
[digital-to-analog converter]: https://en.wikipedia.org/wiki/Digital-to-analog_converter
|
||||
[GY-PCM5102]: https://www.aliexpress.com/item/4000049720221.html
|
||||
[Hairless MIDI]: https://projectgus.github.io/hairless-midiserial/
|
||||
[I2C backpack]: https://www.adafruit.com/product/292
|
||||
[inih]: https://github.com/benhoyt/inih
|
||||
[Munt]: https://github.com/munt/munt
|
||||
@@ -299,3 +307,4 @@ This project, just like [Munt], has no affiliation with Roland Corporation. Use
|
||||
[PI-MIDI]: https://www.arananet.net/pedidos/product/pi-midi-a-baremetal-mt32-emulator-using-raspberry-pi3
|
||||
[REC002004B]: https://www.raystar-optronics.com/oled-character-display-module/REC002004B.html
|
||||
[Releases]: https://github.com/dwhinham/mt32-pi/releases/latest
|
||||
[SoftMPU]: http://bjt42.github.io/softmpu/
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
CFG_A(midi, usb, bool, mMIDIUSB, true )
|
||||
CFG_A(midi, gpio_thru, bool, mMIDIGPIOThru, false )
|
||||
CFG_A(midi, gpio_baud_rate, int, mMIDIGPIOBaudRate, 31250 )
|
||||
CFG_A(audio, output_device, AudioOutputDevice, mAudioOutputDevice, AudioOutputDevice::PWM )
|
||||
CFG_A(audio, sample_rate, int, mAudioSampleRate, 96000 )
|
||||
CFG_A(audio, chunk_size, int, mAudioChunkSize, 512 )
|
||||
|
||||
@@ -22,6 +22,17 @@
|
||||
# Values: on*, off
|
||||
usb = on
|
||||
|
||||
# Set the baud rate used for GPIO MIDI.
|
||||
#
|
||||
# For connecting to standard MIDI devices (i.e. via DIN cable), this should be
|
||||
# left at the default rate of 31250.
|
||||
#
|
||||
# For connecting to PCs, set this to match the baud rate of the other host.
|
||||
# SoftMPU's serial MIDI mode, for example, uses a baud rate of 38400.
|
||||
#
|
||||
# Values: 300-4000000 (31250*)
|
||||
gpio_baud_rate = 31250
|
||||
|
||||
# Enable or disable software "MIDI thru" on the GPIO Tx pin.
|
||||
#
|
||||
# When enabled, all data received via the GPIO Rx pin will be re-transmitted
|
||||
|
||||
+6
-2
@@ -95,9 +95,9 @@ bool CKernel::Initialize(void)
|
||||
if (!pLogTarget)
|
||||
pLogTarget = &mNull;
|
||||
|
||||
// Init serial for GPIO MIDI if not being used for logging
|
||||
// Init serial port early if used for logging
|
||||
mSerialMIDIEnabled = pLogTarget != &mSerial;
|
||||
if (!mSerial.Initialize(mSerialMIDIEnabled ? 31250 : 115200))
|
||||
if (!mSerialMIDIEnabled && !mSerial.Initialize(115200))
|
||||
return false;
|
||||
|
||||
if (!mLogger.Initialize(pLogTarget))
|
||||
@@ -123,6 +123,10 @@ bool CKernel::Initialize(void)
|
||||
if (!mConfig.Initialize("mt32-pi.cfg"))
|
||||
mLogger.Write(GetKernelName(), LogWarning, "Unable to find or parse config file; using defaults");
|
||||
|
||||
// Init serial port for GPIO MIDI if not being used for logging
|
||||
if (mSerialMIDIEnabled && !mSerial.Initialize(mConfig.mMIDIGPIOBaudRate))
|
||||
return false;
|
||||
|
||||
if (!mI2CMaster.Initialize())
|
||||
return false;
|
||||
|
||||
|
||||
Reference in new issue
Block a user