WavePi: Use Raspberry pi (2/3/4) as a AIO MIDI synth

Discussion about old sound cards, MIDI devices and sound related accessories.

WavePi: Use Raspberry pi (2/3/4) as a AIO MIDI synth

Postby t9999clint » 2019-3-16 @ 16:09

Installation instructions are on GitHub!!
GitHub - https://github.com/t9999clint/WavePi
Project site - https://www.retroimperfections.com/wavepi/

Patreon - https://www.patreon.com/KORNinja
PayPal - https://www.paypal.com/cgi-bin/webscr?c ... source=url
Thanks for those who are supporting this project on patreon and paypal it means a lot.

Discord - https://discord.gg/J7rxhTN
We have a growing community of Soundfont nerds here. (never expected that to happen)

This project is a multipurpose synthesizer platform for the raspberry pi. Complete with automatic profile switching using sysex messages to allow the raspberry pi to be controlled from the machine sending the midi data.

This is to act either as a MT-32/CM-32L replacement, or as a soundfont powered synth to use with your old computer, or MIDI Keyboard.

There will be a number of ways to connect this to a old pc, through MIDI cable to gameport adapter, through a serial port, or to the wavetable header like the one on a soundblaster 16.

So far I've only finished the standard MIDI cable in software, but the others are coming. Serial is probably the cheapest way to connect it to a old PC, but it won't support any game that you can't use with softmpu.

Regarding the wavetable header...
I was looking at some schematics and it looks like it should be fairly simple, (not super easy though) to make a adapter that converts the pinout on a soundblaster wavetable header to something that you can plugin to the GPIO on a raspberry pi.

The current plan is to workout something on a breadboard that converts the MIDI to Serial (at 3.3v) and plug that into the gpio pins on the raspberry pi.
From my testing, the 5v rail from most computer power-supplies isn't stable enough to use with the Ras Pi and might damage the Pi or even worse the computer. To get around this, and to still allow the WavePi to be internally powered it has to go through a 12v to 5v buck converter like the LM2596 (calibrated for about 5.5v).
The Midi data will be converted by a optocoupler like the 6N138 and a few resistors. This should bring everything to the levels that the Pi is expecting, while also hopefully limit the noise from the computer's hardware.
The biggest roadblock is the Raspberry Pi 3's built in DAC, which is basically unusable. The cheapest good quality DAC I was able to find was the Sabarant USB one for about $8.

The goal is for the circuitry to only cost about $2-5 USD in parts, (not including the Pi) but so far the project's BOM will probably be around $20 depending on features. The biggest cost is the DAC.

Youtube demo of a WavePi installed inside a PC directly connected to the wavetable header, ZERO EXTERNAL CABLES!.
https://www.youtube.com/watch?v=ye8hCD7b2yk

here's a draft diagram based off of one from samplerbox, some reference documents and another from serdashop...
I'll replace this with a proper schematic when I get to that stage. I'm just at the software stage right now...
Image

BOM (sort of) for wavetable adapter... rough guess is $20 USD total, I need to find a way to make this cheaper...
- $8 - 1 x USB Audio DAC (Sabrent USB)
- $1.50 - 1 x LM2596 DC to DC Buck converter (12v to 5v to power pi, 5v from soundblaster is too unstable/unsafe)
- $0.80 - 1 x 6N138 Optocoupler (MIDI to TTY signal stripping/voltage stepdown)
- $??? - 1 x diode 1N4148
- $??? - 1 x 220ohm resistor
- $??? - 1 x 40 kohm resistor
- $??? - 1 x 4 kohm resistor
- $??? - 1 x Aux stereo cable (connect DAC to soundcard, either internal or external)
- $??? - 1 x ribbon cable, eg. floppy cable (connect midi and audio to wavetable header on soundcard)
- $??? - 1 x molex, female connector (for 12v)
Last edited by t9999clint on 2019-9-11 @ 02:27, edited 16 times in total.
User avatar
t9999clint
Member
 
Posts: 157
Joined: 2014-10-07 @ 14:08
Location: Edmonton, Canada

Re: WavePi: Use Raspberry pi as a MIDI Daughterboard

Postby t9999clint » 2019-3-16 @ 16:26

