Sinth: A very simple digital synthesizer. Docs for Version: 0.10 Dec 14 1995 Sinth is the backend to the internet synthesizer. It reads a control file and produced a sound file. This control file sets up the connections between the various software emulations of analog modules, and also sets up the values for various "constant" parameters. In order to make some things simpler, a number of defaults are given so everything need not be explicitly specified in all cases. Syntax: sinth [-q] [control filename or - for stdin] Sinth is called with the name of a control file as a parameter (or '-' for stdin), and produces a sound file on stdout and a connection diagram on stderr. Using the -q option supresses the connection diagram. for example: sinth ex01.sinth > /tmp/t.au Sinth 0.10 Dec 14 1995 File Version 0.00 Sound Format: MuLaw Sample Rate:8012 Duration:0.50 Trigger: On:0.33 Off:0.17 Rep: 0 Plugboard c1 . . . . . . . . . . . . . . . . . 0.000000 c2 . . . . . . . . . . . . . . . . . 0.000000 c3 . . . . . . . . . . . . . . . . . 0.000000 c4 . . . . . . . . . . . . . . . . . 0.000000 c5 . . . . . . . . . . . . . . . . . 0.000000 c6 . . . . . . . . . . . . . . . . . 0.000000 c7 . . . . . . . . . . . . . . . . . 0.000000 c8 . . . . . . . . . . . . . . . . . 0.000000 c9 . . . . . . . . . . . . . . . . . 0.000000 c10 . . . . . . . . . . . . . . . . . 0.000000 o1 . . . . . . . . . . . . . . . . * Sine Hertz o2 . . . . . . . . . . . . . . . . . Sine Hertz o3 . . . . . . . . . . . . . . . . . Sine Hertz n1 . . . . . . . . . . . . . . . . . eg1 . . . . . . . . . . . . . . . . . 0.00 0.00 0.00 0.00 0.00 0.00 0.00 eg2 . . . . . . . . . . . . . . . . . 0.00 0.00 0.00 0.00 0.00 0.00 0.00 eg3 . . . . . . . . . . . . . . . . . 0.00 0.00 0.00 0.00 0.00 0.00 0.00 f1 . . . . . . . . . . . . . . . . . g1 . . . . . . . . . . . . . . . . . g2 . . . . . . . . . . . . . . . . . sq1 . . . . . . . . . . . . . . . . . sq2 . . . . . . . . . . . . . . . . . +-----+-----+-----+---+---+-----+---+ |F A D|F A D|F A D|S E|S E|S F Q|Out| | Osc1| Osc2| Osc3| G1| G2| F1 | 1 | sq1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 speed: 0.05 sq2: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 speed: 0.05 Operating: o1 This chart shows information on the output format, its sample rate, how long the sound is, the trigger parameters, the "connections" between signals. Sources are listed on the left, destinations on the bottom, and an asterisk shows a connection. Values of parameters are shown on the right. For instance, here, O1 is plugged into the Output. Oscillator 1 is a Sine wave, interpreting frequency info as Hertz (aka cycles/second). At the bottom of the chart, a list of operating modules is given. For optimization, only the modules which produce output are run! Description of Synthesizer Modules: This synthesizer uses a number of modules, and each module processes a number of inputs into a number of outputs. There are also some static parameters, which are mostly switches and things you set once and forget. How the signals get routed and the constants get set is described in a control file. The basic syntax of each command in the control file is: [destination] = [source] ; [parameter] = [floating point number or keyword] ; The '=' is optional, and the ';' is as well, unless there are several commands on a single line. '#' will comment out the rest of the line. All commands are case-insensitive and can have various amounts of "white space" around the keywords. Sinth will catch most if not all syntax errors and complain about them on stderr. Very Important: the output of the synthesizer is taken from the output of Out, so something had better be plugged into it in order to be heard!! In the following descriptions, the dynamically changing parameters of a module are called "inputs", while the constant ones are called "parameters." To specify which of several modules is being used, "n" in the parameter name is replaced with an identifying number, e.g. "OnF" can be O1F, O2F or O3F (the frequency input for an oscillator). Oscillators: Oscillators generally supply repeating signals which are used as sound sources. They can also provide signals which control other modules' characteristics. The frequency is a number given either in Hertz for an accurate frequency, or a real number from -3.0 to 5.0 (roughly) which corresponds to the logorhythmic "1 unit per octave" standard, based on 0 representing a lowish frequency C. The amplitude scales the output and is usually connected to an envelope generator. The duty cycle warps the phase of the signal, which is only used in the square wave and triangle wave. Valid values for duty cycle are -1.0 (for 0%) to 0.0 (for 50%) to 1.0 (for 100%) - so you can plug a unit-scaled signal directly into this parameter. Oscillators' signals can be plugged into each other to make Amplitude Modulated (AM) or Frequency Modulated (FM) sounds as well. + inputs: Freqency (OnF), Amplitude (OnA), Duty Cycle (OnD) + output: On + parameters: Waveform (OnW) [Square,Triangle,Saw_Up, Saw_Down or Sine], Frequency Scale (OnFS): log (1 unit/octave) or Hertz (linear) frequency. Noise: Noise is a random signal that sounds like static on the radio. But when filtered and mixed with other signals, it's quite useful. It can be treated as a random constant between -1.0 and 1.0. + output: N1 Envelope Generators: Envelope generators make commonly used control signals. The EG's themselves are controlled by a trigger signal. When the trigger starts, the value of the control starts changing from the Start Level toward the Attack Level at the Attack Rate. When that level is reached, it starts changing toward the Sustain Level at the Decay Rate. The signal remains at the Decay level until the trigger signal turns off, at which point the signal drops again to the Release Level at the Release Rate. All these rates are specified as "inverse seconds", i.e. a rate of 10 means the transition will take place in 1/10 of a second. The higher, the faster. + parameters:Start level (EnL), Attack rate (EnAR), Attack level (EnAL), Decay rate (EnDR), Sustain level (EnSL), Release rate(EnRR), Release level (EnRL) + output: EGn Sequencers: (called SQ1,SQ2) Sequencers provide a timed series of 8 control signals. The speed that the sequencer runs at is controlled by a parameter SQnS. The values can be used to make a very, very short melody. + parameters: Values (SQnA..SQnH),Speed (SQnS) + output: SQn Gates: Gates modulate the amplitude of an input signal with control signal, which is usually a signal from an envelope generator, but could be another Oscillator (for ring-modulator effects). + inputs: Signal(GnS),Envelope(GnE) + output: Gn Out: This is the output! (future: stereo, etc.) + inputs: OUT Low Pass Filter: A low pass filter is used to remove high frequencies - those below frequency "F" - from a signal. The resonance controls both how much the higher frequencies are attenuated and how much that frequency is boosted. When the Resonance is 1.0, the filter becomes a sine wave oscillator with the frequency of F! + inputs: Signal(F1S), Frequency (F1F), Resonance (F1Q) + output: F1 Constants:(C1-c10) Sometimes you just want to plug a constant into a control signal. I give you 10 constants numbered from 1 to 10. + output: Cn + Parameter:a floating value Beside these objects, there are more general settings which should be adjusted: Trigger: The trigger provides timing for all the envelope generators. + Output: (internally used by all Envelope Generators) + Parameter: On time (Trig_on), Off time (Trig_Off), Repeat (Trig_Rep) Duration: The duration controls how long the sample will end up being, in seconds. + Parameter: Duration (duration) Output Format: The synthesizer can return a mu-law encoded sample (Au), which is 8 bits mono at 8012 Hz, or a NeXT/Sun snd file(snd), which is 16 bit mono at 22050 Hz. + Parameter: format (format) [ mu-law (Au), NeXT/Sun (snd)] Version: The "version" of the sinth control file can be explicitly set. Otherwise, it will assume the modt current version. + Parameter: version (floating point number) Additional Notes: - All sounds are computed in floating point and scaled and converted to whatever the output format may be. Thus, envelopes and other scaling can be pretty sloppy. - the command order is irrelevant, with the exception that only the last setting of a bunch of duplicated parameter settings will be used. - If several sources are routed to a single control, they will be summed! - Sinth gives lots of error messages, with offending line numbers. - Sinth cannot violate the laws of physics, so keep your frequencies below nyquist, please (i.e. <4KHz for .au, 11KHz for snd). You can alias, though, if you want to. - Some things may change in the future: don't expect old command files to work in the next release, although they probably will. Here is a typical bunch of example patches: 1: ultra simple patch: # this is the simplest patch! # because of defaults, this will produce a 110 Hz sinewave 1 second long # with no envelope, out=o1 2: the same with all parameters fleshed out minimally # more detailed # plug the first oscillator in out. out=o1 # more about the oscillator: o1f=c1; C1=110.0 # use C1 to set frequency o1w=Sine # set up waveform type o1Fs=Hertz # set up frequency type o1A=c2; c2=1.0 # use C2 for amplitude # use C3 for Duty Cycle o1d=C3; C3=1.0 # set the gate's envelope signal to 1.0, in c4 g1e=c4; C4=1.0 # foramts and triggers format=au trig_on=0.37; trig_off=0.17; trig_rep=0 duration=0.5 # See why we use those defaults???? 3: more fun! an enveloped filtered noise Version=1.0 # optional version duration=2.0 # 2 secs of noise trig_on=1 # one second on, trig_off=0.37 # .37 sec off trig_rep=10 # repeat for a while #the envelope (plugs into the frequency of the filter) e1l=10 e1ar=2 e1al=2000 e1dr=4 e1sl=1000 e1rr=4 e1rl=10 out=f1 # we hear the output of the filter # filter f1s=n1 # the source is "pure" noise f1f=eg1 # the envelope goes into the frequency f1q=c1;c1=10 # filter resonance is "C1", which is 10 4: sum of sines! # sum these sines! out=o1 out=o2 out=o3 # o1f=c1;c1=100 o2f=c2;c2=104 o3f=c3;c3=700 duration=1.0 5: ring modulated (AM) o1f=c1;c1=200 o2f=c2;c2=31 o2a=eg1 # modulation index will be enveloped! e1l=0 e1ar=2 e1al=0.5 e1dr=4 e1sl=0.25 e1rr=4 e1rl=0 g1s=o1 g1e=o2 # a gate is also a ring modulator! out=g1 # take output from gate1 duration=1.0 6: FM out=o1 # o1 is the carrier o1f=o2 # o2 is the modulator o1f=c1;c1=200 # (add o2's signal to 200 Hz!) o2f=c2;c2=11 # run o2 at a low frequency o2a=eg1 # modulation index will be enveloped! e1l=0 e1ar=2 e1al=50 e1dr=4 e1sl=20 e1rr=4 e1rl=0 duration=1.0 7: duty mod/filter fun! out=f1 o1f=c1;c1=190 o1d=o2; o1w=triangle o2f=c2;c2=5 o2a=c3;c3=0.50 f1s=o1 f1f=eg1 f1q=c4;c4=4 e1l=10 e1al=2000 e1sl=500 e1rl=10 e1ar=5 e1dr=2 e1rr=2 duration=2.0 trig_on=1.0 trig_off=1.0 8: #sequencer fun! duration=2.4 sq1A=110 sq1B=137.5 sq1C=165 sq1D=220 sq1E=385.0 sq1F=330.0 sq1G=440.0 sq1H=165.0 sq1s=0.15 trig_rep=100 trig_on=0.2 trig_off=0.1 e1l=0 e1ar=10 e1al=1 e1dr=15 e1sl=0.25 e1rr=10 e1rl=0 o1f=sq1 o1w=triangle o1a=eg1 out=o1 Get the idea? INTERNET SYNTHESIZER: You can drive this program from an HTML form and cgi perl script combo! Just change the pathnames in all the the perl scripts "sinth*.pl" to point to the proper directories and install it in the server's cgi-bin directory. You should also fix up the URL that the form points to in sinth_mods.html and the other synthesis html pages. VERSION INFO: V 0.10 was the original release V 0.11 fixed bugs in the filter and a few other places. added the sequencer and output options and generalized the internals. The html pages were also streamlined somewhat. V 0.12 fixed a bug in the envelope generator and added more html/perl combos. INSTALLATION NOTE for sinth: The Makefile may need to be adapted to accomodate Intel-ordered bytes. Just set the compilation flag "-DIBM". I bet you can write a better Makefile than I can anyway. Please do and send it to me! THIS SOFTWARE IS COPYRIGHT 1995/1996 HENRY LOWENGARD, jhhl@panix.com. OF COURSE, THIS IS FREEWARE AND I CANNOT BE HELD RESPONSIBLE FOR DAMAGES DONE TO YOUR COMPUTER BY THIS PROGRAM, WHATEVER THEY MAY BE. SHOULD YOU WISH TO REDISTRIBUTE THIS, PLEASE KEEP THE SOURCE CODE AND AUXILIARY FILES WITH IT. I'D LIKE TO HAVE A COPY OF ANY CHANGES YOU MAY MAKE, SINCE I CAN'T TEST THIS ON A LOT OF PLATFORMS AND REALLY DON'T KNOW A HECK OF A LOT ABOUT C, "THE LANGUAGE OF THE PHONE COMPANY." Future enhancements: - Dynamically allocated constants. - Dynamically allocated modules. - more interesting modules. - other HTML interfaces.