PHIL STONE

[polywavesynth]

a polyphonic synthesizer for Pure Data

Version 7.0

polywavesynth.gif

[polywavesynth] is a ready-to-use, CPU-cycle-stingy, OSC-addressable polyphonic "wave" synthesizer for Pd. The tag "wave" is used for want of a better (short) descriptor for the somewhat unusual mix of synthesis technologies employed, which is table-driven subtractive synthesis with a dash of FM.

You can hear some music I've made with this synthesizer here.

Download and Setup

Download the polywavesynth archive here.

After downloading, double-click on the .tgz file to produce the 'polywavesynth' folder.

(Pd-extended users only: Pd-extended is no longer supported by new versions of [polywavesynth]. You may download the last version compatible with Pd-extended (5.0) at this link.)

Pd requires 2 external libraries to use this object: mrpeach and ggee. (Coming soon: new version with *no externals required!)

If you don't have these libraries installed in your copy of Pd already, use the "Help->Find externals" menu item in Pd to download and install them. Be sure to pick the correct version for your platform, and be sure the libraries have been added to your search path (this is done automatically by "Find externals" if you have the "Should newly-installed libraries be added to Pd's search path?" item checked in the Preferences to this dialog).

NOTE: in the unlikely case that you are currently a user of a very early version of [polywavesynth] (2 or earlier), be aware that there are slight differences between version 3 (and later) presets and those of version 2. See here for more information.

[polywavesynth] Operation

It should be pretty easy to get a sound out of [polywavesynth] if everything is loaded correctly. Open the "polywavesynth" folder created above, and double-click polywavesynth_example.pd to get started.

Most controls should be familiar to those with subtractive synthesis and/or FM synthesis experience.

Anything in [polywavesynth] displayed in a "number2" box (the ones with ">" on their left edge) is an adjustable parameter, which can be saved and recovered using [sssad]. Normal number boxes are display-only. Most controls should be fairly obvious in function, with a few notes:

N.B.: [polywavesynth] implements its wave tables in a singleton. Therefore, you can have multiple [polywavesynth]s open at once, and only one set of tables will be allocated for all of them, with no conflict. However, if you close the first-opened patch that contains a [polywavesynth], the single instance of the tables will disappear along with it. This is an unavoidable side-effect of using singletons with a [closebang]-less Pd. If this happens, just close all patches containing [polywavesynth], and re-open -- the singleton will re-establish.

Specifications

Inlets:

  1. frequency of note in Hertz; initiates attack or release
  2. amplitude of note, between 0 and 1 (>0 = attack, 0 = release)
  3. external "mute" - note-ons are ignored when this is non-zero
  4. OSC inlet (see OSC implementation, below)

Arguments:

  1. synth name, used for OSC addressing and preset saving/loading (allows multiple polywavesynths to be used simultaneously yet controlled independently)
  2. number of voices
  3. voice stealing (0=off; 1=on)

Outlets:

