Raspberry Pi Synthesizer Projects

If not for Strawberry Fields Forever, I would probably not have looked into the Mellotron. The introduction to Strawberry Fields Forever was played on a Mellotron using the flute voice. (It appears that Paul McCartney owns that Mellotron.) This is a link to a good introduction to the Mellotron: https://flypaper.soundfly.com/produce/how-mellotrons-work-and-what-makes-them-so-special. Samples of Mellotron voices are available to download online and they can be played on a type of music synthesizer called a “sampler”. A number of music synthesizers can be built around the Raspberry Pi minicomputer. I had worked with a Raspberry Pi (RPi) minicomputer to run RetroPie (an arcade game simulator) in the past, so I looked at music synthesizers based on the Raspberry Pi and I found a number of interesting projects.

The First Project Was A Mini Synth That Can Run Bristol (For short, Synth A)

This is a basic capability of the Raspberry Pi version 3 computer. Searching for “synth” in the standard Raspberry Pi Operating System (Raspbian) will bring up a number of synthesizer programs including Bristol that emulates a large number of synthesizers including Moog.  Only the standard setup for the Raspberry Pi computer was required for this project.

Parts List for Synth A:

Hardware:

  • Raspberry Pi 3
  • 7 layer case with fan
  • SD Card (Class 10, 32 GB)
  • Midi USB controller AKM320 keyboard
  • Roccat USB audio interface NOT USED (Does not work with this configuration. Works well on VAIO pc.)
  • USB keyboard and mouse
  • HDMI monitor or VGA monitor with HDMI to VGA converter
  • DSO138 oscilloscope (optional)
  • 3.5mm audio male to 2 female splitter with one connection to 808 speaker and other to DSO138 oscilloscope via male to male 3.5 audio male cables (optional)

Synth A hardware setup:

  • RPi 3b
  • Power input (Switched UBS Power Supply)
  • HDMI out to HDMI to VGA converter to Sony VGA monitor
  • 3.5mm audio jack to”808” speaker
  • (May split sound output to DSO180 oscilloscope)
  • Switched 4 port UBS extension to:
  • AKM320 Midi Keyboard,
  • Jelly Comb UBS keyboard and
  • UBS Mouse

This project looked relatively uncomplicated.

The qualification “relatively” is there because to get Bristol to send a sound signal to the Raspberry Pi output, you need to start up the Raspberry Pi computer and type the following at the Raspbian prompt:

              startBristol –midi alsa

              qjackctl

In the qjackctl program’s AUDIO tab, connect “bristol” to “system”.

In the ALSA programs tab, connect “20AKM320” (keyboard) to “128 bristol”. This enables the MIDI keyboard. (Otherwise, the QWERTY keyboard can be used.)

(Note that Bristol seems to crash easily.)

Here’s the long story of the rest of Synth A’s initial software:

I added the following synthesizer software to the Raspberry Pi:

1. Aeolus-0.9.6-1

This is a synthesized pipe organ and a good program.

You need to start qjackctl before starting Aeolus then click the MIDI button in Aeolus and click one or more boxes in the keyboard window and then select the organ voices.

Last, configure the qjackctl connections for Aeolus similar to connections for Bristol, above.

In Aeolus, click the MIDI button and click keyboards for keyboard levels I, II, III and P (pedals) in slots 1, 2, 3 and 4.

In Keyboard I, click I&II and/or I&II to use 1, 2 or 3 keyboards.

Then configure qjackctl.

Aeolus works well and sounds good.

2. csound-1:6.12.2~dfsg-3.1 is a versatile sound synthesizer software program but it is a very complicated and learning intensive scripting language. I removed the program and removed qsoundqt which is a Graphical User Interface for the program csound.

3. din-5.2.1-6 which is a simple sound generator. I found DIN aptly named in that it is noisy.

When you find the program, click “I am a donor” to start. Start qjackctl and in the AUDIO tab connect DIN to system. DIN uses the QWERTY keyboard to make notes.

Once started, I could not stop DIN from running, so I typed: “ps aux 1 grep din”

This showed that DIN was process “2038”. I typed “kill 2038” and DIN stopped.

I then removed the DIN program.

4. fluidsynth-1.1.11-1 is a real time MIDI synthesizer.

Qsynth (a graphical front end for fluidsynth) is a good simple synthesizer.

In Qsynth, to choose an instrument, you need to select an engine such as Qsynth, Qsynth1, Qsynth2, up to Qsynth16.