Once this project is mature enough to be considered feature complete I'll use this comment for the changelog, for now i'll use it as a to-do list.


Here's my plan/progress for this project at the moment:
- *DONE* testing a Proof of concept for this, just using a USB MIDI cable, gameport to midi adapter and a ras pi 3 b+.
- *DONE* Configure Fluidsynth to reliably load soundfonts and accept MIDI
- *DONE* get it to be installable on different systems.
- *DONE* :cool: Add way to switch synths through sysex messages. I'm gonna have to learn some python for this.
- *DONE* Add NZXT HUE+ support for dynamic RGB lighting.
- *DONE* Configure serial port passthrough for MIDI, no soundcard required :-) (TTYMIDI)
- *MOSTLY DONE* Add proper documentation and tutorials (including video)
- *DONE* Add MUNT support.
- *MOSTLY DONE* LCD Code With button support. I2C 16x2 display (thanks ElBartoME!!)
- *shouldn't be too hard* look into using MAME code to emulate other synths (Yamaha FB-01 and Roland SC-55 :cool: ).
- Add a WebUI for easy use with a phone/IE 5.0/Dillo, this should also have a auto-generated profile and soundfont list. (thanks to seren for the WebUI idea)
- get a Raspberry Pi 4 B to test code on that. (should already work though)
- convert existing python scripts from MCOBIT to add further led and lcd support. as well as hardware buttons. Also usefull for Dreamblaster's new MP-32.
- Make .img files for easy installation (hosted through bittorrent?)
- add support for Jack2 and NetJack
- add better integration to be used with the MiSTer project (UDPMidi support on WavePi and adding Preset selector menu to the MiSTer ui).
- convert as much of my code as possible to C or C++. This is mainly so I can reduce the amount of dependencies, fix some filename issues and because I don't like Python.
- *In theory it's possible* Add support for windows .VST files through Wine/QEMU layer.
- *hardware wise it's easy, software wise... SUPER complicated* See about OPL2/AdLib support. (like a OPL2LPT) Maybe through a USB2LPT adapter, maybe midi can be passed through this way too...
- *DONE* Once I get the software side worked out and stable I'll start building a test rig using a breadboard and stuff to see how well it'll work. *EDIT: Works great! :happy:
- *MOSTLY DONE* After I will reduce the components and draft a final BoM and wiring schematics for a cable adapter.
- *MOSTLY DONE* Maybe after this I will design a pcb layout for this, pins on oneside to connect to the soundcard, pins on the other to connect directly to the pi. (as a Pi Hat, with a stereo jack for the audio)
- if I ever get this far then I would look into getting a cheap dac to use instead of a USB dac. This way we can increase the quality while keeping things cheap.
- Maybe start selling these as kits.... maybe?
- ???
- PROFIT!
(the last bit there was a joke btw)

Side goal - make a OrangePi Zero version because it should be simpler to configure for this and it'd look waaay cleaner. (not sure a OrangePi would be fast enough for my soundfont though...)
Side goal 2 - see if It's possible to use another computer on the local network to do the soundfont synth stuff and stream it back over to the pi. Then ram and cpu speed wouldn't be an issue. Maybe a modified version of FalcoSoft Midiplayer with a pulseaudio/jack client?
Last edited by t9999clint on 2019-9-11 @ 04:25, edited 36 times in total.
User avatar
t9999clint
Member
 
Posts: 157
Joined: 2014-10-07 @ 14:08
Location: Edmonton, Canada

Re: WavePi: Use Raspberry pi as a MIDI Daughterboard

Postby root42 » 2019-3-16 @ 17:46

Since Dreamblaster et al are so cheap I think this project would be useful for two things:

1. to run MUNT on the PI and have a MT32.
2. for fun and giggles. Aka learning.

Maybe this would be nice with a zero or a compute module?
Soldering, retro game reviews and more on YouTube and Bonus videos
80386DX@25 MHz, 8 MiB RAM, Tseng ET4000 1 MiB, Jazz16, PC MIDI Card + SC55MkII + MT32, XT CF Lite, OSSC 1.6
User avatar
root42
Oldbie
 
Posts: 1200
Joined: 2018-1-27 @ 13:23