OSC implementation tree:

  • /(synth name)
    • /controlmode --(value = 0: UI and OSC controls are per-voice; 1: controls are global)
    • /enable -------(value = 0: incoming note-ons are ignored; 1: all note-ons honored)
    • /gain ---------(value >= 0.0, though be careful with gain > 1.0)
    • /global
      • /pitchbend ----(value in cents)
      • /allnotesoff --(any value)
    • /note
      • /freq ---(value in Hertz, triggers or releases note, so should be sent last)
      • /amp ----(amplitude multiplier, 0.0-1.0; 0=release >0=attack)
    • /osc
      • /carrier
        • /wave ----(0=sine 1=square 2=ramp 3=pulse 4=triangle 5=noise)
        • /detune --(value in cents)
      • /mod
        • /wave -------(0=sine 1=square 2=ramp 3=pulse 4=triangle 5=noise)
        • /amount -----(0.0 - 1.0, modulation index)
        • /freq -------(0.0 - 1.0)
        • /ratorfreq --(freq. mode switch 0=frequency 1=ratio)
      • /env
        • /atk ---(value in msecs.)
        • /dec ---(value in msecs.)
        • /sus ---(0-100, percent of full amplitude)
        • /rel ---(value in msecs.)
        • /exp ---(envelope curve "exponent" -- see multicurveadsr-help.pd)
    • /filt
      • /freq --(value in Hertz)
      • /q -----(0=filter switched off -- reasonable values=between 0.1 and 1.0)
      • /env
        • /atk --------(value in msecs.)
        • /dec --------(value in msecs.)
        • /sus --------(0-100, percent of full amplitude)
        • /rel --------(value in msecs.)
        • /exp --------(envelope curve "exponent" -- see multicurveadsr-help.pd)
        • /fampscale --(0=filter opens fully; 1=scale filter opening to amplitude)
    • /pan
      • /position --(0=full left; 1=full right)
      • /speed -----(speed of transition to new position, in msecs., >=2)
      • /mode ------(0=random; 1=fixed)
      • Made panning equal-power

[polywavevoice~] Architecture

At the heart of each [polywavevoice~] is a pair of table-driven waveform oscillators, in a carrier/modulator configuration. Both carrier and modulator can be switched between five simple waveforms (sine, square, pulse, sawtooth, triangle) or a random-filled "noise" table. Modulation may be switched between rational (modulator can be a harmonic of the carrier, like in most commercial FM synthesizers), and free (useful for inharmonic sounds, or at very low frequencies, vibrato.) Note that the "freq" value is interpreted differently for the two modes -- either as selecting from a list of fixed ratios, or as a literal frequency.

The output of this wave generator is run through an envelope-controlled, variable-frequency and Q-factor low-pass filter. The envelope opens the filter to the frequency indicated by the "filter_freq." slider, scaled by the amplitude of the note. This behavior can be defeated by de-selecting "scale_to_amp" near the filter envelope controls; in this mode, the filter will open to full range for all notes.

The output of the filter is in turn passed through an amplitude envelope. Both the filter envelope and amplitude envelope have variable curves, and ADSR controls.

Finally, the output of the amplitude envelope is split and panned in one of two ways: either 1) fixed, the l/r balance set by a number between 0 (full left) and 1 (full right), or 2) a random value between l and r is chosen just before note attack, with a transition time set by the pan rate variable.

[polywavevoice~] is fairly thrifty with CPU cycles. It uses lookup tables for envelope curves, and each voice switches itself off when its amplitude envelope completes, so only voices actively playing consume CPU. Also, the enveloped filter in each [polywavevoice~] switches itself off if its 'Q' value is set to zero. So, if you really need more voices, don't have CPU cycles to burn, and don't mind giving up per-note enveloped filtering, set 'Q' to zero.

Polyphony

[polywavevoice~], an individual voice instance for this synthesizer, is compatible with [polypoly], which is a powerful object combining the replication features of [nqpoly/nqpoly4] with the allocation and management capabilities of [poly]. [polypoly] can clone a compatible object 'n' times, where 'n' is limited only by available CPU cycles. Using [poly], it automatically assigns a voice instance on attack, tagging it by frequency so as to be able to mark it as available on subsequent release. This makes it very easy to instantly create a polyphonic synthesizer as is done in [polywavesynth]:

[polypoly $2 $3 polywavevoice~ $0]

The first argument is for 'n', or the number of voices desired, and is controlled by [polywavesynth]'s second argument. High numbers give rich polyphony, but can also use more CPU. Stick a CPU meter (like [loadometer] in [polywavesynth_example]) in your patch, and watch it to see what kind of bandwidth you can get away with under various musical "loads"; adjust 'n' accordingly in the creation argument for [polywavesynth]. Trying to suck more CPU cycles than exist will lead to "interesting music", so be conservative with 'n'. Anecdotally, on my MacBook Pro, sustaining 64 notes simultaneously uses about 75% CPU.

