## Ninereeds NRS04

By Steve Horne, 10 July 1999

This generator is a synthesizer, with the following features...

- ADSR envelope, with linear attack and exponential decay and release.
- Pitch bend.
- Thirteen basic waveforms.
- Fractal distortion of the basic waveform that varies with the envelope.
- Ability to produce a 'twin' note, detuned from the original.
- Support for ring modulation, amplitude modulation, frequency modulation and pulse width (or waveform centre) modulation based on an auxiliary input signal.
- Ability to store and choose from a number of 'programs' - essentially named instrument configurations.
- Support for partial external control - listens to 'command broadcast channels'.

A feature that some people may find novel is that this machine actually uses note-off commands. I may add some more precise timing controls to a future machine, but I find using note-offs much more convenient than providing calculated durations for every note.

However, if the sustain level is set to zero, and the release rate is set the same as the decay rate, there is no need to worry about note-off commands.

### History

September 3, 1999
  I've left this so long, I'm ashamed of myself. However, this version has...
  - A bug fix that initialises note volumes correctly.
  - A bug fix that allows the output to be sent to more than one effect - I really don't understand the mi::Work functions mode parameter, but ignoring it seems to have the required effect.
  - A bug fix that means square waveforms are now square - sorry if this breaks old tunes.
  - Optional optimisation of fractals and envelopes using precalculated lookup tables - warning - these do affect the end result, especially the fractal optimisation.
  - An internal modulator for FM, AM and PWM effects - allows modulator frequency to be relative to the note frequency - no modulator envelope yet, nor any controls to 'equalise the brightness over a range of notes'.
July 18, 1999
  Added some major facilities, including...
  - Ability to recieve from an AuxBus channel.
  - Ability to perform various modulations using the AuxBus channel.
  - Support for external control - listens for broadcast commands.
  - A program bank storing named instrument configuartions.
  This is by no means complete...
  - The modulations are only really good for special effects - some secondary oscilators and/or LFOs are needed.
  - Program changes and other externally driven changes to the sound are very abrupt, and tend to create clicks. Some kind of smooth transition is needed.
  - The ability to save and load program banks as readable text files, and possibly directly exchange them between machines, could be useful.
July 13, 1999
  Fixed some very silly defaults, added an amplitude control for the twin note, and added an extra waveform (based on double triangle, but adjusted to give it some even harmonics).

  Nothing major, no compatability issues, but fewer irritations.

July 10, 1999
  First Release

### Global Parameters

This machine does not have any global parameters.

### Track Parameters

The track parameters are...

Note
  Triggers new notes. A note off here stops the note, by triggering the release phase.
Bend Note
  Starts a pitch bend, specifying the target note. A note off here stops a pitch bend, so that the note continues at whatever pitch it reached.
Volume
  How loud to play the note.

### Attributes

This machine does not have any attributes.

### Edit Dialog

To access the edit dialog, go to the Machine Editor screen in Buzz, right click on the appropriate machine and select 'Edit Ninereeds NRS04' on the context menu.

A property sheet will be displayed, which has three pages...

Waveform
  - Allows the basic waveform to be selected.
  - Allows the fractal distortion parameters to be edited.
  - Allows the 'twin' note to be enabled, and its detuning and amplitude to be edited.

  Of the commonly known simple waveforms, the only one that has even harmonics is the ramp (sometimes called sawtooth). While waveforms without even harmonics are useful, they often sound beepy or obviously synthesized, no matter how much they are processed - both string and brass acoustic instruments definitely produce even harmonics, and I'm sure this is pretty normal for real instruments.

  If you find the ramp waveform too harsh, try 'Altered Bumps 2', 'Double Bumps 2' or 'Double Triangle 2' instead - and don't forget to play with the fractal settings.

  Finally, if the Twin note is enabled using the checkbox it is always calculated, even if its amplitude is zero. The only effect in this case is to halve the amplitude of the main note. Using a twin note almost doubles the CPU usage, so turn it off if you can't hear the difference.

Envelope
  - Allows the ADSR envelope to be edited.
  - Allows the pitch bend rate to be edited.

AuxBus Effects
  - Connect to an AuxBus channel.
  - Disconnect from AuxBus.
  - Configure ring modulation.
  - Configure frequency modulation.
  - Configure amplitude modulation.
  - Configure pulse width / waveform centre modulation.

  Waveform centre modulation basically distorts a waveform such that the normal centre point is reached slightly earlier or slightly later than normal. In the case where the original waveform is a square this gives pulse width modulation. The advantage is simply that it can be applied to any waveform.