Re: WavePi: Use Raspberry pi as a MIDI Daughterboard

Postby t9999clint » 2019-3-16 @ 17:52

Yup 99% just for fun, I'm only using a 3b+ because that's what I have right now. The ras pi zero doesn't have a dac, but the orange pi zero does, so I'm looking at maybe buying one of those and testing it out, but if I ever start reaching the point where I'm adding a dac anyways, then the ras zero should work fine.
User avatar
t9999clint
Member
 
Posts: 157
Joined: 2014-10-07 @ 14:08
Location: Edmonton, Canada

Re: WavePi: Use Raspberry pi as a MIDI Daughterboard

Postby root42 » 2019-3-16 @ 20:21

But why the extra card reader? The micro SD of the Pi should be plenty?
Soldering, retro game reviews and more on YouTube and Bonus videos
80386DX@25 MHz, 8 MiB RAM, Tseng ET4000 1 MiB, Jazz16, PC MIDI Card + SC55MkII + MT32, XT CF Lite, OSSC 1.6
User avatar
root42
Oldbie
 
Posts: 1200
Joined: 2018-1-27 @ 13:23

Re: WavePi: Use Raspberry pi as a MIDI Daughterboard

Postby t9999clint » 2019-3-16 @ 22:01

root42 wrote:But why the extra card reader? The micro SD of the Pi should be plenty?

Those are diagrams ripped from other projects, I'll make a proper diagram without that stuff. It's just to show the wiring for serial2midi on the gpio, and the diagram below that is for the wavetable header.
User avatar
t9999clint
Member
 
Posts: 157
Joined: 2014-10-07 @ 14:08
Location: Edmonton, Canada

Re: WavePi: Use Raspberry pi as a MIDI Daughterboard

Postby gdjacobs » 2019-3-17 @ 02:33

MIDI in on a Raspi UART is viable, but kind of goofy. The ideal option would have a decent USB DAC and MIDI I/O, that or just use an X3M.
User avatar
gdjacobs
l33t++
 
Posts: 6511
Joined: 2015-11-03 @ 05:51
Location: The Great White North

Re: WavePi: Use Raspberry pi as a MIDI Daughterboard

Postby t9999clint » 2019-3-17 @ 04:34

gdjacobs wrote:MIDI in on a Raspi UART is viable, but kind of goofy. The ideal option would have a decent USB DAC and MIDI I/O, that or just use an X3M.

X3M would be the better option for most people, that is true. But I want to load my own SF2 files, or load up MUNT on here, this you can't do on a X3M.
Yeah, It's probably pretty goofy but hell it's worth a try. Other ras pi owners have claimed it worked fine for them, but then again I won't know until I build one myself.

On the other hand, I agree, if you have a usb dac and Midi solution already it's probably way better to use that instead. And there's nothing stopping anyone from doing that. This project is gonna be open source for a reason.
It's a DIY synth, make it how you like. In fact I'm using USB DAC and MIDI adapters with it right now as I build/document the software side of this.
Last edited by t9999clint on 2019-3-17 @ 04:39, edited 1 time in total.
User avatar
t9999clint
Member
 
Posts: 157
Joined: 2014-10-07 @ 14:08
Location: Edmonton, Canada

Re: WavePi: Use Raspberry pi as a MIDI Daughterboard

Postby jmarsh » 2019-3-17 @ 04:37

Why do you want to connect to the wavetable header instead of the port on the back of the card?
jmarsh
Member
 
Posts: 241
Joined: 2014-1-04 @ 09:17

Re: WavePi: Use Raspberry pi as a MIDI Daughterboard

Postby t9999clint » 2019-3-17 @ 04:44

jmarsh wrote:Why do you want to connect to the wavetable header instead of the port on the back of the card?

2 reasons mainly...

1. to make it a stealth install. I would like to install the ras pi inside the machine and leave the other ports on the soundcard free to use for other stuff. It'll look super clean when it's done right.
2. for fun basically. I want to learn how to do some electronics and PCB design and this looks like something simple enough for me to tackle.

Also it doesn't have to be internal. You could just wire it up to the back like normal. It's a DIY thing, I'm not the boss of you people :wink:
User avatar
t9999clint
Member
 