The next argument tells the internal [poly] whether to use voice stealing, and is controlled by [polywavesynth]'s third argument.

[polypoly] allows up to four more arbitrary arguments, which are passed through to the object being cloned. [polywavesynth] currently uses only one of them to pass the $0 variable, which serves as a unique prefix to communicate GLOBAL parameters to all [polywavevoice~] voices of this [polywavesynth] instance.

When any message is sent to '$0-GLOBAL-allOff' (OSC: /(synthname)/global/allnotesoff), all notes currently attacked are released and deallocated from the voice-managing [poly] object). This is useful for quashing stuck notes, which can be caused by incomplete or unbalanced note messages sent to [polywavesynth].

State Saving

[polywavesynth] supports [sssad] state-saving. See the [polywavesynth_example] object for how to do it.

Migrating v2 presets to v3

[sssad]-saved presets made with version 2 [polywavesynth] will be missing a couple of lines needed for version 3 (and later) presets. Simply add the following two lines to each of your version 2 presets, and they will be compatible with version 3 and up. Be sure to replace "wav1" with the name of your synth (you'll know what this is because all the lines in your [polywavesynth] patch files start with it -- it's also the first argument to [polywavesynth]).

wav1/fampscale 1;
wav1/enable 1;

v4 OSC changes

A couple of OSC nodes used to be spelled in camel case (/allNotesOff and /ratOrFreq). All OSC nodes are now completely lowercase: /allnotesoff, /ratorfreq -- sorry for any inconvenience, but this is better for the long run! If you didn't use these OSC nodes across these versions, don't worry about this at all.

Credits

I built on a great deal of pre-existing Pd work to make this synthesizer.

I owe big thanks to Tom Erbe and a couple of his students, who designed some wonderful synthesizer emulations back in 2005. One of these in particular, Patrick Sanan's Minimoog, inspired me to experiment with making my own Pd synth. I started with the waveform data from Patrick's synth. Since his comments lead me to believe he got the band-limited table-generating code from Tom, I named my modification of this lifted code [erbe_tables] in Tom's honor.

Thanks to Hans-Christoph Steiner for his equal-power panning code.

Chris McKormick's "s-abstractions" taught me how to do GOP and more generally, how to organize my thinking about patches. I learned how to use [sssad] state-saving from his examples, too.

Frank Barknecht designed [polypoly] and [sssad] and [singleton], among a multitude of other useful Pd objects.

Areas for Improvement

I can only stand designing instruments for so long, and then I need to play them, so I sometimes take expedient shortcuts to get something functioning. As a result, this synthesizer could use improvement in some areas.

I highly encourage you to make your own improvements/customizations if you have some ideas -- or just use [polywavesynth] as a template for something completely different.

Please let me know (via the "contact" link at the top of the page) if you find any bugs or bad behavior. Also, I'd be glad to hear if you got any good use from this synthesizer.

Revision History

License

Everything in the polywavesynth download is released under the same license as Pd, with myself and others included as authors:

Copyright:

This software is copyrighted by Miller Puckette, Frank Barknecht, Phil Stone and others. The following terms apply to all files associated with the software unless explicitly disclaimed in individual files.

The authors hereby grant permission to use, copy, modify, distribute, and license this software and its documentation for any purpose, provided that existing copyright notices are retained in all copies and that this notice is included verbatim in any distributions. No written agreement, license, or royalty fee is required for any of the authorized uses. Modifications to this software may be copyrighted by their authors and need not follow the licensing terms described here, provided that the new terms are clearly indicated on the first page of each file where they apply.

IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

RESTRICTED RIGHTS: Use, duplication or disclosure by the government is subject to the restrictions as set forth in subparagraph (c) (1) (ii) of the Rights in Technical Data and Computer Software Clause as DFARS 252.227-7013 and FAR 52.227-19.

Phil Stone
https://pkstonemusic.com