For a given engine, you need to click on “Channels” then right click on ln 1 and click on edit

Choose an instrument in the next window (may double click) and click ok.

You can choose up to 16 simultaneous instruments, one for each of 16 engines.

5. 11-scope-0.2.1-3+bl is a DSSI plugin GUI oscilloscope.

The program gave the error “Invalid desktop entry file: ‘/ust/share/applications/11-scope.desktop’” and was removed.

Note: To remove a program and unnecessary associated programs, (in this case, Oscilloscope) type the following at the Raspbian prompt:

              sudo apt-get remove ll-scope

              sudo apt autoremove

6. Horgand is a GUI synthesizer that works but has an unacceptable latency. I removed Horgand.

I will keep Bristol, Aeolus and Qsynth (fluidsynth).

I then installed General SoundFont from MuseScore (full version) “musescore-general- soundfont-lossless-0.1.4-1″

but this made qsynth unstable. (Soundfont files are in /usr/share/sounds/sf2 and /usr/share/sounds/sf3).

I removed “MuseScore…..” using sudo rm –v /usr/share/sounds/sf2/ musescore-general- soundfont-lossless-0.1.4-1. Qsynth was then stable but only one channel instead of sixteen appeared to be selectable.

I removed “qsynth and /usr/share/sounds/sf2/FluidR3-GM.sf2” and “TimGM6mb.sf2” and then I reinstalled qsynth:

“fluild-soundfont-gm-3.1.5-1, fluidsynth-1.1.11-1” and          “libfluidsynth1-1.1-11-1”.

Finally, I decided to do a full clean install and reinstalled the backup image of 020120 that included only Bristol, then installed Aeolus and installed fluidsynth and qsynth. All three now work well.

Final software for Synth A:

  • RPi
  • NOOBS (“New Out of Box Software”)
  • Raspbian OS
  • SD Card formatter
  • VNC Viewer (Download and install VNC Viewer for Raspberry Pi)
  • Aeoulus
  • Bristol
  • Qsynth (fluidsynth)

These are the step-by-step Synth A software startup procedures:

Power on the RPi computer, monitor and 4-port switch. Turn on the speaker.

Bristol

From the RPi desktop:

Click on the terminal icon.

Type, ”startBristol –dx midi alsa” to open “dx synthesizer”.

Note: -dx opens the Yamaha DX-7 synthesizer. –voxM2 opens the vox continental Super300/II.

Minimize the terminal with the Ú symbol.

Open another terminal and type, “qjackctl” to open the JACK AUDIO CONNECTION KIT window.

Click “Start” and “Connection”.

In the Connection window, AUDIO tab, click bristol and system and then click connect.

In the ALSA tab, connect 20:AKM320 to 128:bristol.

Minimize the connections and the main qjackctl windows.

Aeolus

From the desktop:

Click on the RPI symbol and in the drop down menu click Sound & Video then Aeolus.

Open qjackctl. In the AUDIO tab, connect Aeolus to system.

In ALSA connect 20:AKM320 to 128:Aeolus.

In the Aeolus graphic, click on the MIDI button.

In the keyboard window, click on P, I, II and III in each of four different horizontal boxes.

Click on a “stop” in each keyboard level of the graphic and click on I+II and I+III for all keyboards to be active.

QSYNTH

From the desktop:

Click on RPi/Sound & Video/Q Synth.

Open qjackctl. In the AUDIO tab, connect qsynth to system.

In the ALSA tab, connect 20:AKM320 to 128:FLUIDsynth(1536).

This activates the Yamaha Grand Piano sample.

To choose another instrument or “Channel” click on Channels.

In the channel window, click on the top channel 1 and then right click and click on “edit”.

In the next window, double click on an instrument to choose it.

To add a channel, click the green + and click OK to add the new channel 2 to the existing channel 1.

You may open up to 16 channels.

Again In qjackctl, in the AUDIO tab, connect qsynth2 to system.

In the ALSA tab, connect 20:AKM320 to 1139:FLUIDsynth(QSynth2)

Both channels are now active with QSYNTH2 initially using the default instrument in channel 1, Yamaha Grand Piano.  You may change instruments in QSYNTH2 using same edit procedure above.

To shutdown, close any programs and click RPi/Shutdown/shutdown.

Turn off the hardware.

The Second Project Is An Implementation Of The SamplerBox Synthesizer (For short, Synth B1)