Posts: 157
Joined: 2014-10-07 @ 14:08
Location: Edmonton, Canada

Re: WavePi: Use Raspberry pi as a MIDI Daughterboard

Postby gdjacobs » 2019-3-17 @ 05:38

t9999clint wrote:
gdjacobs wrote:MIDI in on a Raspi UART is viable, but kind of goofy. The ideal option would have a decent USB DAC and MIDI I/O, that or just use an X3M.

X3M would be the better option for most people, that is true. But I want to load my own SF2 files, or load up MUNT on here, this you can't do on a X3M.
Yeah, It's probably pretty goofy but hell it's worth a try. Other ras pi owners have claimed it worked fine for them, but then again I won't know until I build one myself.


You can if you use the X3M as the DAC and MIDI input for your Pi.
User avatar
gdjacobs
l33t++
 
Posts: 6511
Joined: 2015-11-03 @ 05:51
Location: The Great White North

Re: WavePi: Use Raspberry pi as a MIDI Daughterboard

Postby t9999clint » 2019-3-17 @ 12:08

gdjacobs wrote:
t9999clint wrote:
gdjacobs wrote:MIDI in on a Raspi UART is viable, but kind of goofy. The ideal option would have a decent USB DAC and MIDI I/O, that or just use an X3M.

X3M would be the better option for most people, that is true. But I want to load my own SF2 files, or load up MUNT on here, this you can't do on a X3M.
Yeah, It's probably pretty goofy but hell it's worth a try. Other ras pi owners have claimed it worked fine for them, but then again I won't know until I build one myself.


You can if you use the X3M as the DAC and MIDI input for your Pi.


I mean sure, if you already have one laying around, but that thing is hecka expensive if all I'm using it for is a DAC and MIDI interface.
Right now for testing I'm using a HDMI audio extractor as the DAC and a Roland UM-ONE for midi. The built in DAC is ok, but it's not properly amplified (like at all).

The wiring half of this project is only for those that want a way to mount the pi internally and for ideally as cheaply as possible.
The software half should work with almost whatever you want.
Last edited by t9999clint on 2019-3-17 @ 12:44, edited 1 time in total.
User avatar
t9999clint
Member
 
Posts: 157
Joined: 2014-10-07 @ 14:08
Location: Edmonton, Canada

Re: WavePi: Use Raspberry pi as a MIDI Daughterboard

Postby t9999clint » 2019-3-17 @ 12:38

So I've done some testing with Raspbian and Fluidsynth and have the software 90% working at this point. At least for a first draft. I'm gonna do a bit of a brain dump here so I don't forget what I did later, a lot of this probably won't make sense so sorry for that.

The steps are fairly simple. Later I'll write up a script to automate most of it. I'll also try my best to make it platform agnostic (should work on anything based off debian)

    1. Install raspbian LITE to a sd card. NO GUI VERSION PLZ (we need as much ram as we can get)
    2. run all software updates
    3. use raspi-config to force either HDMI or analog jack for the built in audio. If using a different dac, then specify the default alsa device to match the new device.
    4. install fluidsynth
    5. figure out the client numbers for the midi interfaces you want aconnect to use by running: aconnect -o
    They are usually 20:0 and 128:0
    6. Extra steps to get the serial 2 midi stuff working, skip if your just using a usb based midi interface - I haven't done this bit yet but it's well documented over here... http://www.samplerbox.org/article/midiinwithrpi
    7. copy over your soundfont *must be smaller than 85% of your total ram*
    8. write shell script to run on startup. I just set /etc/rc.local to launch it. Later versions will have this wrapped up as a proper service.
    in the script...
    Code: Select all
    fluidsynth -R 1 -C 0 -is -r 44000 -o synth.cpu-cores=4 -o synth.polyphony=999 --audio-driver=alsa --gain 0.1 /home/pi/KOR\ Soundfont\ -\ GM\ basic\ 0.5.sf2 &
    sleep 180
    aconnect 20:0 128:0
    replace soundfont with whatever you copied over in step 7 and aconnect client numbers with what you got in step 5.
    9. reboot and pray to your god of choice...
    10. plug it in to your retro rig and see if it's making sweet sweet midi music. I like to test with Tyrian2000