Broadcast Rx
  - Allows broadcast command listening to be enabled and a channel to be selected.
  - Allows programs to be configured in the program bank.
  - Allows a mapping between program IDs and named programs to be established.

About
  My web and email address, and other pointless stuff.

The parameters on the dialog are not meant to be edited during a live performance. There should be no possibility of a crash, so you can adjust the parameters while a tune is playing to get the sound you want, but there is no attempt to avoid clicks or other strange effects.

### Broadcast Commands Accepted

The following fixed broadcast commands are understood by this machine...

Select Program

      Command      : 01
      Byte Param 1 : Program ID

Set Waveform

      Command      : 80
      Byte Param 1 : Waveform ID

Set Fractal

      Command      : 81
      Byte Param 1 : Fractal Depth
      Word Param 1 : Fractal Effect Low
      Word Param 2 : Fractal Effect High

Set Envelope

      Command      : 82
      Word Param 1 : Attack
      Word Param 2 : Decay
      Word Param 3 : Sustain
      Word Param 4 : Release

Set Pitch Bend Rate

      Command      : 83
      Word Param 1 : Pitch Bend Rate

Set Twin Note

      Command      : 84
      Byte Param 1 : Enable Twin Note
      Byte Param 2 : Apply Fractal Before Mixing
      Word Param 1 : Detune - not yet implemented
      Word Param 2 : Twin Note Amplitude

Set Ring Modulation

      Command      : 85
      Byte Param 1 : Enable on Main Note
      Byte Param 2 : Enable on Twin Note

Set Frequency Modulation

      Command      : 86
      Byte Param 1 : Enable Frequency Modulation
      Word Param 1 : Modulation Level

Set Amplitude Modulation

      Command      : 87
      Byte Param 1 : Enable Amplitude Modulation
      Word Param 1 : Modulation Level

Set Pulse Width (Waveform Centre) Modulation

      Command      : 88
      Byte Param 1 : Enable Pulse Width Modulation
      Word Param 1 : Modulation Level

### How does that fractal thing work?

Most controls for this machine are fairly self-explanatory, or at least fairly standard. The fractal distortion, however, is my own invention and some explanation is in order.

The fractal distortion uses an iterative function. That is, once you get the result of the function, you feed it back in again. It is heavily based on an equation for modelling population fluctuations that was first documented in “Simple Mathematical Models with Very Complicated Dynamics” (Nature, No. 26, 1976), by R. M. May.

A sound signal has very little to do with population fluctuations, so I designed a cubic function to use instead. As with the May equation, there is a parameter that controls how 'chaotic' it is. I have called this the fractal effect. In addition, the fractal depth is the number of times the function is applied (the equivalent of the number of generations ahead to predict in the May equation).

When the fractal depth is set to zero, or the fractal effect is set to one, the function has no effect on the input signal. If the fractal depth is zero, the fractal is never called.

When the fractal effect is set to a high sufficiently high value, the function becomes chaotic. With a sufficiently high fractal depth, it is quite simple to produce white noise. With more moderate values for the effect and depth parameters, the fractal distortion will add moderate levels of high harmonics.

The reason there are two 'fractal effect' controls is simply that the fractal effect is varied as the note is played. The effect value actually used will be between the 'high' effect and the 'low' effect, depending on the current envelope level.

Finally, there is a checkbox in the 'Twin Note' group which allows the fractal to be applied either before or after the twin note is mixed in with the original note. If the fractal is applied before the mixing, then it needs to be calculated separately for both the original and the twin note. Unfortunately, this is normally necessary - applying the fractal after mixing gives a rather odd effect. I left it in as an option in case someone really needs an odd effect.

### What's all this broadcast command listening stuff

I have created a small DLL which provides an additional means of communication between machines. It uses similar principles to AuxBus, but instead of communication signals it allow commands to be sent between machines.

The command format is based on the kinds of things that can be done in the pattern editor, and the main way of sending these commands will be using a machine that stores these commands in its pattern editor - Ninereeds Broadcast.

The inspiration was a recent message to the buzz developers mailing list, which suggested the possibility of a tune reacting to externally generated events - specifically, to locations and situations in a game.

The end result supports a number of requirements...

- Central control of all machines, a bit like a conductor. For example, all machines that support this could be switched to an 'emphasis' configuration in response to a single command by one machine.
- Pattern-driven control of a machine in ways that weren't anticipated when it was first created - ie extension beyond the limits of existing parameters.
- External control as described above.
- External listeners that detect events within the song - most likely reaching certain points in a song.

If you have any comments or suggestions, please e-mail them to steve@lurking.demon.co.uk.