# Online music jam/Software synthesizer
## Learning Task

This learning resource look at the interface between a MIDI signal and sound generation. You will learn to create "key pressed" events with the keyboard or an Open Source Digital Audio Workstations DAW (like LMMS) and create the corresponding sound with software synthesizer on a PC. The example is performed on the OpenSource Linux Operating system with OpenSource software only and is designed in way that musicians can learn about the underyling concepts without buying software or hardware. Furthermore learners should be able to reproduce the learning example with available software for different Operating systems (Jamulus, Musescore is available for different Operating systems). In the first section the examples are elaborated for Linux operating system and could be transfered to other Operating systems in a similar way. Current operating systems are able to work with USB Midi Controllers. If not just used an existing MIDI file to create the MIDI events for this learning example.

### Requirements

If you do not have a MIDI keyboard, digital drum kit or digital wind instrument to create live MIDI events, then it would be helpful to have a
* an Open Source digital audio workstation like LMMS,
* a freely available MIDI song e.g. with drum track a bass track and keyboard track. Choose a MIDI track according to your "taste of music". This is file serves just as a method to create MIDI events without having a digital instrument available.
An other option is to use the OpenSource notation software
* e.g. the OpenSource software Musescore and create a few notes,
* export the notation to a MIDI file and
* assign different sounds to track with Musescore
The following example assumes you have
* MIDI Keyboard,
* Software Synthesizer and a
* Online Jam Software (here Open Source Jamulus is used as an example) for distributed practicing of musicians located at different places

## History of this Subpage

This contribution was made to the Jamulus Github Repository by Volker Fischer. This learning focuses on the underlying concepts that are used by Open Source software Jamulus and goes beyond the current implementation of available Open Source software to optimize the implementation Online Music Jam Software. The learning resource follows the Open Community Approach to support musicians for keeping alive their joint cultural activities durch COVID-19.

## Linux

We will elaborate the concept of playing a software synth on Linux as example and transfer that to other operating systems (e.g. Windows, MacOSX).
* (Hammond Organ Synth) As an example we talk open source software synth setBfree, which is a hammond organ emulator that outputs through JACK on Linux.
* (MIDI Keyboard) The MIDI keyboard is used to generate the key pressed events, that are transmitted through a USB-MIDI interface to Linux system and the Synthesizer setBfree generates the corresponding tone for the pressed key. In general the MIDI keyboard can also be replaced by a digital wind midi controller, that does the same but the tone is dependent on how the musician blows air into the digital wind controller.
* (Connector to Jamulus) You may hear the audio output of your Linux system on your speakers but the audio output may not be use as input for your Jamulus session. So another step is to connect the audio out to Jamulus client (with QJackCtl).

### General Information about ALSA, JACK and MIDI

First of all we explain a few basic concepts on Linux to use MIDI and Audio together.
* ALSA is the basic to connection to the hardware, i.e. the soundcard and the midi controller for the keyboard.
* JACK is build on top of ALSA and uses ALSA for the audio output. It provides a adequat environment for music production on Linux.
* Synthesizer like the Hammond Organ emulator setBfree connect to JACK for audio output.
* Jamulus connects to JACK.

### Requirements for Using Software Synths in Jamulus on Linux

For ALSA2JACK MIDI (a2jmidid) connection it is necessary to install the a2j package. Furthermore we use in this example a simple Hammond organ emulator setBfree in this example. Replace setBfree by your favorite Linux synthesizer. Both packages a2jmidid and setbfree can be installed via your package manager or e.g. on Ubuntu/Mint with apt-get commands:

### Connecting ALSA, JACK and MIDI for a Synth for Jamulus

Now we look an the workflow to use the whole infrastructure in Jamulus.
* (Jamulus Installation and JACK) Use the install script for Jamulus on Linux or install Jamulus with the manual in the wiki. With this installation we have JACK and QJackCtl installed for Jamulus.
* (ALSA to JACK - MIDI) Next we must create a connection from ALSA to JACK to route the MIDI input from the keyboard to the Hammond Emulator setBfree.
** (Command Line: qjackctl) For this step you can start JACK-Control (QJackCtl) from the command line by qjackctl,
** (Command Line: a2jmidid -e) Then you launch the ALSA2JACK MIDI connector with command: a2jmidid -e. As long as this connector runs in the shell the a2j connection interface is visible in QJackCtl.
** (QJackCtl: ALSA-MIDI) Connect your USB MIDI as input to MIDI through in the ALSA-MIDI tab of QJackCtl. Now the midi events from your keyboard reach JACK and are ready to connect.
** (Start Synth) Start the Hammond Synthesizer too e.g. from the command line with setBfree. You will see the setBfree graphical user interface GUI (see http://setbfree.org/gui_3d). Press with your mouse on the visualised organ keyboard to test if the synth generates an organ sound on your speakers.
** (QJackCtl: JACK-MIDI) Now we can connect a2j in JACK-MIDI as input to the synth setBfree, that generates the sound as output for each key pressed on the keyboard. Keep in mind that you can connect synths if they are started and visible for QJackCtl. So you can connect after starting the Hammond Emulator setBfree, i.e. connect a2j to the setbfree if you also see the Hammond Synth SetBFree in QJackCtl.
** (Test Software Synth with MIDI Keyboard) If you have speakers attached to your Linux Computer you would hear the emulated Hammond sound on your Linux PC for all the keys your press on your MIDI keyboard. If you just want to play the software synth with your keyboard you are ready to play from here. The only remaining step is to connect the audio to Jamulus.
* (Synth to Jamulus - Audio) In the previous step we connected the MIDI signals from your keyboard to the MIDI input of JACK via a2j - MIDI through connection. Now JACK the MIDI which tell JACK which keys are pressed on the keyboard. Now create an audio connection in JACK (i.e. the generated Hammond sound of the synth). We connect the Hammond Emulator setBfree output to Jamulus. Therefore Jamulus must be started so that you see also Jamulus in the audio connection of QJackCtl. Now you can the audio output of the Hammond Emulator setBfree to the audio input of Jamulus in JACK.
In general QJackCtrl is used similar operations like for plugging in instruments in mixer and the mixer into an amplifier and the amplifier again to the speakers. Have fun with your other OpenSource synths like QSynth, ZynAddSubFX than can be installed on your Linux system and/or used within LMMS.