User avatar
t9999clint
Member
 
Posts: 157
Joined: 2014-10-07 @ 14:08
Location: Edmonton, Canada

Re: WavePi: Use Raspberry pi as a MIDI Daughterboard

Postby dreamblaster » 2019-3-17 @ 13:28

Hi t9999clint,

nice idea : MCOBit has done such project in various incarnations : See this video : https://www.youtube.com/watch?v=_VYdw-AfNGc&t=213s
it runs MUNT and soundfonts. He also tried the setup with X3M, here you can see the internals : https://www.youtube.com/watch?v=gIkoM0iPrbU
Have a look at this thread for some inspiration and history : viewtopic.php?f=9&t=58174

gdjacobs wrote:You can if you use the X3M as the DAC and MIDI input for your Pi.

Yes, X3MA can be used: Note there are 2 X3M variants :
X3MA : usb audio + 54 voice MIDI synth : https://www.serdashop.com/X3M
X3MB : 81 voice MIDI synth (no USB audio) : https://www.serdashop.com/X3MBuran
X3MA is the one suitable for this. In this application you just don't use the built in synth.

I will be publishing about a pi related project soon (but still changing concept now and then, i prefer to wait until it works):
It will be a hardware solution + 3d print enclosure, to accommodate for buttons and display.

I will be following your thread with interest, t9999clint, especially for the software side :
Software wise, all variants will work quite similarly, so it could make sense to achieve some 'compatibility'.
Visit http://www.serdashop.com for retro sound cards, video converters, ...
OPL2LPT, OPL3LPT, X2, S2, S2P, MCE2VGA, ... many projects !
Special vogons LPT bundle : https://www.serdashop.com/Parallel-port-retro-sound-bundle
Thanks for your support !
dreamblaster
Oldbie
 
Posts: 679
Joined: 2015-1-18 @ 19:34
Location: Belgium

Re: WavePi: Use Raspberry pi as a MIDI Daughterboard

Postby t9999clint » 2019-3-17 @ 17:04

Thanks a ton Dreamblaster! I don't know how I haven't found that while I was researching for this project. A tone of useful code snippets in there.

I'm more of a software guy than a hardware guy so that's the approach I'm going to be taking with this. I'm glad to see that he was able to work through most of the issues that I was kind of worried about, I now have a few more interesting ideas that I'd like to incorporate into this.

Once I have something more polished I'll set it up on a github to keep things better organized. One of the ideas I had when I was first planning this out was to make a 3d printed case for the pi that looked like a MT-32, now that I see that the scripts for a LCD screen is already done then I'm definitely gonna try something like that. I was debating on rather or not I'm gonna script this in python, but it looks like that that decision was made for me now that there's an existing code base for this.

I like the idea of custom compiled binaries to reduce cpu overhead, but I don't see that being very portable (I want this to run on almost anything), so I'm gonna leave that part out for now. If I do implement that then I will have it dynamically compile fluidsynth and munt as part of the installation script. I've seen this done well with other projects, but I've also seen that this can be a GIANT timesync if you're not careful.

Now that there's already code for me to start from, the thing I want to work on next is getting the software listen to sysex messages to switch presets just like Falcosoft's MidiPlayer does. The lcd code I seen there should be easily modified to do this for me.
User avatar
t9999clint
Member
 
Posts: 157
Joined: 2014-10-07 @ 14:08
Location: Edmonton, Canada

Re: WavePi: Use Raspberry pi as a MIDI Daughterboard

Postby Scali » 2019-3-17 @ 17:13

root42 wrote:1. to run MUNT on the PI and have a MT32.
2. for fun and giggles. Aka learning.


3. To run MAME on the PI and have a Yamaha FB-01/IBM Music Feature Card :)
Scali
l33t
 
Posts: 4330
Joined: 2014-12-13 @ 14:24

Re: WavePi: Use Raspberry pi as a MIDI Daughterboard

Postby t9999clint » 2019-3-17 @ 18:15

Scali wrote:
root42 wrote:1. to run MUNT on the PI and have a MT32.
2. for fun and giggles. Aka learning.


3. To run MAME on the PI and have a Yamaha FB-01/IBM Music Feature Card :)


