VOGONS


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

Topic actions

First post, by t9999clint

User metadata
Rank Member
Rank
Member

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?cmd=_s- … HQXG&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 *edit, serial is done now*, 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...
super-rough-draft.png

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-11-28, 18:57. Edited 17 times in total.

My Youtube Channel: https://www.kor.ninja/
My Soundfont Project: K.O.R. Soundfont Project V.5.0
My Soundcloud Page: https://soundcloud.com/clint-theriault

Reply 1 of 206, by t9999clint

User metadata
Rank Member
Rank
Member

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* 😎 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.
- *DONE* LCD Code With button support. I2C 16x2 display (thanks ElBartoME!!)
- *not currently possible* look into using MAME code to emulate other synths (Yamaha FB-01 and Roland SC-55 😎 ).
- *In progress* 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)
- *DONE* Get a Raspberry Pi 4 B to test code on that. (thanks SheezNeez!!)
- *in progress* 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.
- *DONE* Make .img files for easy installation.
- 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).
- *too much code now, I'm probably going to stick with python* 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! 😀
- *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)
- *not needed, just use RasPi 4 dac* 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-11-28, 18:52. Edited 38 times in total.

My Youtube Channel: https://www.kor.ninja/
My Soundfont Project: K.O.R. Soundfont Project V.5.0
My Soundcloud Page: https://soundcloud.com/clint-theriault

Reply 2 of 206, by root42

User metadata
Rank l33t
Rank
l33t

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?

YouTube and Bonus
80486DX@33 MHz, 16 MiB RAM, Tseng ET4000 1 MiB, SnarkBarker & GUSar Lite, PC MIDI Card+X2+SC55+MT32, OSSC

Reply 3 of 206, by t9999clint

User metadata
Rank Member
Rank
Member

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.

My Youtube Channel: https://www.kor.ninja/
My Soundfont Project: K.O.R. Soundfont Project V.5.0
My Soundcloud Page: https://soundcloud.com/clint-theriault

Reply 4 of 206, by root42

User metadata
Rank l33t
Rank
l33t

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

YouTube and Bonus
80486DX@33 MHz, 16 MiB RAM, Tseng ET4000 1 MiB, SnarkBarker & GUSar Lite, PC MIDI Card+X2+SC55+MT32, OSSC

Reply 5 of 206, by t9999clint

User metadata
Rank Member
Rank
Member
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.

My Youtube Channel: https://www.kor.ninja/
My Soundfont Project: K.O.R. Soundfont Project V.5.0
My Soundcloud Page: https://soundcloud.com/clint-theriault

Reply 6 of 206, by gdjacobs

User metadata
Rank l33t++
Rank
l33t++

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.

All hail the Great Capacitor Brand Finder

Reply 7 of 206, by t9999clint

User metadata
Rank Member
Rank
Member
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-03-17, 04:39. Edited 1 time in total.

My Youtube Channel: https://www.kor.ninja/
My Soundfont Project: K.O.R. Soundfont Project V.5.0
My Soundcloud Page: https://soundcloud.com/clint-theriault

Reply 8 of 206, by jmarsh

User metadata
Rank Oldbie
Rank
Oldbie

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

Reply 9 of 206, by t9999clint

User metadata
Rank Member
Rank
Member
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 😉

My Youtube Channel: https://www.kor.ninja/
My Soundfont Project: K.O.R. Soundfont Project V.5.0
My Soundcloud Page: https://soundcloud.com/clint-theriault

Reply 10 of 206, by gdjacobs

User metadata
Rank l33t++
Rank
l33t++
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.

All hail the Great Capacitor Brand Finder

Reply 11 of 206, by t9999clint

User metadata
Rank Member
Rank
Member
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-03-17, 12:44. Edited 1 time in total.

My Youtube Channel: https://www.kor.ninja/
My Soundfont Project: K.O.R. Soundfont Project V.5.0
My Soundcloud Page: https://soundcloud.com/clint-theriault

Reply 12 of 206, by t9999clint

User metadata
Rank Member
Rank
Member

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...
    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

My Youtube Channel: https://www.kor.ninja/
My Soundfont Project: K.O.R. Soundfont Project V.5.0
My Soundcloud Page: https://soundcloud.com/clint-theriault

Reply 13 of 206, by dreamblaster

User metadata
Rank Oldbie
Rank
Oldbie

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 : Raspberry Pi 3 SoftSynth Box [Buildlog]

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, ...
DreamBlaster X2, S2, S2P, HDD Clicker, ... many projects !
New X2GS SE & X16GS sound card : https://www.serdashop.com/X2GS-SE ,
Thanks for your support !

Reply 14 of 206, by t9999clint

User metadata
Rank Member
Rank
Member

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.

My Youtube Channel: https://www.kor.ninja/
My Soundfont Project: K.O.R. Soundfont Project V.5.0
My Soundcloud Page: https://soundcloud.com/clint-theriault

Reply 16 of 206, by t9999clint

User metadata
Rank Member
Rank
Member
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

My Youtube Channel: https://www.kor.ninja/
My Soundfont Project: K.O.R. Soundfont Project V.5.0
My Soundcloud Page: https://soundcloud.com/clint-theriault

Reply 17 of 206, by Scali

User metadata
Rank l33t
Rank
l33t
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: IBM Music Feature Card/Yamaha FB-01
I plan to release a first version of DOSBox, MAME and SoftIMFC and some information on how to use it this week.

http://scalibq.wordpress.com/just-keeping-it- … ro-programming/

Reply 18 of 206, by root42

User metadata
Rank l33t
Rank
l33t
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...?

YouTube and Bonus
80486DX@33 MHz, 16 MiB RAM, Tseng ET4000 1 MiB, SnarkBarker & GUSar Lite, PC MIDI Card+X2+SC55+MT32, OSSC

Reply 19 of 206, by t9999clint

User metadata
Rank Member
Rank
Member

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.

My Youtube Channel: https://www.kor.ninja/
My Soundfont Project: K.O.R. Soundfont Project V.5.0
My Soundcloud Page: https://soundcloud.com/clint-theriault