Using the program Disk Imager, write the SampleBox image to a formatted 32GB micro SD Card and insert the card in the Raspberry Pi 3 with the same hardware setup as in Synth A above. You may also need to expand the useable space on your micro SD card since most of the space is “unallocated”.

Login: root

Password: root

Type “halt” to shoutdown.

Note: You need to be able to have a midi keyboard with a “program” button to easily change the sample being played or you need to build the SamplerBox1 hardware module described below to run SamplerBox1 as it was intended.

I copied the Mellotron Flute file “1 Mellotron_flute” to the SD card. (Note that the simplest naming format for the file is “number space instrumentname” and plugged the SD card (I named “SD Card2”) into the USB adapter.

Note: Only when the HDMI cable is detached from the monitor is the midi keyboard is active.

And note:  The Mellotron does not initially sound like the Mellotron flute in Strawberry Fields. It needs to be two octaves below the default octave.

After playing a sound file with the SD Card in place, the system will play a sound file even if the SD card is then unplugged, suggesting that a sound file is stored in the SoundBox image is being played but if the HDMI is unplugged before the SD Card is in place, no sound is heard. Also note that if the HDMI cable is reattached, you need to shutdown Synth B1 and restart it to get the monitor to be active.

To run SamplerBox1 as it was designed and to select instruments from SD Card 2, rather than only the two that are loaded in the Samplerbox software image, you need to build the SamplerBox hardware e.g. a three character readout and two switches. The software was written to this hardware configuration. See https://www.samplerbox.org for all the details about the original SamplerBox (“Samplerbox 1”) and what is required for the hardware.  (See Figure 1, Original SamplerBox site).

Figure 1. Original Samplerbox Site

I do not plan to pursue SamplerBox 1 since Samplerbox 2 has a number of enhancements to the SamplerBox 1 features.

The Third Project Is An Implementation Of The SamplerBox2 Synthesizer (For Short, Synth B2)

SamplerBox2 behaves like Samplerbox1 but has more features and is more configurable.

Unlike SamplerBox1, Samplerbox2 will support a monitor, keyboard and mouse via HDMI and not interfere with music being played at the same time, so you can look at the boot sequence and software for SamplerBox2 when the program is running. For my configuration, no changes to the .img file for SamplerBox2 were required. You may, at some time, want to change the configuration.txt file for SamplerBox2.

If so, in Raspbian on the Raspberry Pi:

To change the directory, type, “cd \(directoryname)” e.g. “cd \root”

To look at directory content, type, “ls”

To view a file (like configuration.txt), type, “nano (filename), e.g. “nano configuration.txt”

To exit nano, type “CTRL x” (shown as ^X)

Documentation for SoundBox2 (Synth B2)

See: http://homspace.xs4all.nl/homspace/samplerbox/index.html and  http://www.nickyspride.nl/sb2. (See Figure 2, Samplerbox2 site). These sites have all the details required to download the software and assemble Synth B2 and address the configuration and hardware modifications to support a 16×2 LCD readout and three switches to  select and change parameters such as the sample instrument and volume level.

Figure 2. Samplerbox 2 Site

I redrew the original wiring diagrams (see Figure 3) to conform to the layered case I selected (see Figure 4).

Figure 3. Original Samplerbox 2 Wiring Diagram
Figure 4. Redrawn Wiring Diagram

The top layer holds the LCD readout and the three control switches. The middle layer holds two potentiometers to adjust the brightness and contrast of the readout and the lowest layer holds the Raspberry Pi. (See Figure 5, Rack Cluster Case for the Raspberry Pi.)

I bought a couple of these cases since I needed two bottom layers: the bottom layer worked best to cut out a rectangle for the display and use as a top layer in my module. The middle layer is fine, as-is.

Figure 5. Rack Cluster Case

I assembled the materials for SamplerBox2 and a custom layered case and assembled those parts. I call the completed assembly of hardware and case the “Samplerbox2 Module”.

(See Figure 6, the Samplerbox2 Module and Figure 7, the module attached to the other system components).

Figure 6. The Samplerbox2 Module

Required Hardware:

  • Samplerbox2 Module
  • 5v power supply
  • USB hub
  • MIDI Keyboard
  • Micro SD card 2.1 to RPi
  • Micro SD card 1.2 to USB micro SD card reader
  • External sound card to volume control to speaker

Note that the Roccat JUKE external sound card works with SynthB2. It needs an in-line volume control since it is too loud without it. Samplerbox2 plays to an “808 Audio XS Wireless Bluetooth Stereo Speaker” via an inline volume control and the output is split to an optional DS0138 Oscilloscope.

In addition:

  • 5v power supply
  • USB hub
  • MIDI Keyboard
  • QWERTY Keyboard and mouse
  • LCD monitor

Required software:

  • I installed the SamplerBox 2 .img file on a micro SD Card I named, “SYNB2.1”. I then used Image Writer to make a backup of SD card SYNB2.1.

The default configuration of SamplerBox2 is set to “external sound card”. Note that SamplerBox2 also works with the audio out directly from the Raspberry Pi.

Figure 7. Samplerbox2 System Components

After assembly of the Samplerbox2 module, all buttons and potentiometers work as expected. The readout works well and the RPi LEDs behaved normally. With the SD card loaded with samples in a USB SD card reader, the unit played the SAW WAV file but when switched to the Demo1 WAV, no sound was heard and when switched back to SAW it did not play unless rebooted.

After playing these samples, the system may mute the USB connectors. I was able to correct that by pressing the red (up) and black (down) switches at the same time or just cycle through the blue (program) switch options.

The Demo1 WAV is lower in volume than the SAW WAV, so I needed to adjust the volume.

The blue switch cycles through selecting Volume, Sample, Chord, and other options.

SamplerBox2 was not designed to use an SD card in an SD card reader. (Only Samplerbox1 is designed that way). For Samplerbox2 you must use a USB thumb drive to store the sample sets.

I wrote my sample sets on a USB thumb drive and the system recognized the samples and played them with no problems. There were a few “07 Empty Preset” readouts. I suspected that the format of the sample was not correct or the sample set’s detinition.txt file needed editing.

I continued to find samples on the net and added more samples to the SD card. For example, one group was:

  • 25 Hammond_Rock
  • 26 Hammond_Slow Leslie
  • 27 Hammond_Reed
  • 28 3:28 Hammond_Rock
  • 29 4:29 Hammond_Rock
  • 30 Hammond_Slow Leslie
  • 31 Hammond_Rock

Samples 25-27 had no velocity. 28-31 had velocity. (Velocity is the MIDI parameter that makes a sound louder if you press a midi key faster.)

I remove samples 25, 26 and 27 and kept 28-31.

In the definition.txt for those samples, I removed “% voice=1,2,3,4” so the voice and number did not appear in the LCD display of the name of the sample.

The definition.txt tells Samplerbox how to process the sample. The following link lists parameters that can be included in the definition.txt document:

https://samplerbox.readthedocs.io/en/latest/Sample_Sets/index.html#definition-files .

A typical sample (for 0 Mellotron_MC2_Flute) looks like this:

The definition for this file is: %notename.wav

The sample for 28 Hammond_Rock 2 looks like this:

The definition for this file is:

                                                          %%velmode=accurate

                                                          HammondRock-*%notename.wav,%voice=3,gain=.5

I then added more samples using a USB microphone to capture the sounds. (See Figure 8, Final List of Samples).

See Figure 8. Final List of Samples

There are fifty nine samples in all. Forty nine samples were downloaded from various internet sites. Ten samples were recorded using a USB microphone to capture the sounds and the free trial of Acoustica 7 – 64 Bit to edit the WAV files. The last three were excerpts from Freddy Mercury singing “aaa-ooo” in a recorded concert.

Using the first sample, 0 Mellotron_MC2_Flute set down two octaves, I can now play the introduction to Strawberry Fields Forever and it sounds like the record. This is the introduction played on the SamplerBox1 synthesizer and Mellotron flute sample: https://www.youtube.com/watch?v=yz7GZ8YOjTw .

The Fourth Project, Zynthian v3 Is A Standalone Synthesizer Kit.

Zynthian v3

Zynthian v3 is a synthesizer based on the Raspberry Pi 3. I chose a kit with all parts that required assembly but no soldering. I copied the Zynthian .img file to micro SD cards I named “Z1” and “Z1 Copy” then assembled the Zynthian kit v3 with no difficulty. Zynthian works as represented. (See Figures 9 and 10, Zynthian.)

See the following for detailed information on Zynthian:

https://shop.zynthian.org

and

https://wiki.zynthian.org/index.php/Zynthian_Wiki_Home

Figure 9. Zynthian Top
Figure 10. Zynthian Back