I've never even heard of that thing until now. I love how crunchy it sounds with it's bass instruments. I'm totally adding it if I can figure out how.
https://www.youtube.com/watch?v=oqIOTwUjlks
User avatar
t9999clint
Member
 
Posts: 157
Joined: 2014-10-07 @ 14:08
Location: Edmonton, Canada

Re: WavePi: Use Raspberry pi as a MIDI Daughterboard

Postby Scali » 2019-3-18 @ 08:23

t9999clint wrote:I'm totally adding it if I can figure out how.


There's support for it in MAME. So I guess the main problem would be 'plumbing' to switch between MUNT and MAME on the midi input.
Should be possible with some kind of 'proxy' in between, which responds to SysEx messages, similar to Falcosoft's MIDI player.
The proxy will be connected to the physical MIDI port, and MAME and MUNT will be connected to virtual MIDI ports. The proxy will then forward the data to either MUNT or MAME.

I'm also working on IBM Music Feature Card emulation. I have a DOSBox patch that is currently good enough to run all Sierra games (and I don't think there are other games that support it), and output the data to a MIDI out port.
The IMFC onboard synthesizer is based on the FB-01. It has the same YM2164 synthesizer chip. It just has slightly updated firmware, which supports some SysEx commands that the FB-01 does not. My DOSBox patch translates these SysEx commands on-the-fly, so they work on a regular FB-01.

I've also made a 'SoftIMFC' TSR for real 386+ machines. This is similar to SoftMPU (based on the DOSBox emulation code), except it emulates the IMFC interface rather than an MPU-401. So when you load this TSR on a native DOS machine, you get IMFC compatibility, and it will output the MIDI data to an MPU-401 or SB-MIDI port. Connect it to a real FB-01, or an emulated one via MAME, and you're done.

Follow this thread for updates: viewtopic.php?f=32&t=9555
I plan to release a first version of DOSBox, MAME and SoftIMFC and some information on how to use it this week.
Scali
l33t
 
Posts: 4330
Joined: 2014-12-13 @ 14:24

Re: WavePi: Use Raspberry pi as a MIDI Daughterboard

Postby root42 » 2019-3-18 @ 08:34

Scali wrote:
root42 wrote:1. to run MUNT on the PI and have a MT32.
2. for fun and giggles. Aka learning.


3. To run MAME on the PI and have a Yamaha FB-01/IBM Music Feature Card :)


4. To run ScummVM on a Pi connected to a waveblaster header inside a PC with a fraction of the Pi's computational capabilities.

Edit: Maybe we can use the Waveblaster header to give vintage PCs WiFi capabilities...?
Soldering, retro game reviews and more on YouTube and Bonus videos
80386DX@25 MHz, 8 MiB RAM, Tseng ET4000 1 MiB, Jazz16, PC MIDI Card + SC55MkII + MT32, XT CF Lite, OSSC 1.6
User avatar
root42
Oldbie
 
Posts: 1200
Joined: 2018-1-27 @ 13:23

Re: WavePi: Use Raspberry pi as a MIDI Daughterboard

Postby t9999clint » 2019-3-18 @ 17:32

I revised the schematics to help them make more sense. (still pretty ugly tho)

Scali wrote:There's support for it in MAME. So I guess the main problem would be 'plumbing' to switch between MUNT and MAME on the midi input.
Should be possible with some kind of 'proxy' in between, which responds to SysEx messages, similar to Falcosoft's MIDI player.
I'm trying to script it that way right now. I'm probably even going to use the same sysex messages.
Then have a series of config files for each preset.
Basically exactly the same way as MidiPlayer.

root42 wrote:4. To run ScummVM on a Pi connected to a waveblaster header inside a PC with a fraction of the Pi's computational capabilities.

Edit: Maybe we can use the Waveblaster header to give vintage PCs WiFi capabilities...?
The only pins on a wavetable header are for audio, power and midi data out. I'm not sure what your asking is possible.
User avatar
t9999clint
Member
 
Posts: 157
Joined: 2014-10-07 @ 14:08
Location: Edmonton, Canada

Next

Return to Sound

Who is online

Users browsing this forum: carlostex, knowledge [bot] and 1 guest