Next  |  Prev  |  Top  |  REALSIMPLE Top

MIDI Synthesizer Test Patch

The example synth is loaded into pd like any plugin-wrapper. A manually written test patch (cpgrs-help.pd) is shown in Fig.16. Note that the standard MIDI-synth control parameters (freq, gain, gate) are handled behind the scenes and do not appear among the plugin GUI controls.

Figure: Test patch for the pd synth plugin cpgrs.pd generated by faust2pd based on cpgrs.dsp in Fig.15.
\resizebox{4.3in}{!}{\includegraphics{\figdir /cpgrs-help.eps}}

To drive our MIDI synth, we need a source of MIDI data. Perhaps the simplest resource for this purpose is the Virtual Keyboard (vkeybd), which is standard in Red Hat Fedora 6, and in the planetccrma-menus at ``Applications / Planet CCRMA / MIDI / Vkeybd''). Figure 17 shows a screen shot of the Virtual Keyboard with its key-range and velocity controllers displayed (menu item ``View / Key/Velocity''). The velocity controller sets the gain parameter, mapping MIDI velocity (0-127) to the unit interval (0-1). The key-range controller transposes the keyboard by octaves. Pressing a key determines, together with the key-range, the freq parameter in our synth. Pressing a key also sets the gate parameter to 1, and releasing it sets gate to 0. The ADSR envelope is triggered when gate transitions to 1, and it begins its ``release'' phase when gate transitions to 0, as is standard for ADSR envelopes triggered by a keyboard. Note that the bottom two rows of ASCII keyboard keys are mapped to virtual-keyboard keys, enabling the playing of chords in real time on the regular computer keyboard.

Figure 17: The Virtual Keyboard (MIDI source).
\resizebox{4in}{!}{\includegraphics{\figdir /vkeybd.eps}}

Figure 18 illustrates the MIDI tab of qjackctl's Connect window after connecting the Virtual Keyboard MIDI output to pd's MIDI input.17

Figure 18: JACK MIDI connections routing MIDI from the Virtual Keyboard (vkeybd) to pd's first MIDI input port.
\resizebox{4in}{!}{\includegraphics{\figdir /jack-midi-connect.eps}}

To play back a MIDI file (extension .mid), a nice way is to open it in Rosegarden (``Applications / Planet CCRMA / Sequencers / Rosegarden'') and connect Rosegarden's MIDI output to pd's MIDI input as above. (You can still play along on the Virtual Keyboard.)


Next  |  Prev  |  Top  |  REALSIMPLE Top

Download faust.pdf

``Signal Processing in Faust and PD'', by Julius O. Smith III,
REALSIMPLE Project — work supported by the Wallenberg Global Learning Network .
Released 2010-07-29 under the Creative Commons License (Attribution 2.5), by Julius O. Smith III
Center for Computer Research in Music and Acoustics (CCRMA),   Stanford University
CCRMA