straight from scratch journal file
sept 27 00
The synth startup
Because I've been doing a lot of 'unknown' work, this
journal makes it clearer what i've been up to, and also
the things i'm dealing with in let's say the development
sense of the synthesizer (electronical / digital musical
instrument that is) that i'm making.
The sonic part of the research is about the type of sounds
I'm interested in and how they can be effectively made,
the computer part of the research is how to effectively enough,
both in engineering sense and in efficiency of the resulting
machinery, the desired sound algorihtms can be specified and
and built into a digital system, and the design part of the
research is how i feel comfortable working with the results,
given the limitations of my current tools and equipment, and
how i can prepare for using the same software and built
equipment in more state of the art environments.
The development is about the actual machine i'm in the process
of making, that is an extended micro computer system (fast cmos Z80
system), with communication possibilities (currently a parallel port
driveable DMA interface), the analog part: filter(s), VCA and
modulation/signal modification circuits, and a speaker/amplifier
system to monitor it all. Points of specific attention are the
DA (digital to analog) converter, which is a self made 8 (or some more)
bits multiplexable and pulse width modulable high speed design, with
room for analog multipicative behaviour, even exponential (for
generating envelopes).
Currently, the Z80 ticks at about 10MHz, which could be 35 or so with
a better chip ($4 or so), and the DAC simply directly feeds a high
quality amp chip with some high quality speakers basically laid on
their heavy cardboard box, the DMA interface is operated after
selecting memory range and resetting manually, the PC with the
printer port interface is an old laser 286 system with simple
enough analog (VGA/EGA) monitor and a few dozens of megs of
free harddisk space. The computer hardware basically consists of
circuit boards connected with quite some band-cables, and a few
breadboards. The display is a 16 digit large led display, the
keyboard an old TI calculator keyboard, alternatively a
baby-keyboard (small 'organ' keys), which is now driving an
analog synth prototype with one of its three octaves.
There's no proper enclosure for the (mainly) cmos computer circuitry,
resulting in electrical/magnetical field sensitivity, which is
constantly noticed because every few minutes an old refrigerator
switches on, generating a major inductance pulse, picked up by
the computer circuits, which then usually f* up some way. Mainly
this is because the fridge thermostat is broken, so i drive the
motor over a relais-card driven by a digital pulse generator from
one of the computer circuit boards. The nearness of a cable conencted
to the relais card alone is enough to disrupt some of the HC (cmos)
computer chips, though luckily not the memory, most probably because
there are many long wires connecting them, that act as antennas.
These chips are very fast by themselves (up to few hundred megaherz
effectively), and have very high input impedance, that means a small
antenna picking up a rapidly changing magnetig field can already
generate disturbances that end up changing some of the circuits
ones and zeros. I play my own watchdog timer regulary resetting the
system, and if necessary reloading programs and/or data.
What does the system currently do?
The computer ticks, that means it is a valid system, with at least
8 kilobytes of battery backed-up memory, taking z80 programs
from for instance a PC, or by inputting them by hand even
(which i did thus far for short test programs).
The dma interface fills the memory effectively with anything needed,
it has counters over half the 8k address range, and can be switched to
the lower 4kbytes (which are normally protected to be red only,
for storing fixed programs), or the upper 4k, which can even be written
while a program is running. Basically, the computer can be given
a dma request by pressing a switch for 'dma-mode' which is honours in
usually a microsecond or so, after which the dma circuit start filling
the memory up, with data provided on its 8 bit input. It can be given
a pulse for writing that byte into the memory, and advancing one
memory location. This process is repeated until the computer is
switched out of dma mode, and resumes running, possibly after first
pressing the reset button.
I've made a few cables with the right connectors to fit a standard
parallel printer port, which can connect to this dma interface.
Then any program that can access the printer can write data into
the Z80 systems memory. A basic (gwbasic or qbasic) progam can
easily write 4 Kilo byte into memory in maybe 10 seconds, a
possibility I've used to dump data in hex format into the z80,
and to generate additive fourier synthesized samples and download
then as a 'one page' (256 bytes) wavesample.
Development software
The 286 pc has basic, an assembler, recently a sort-of-C compiler,
for the pc, a cross assembler for the z80 (good enough), with
standard ihx (or motorola) hex output files, that can be read
by a basic program that checks the memory map and downloads
it into the Z80's memory. The z80 assembler also takes input from
a 'tiny' C compiler, which should be able to produce serious
enough C programs with little library (I'm working on it),
that should download straight into the z80 as well.
I've tested that compiler, and it produces sensible z80
code, with basic library for io (including character/string IO,
basic 16 bit math (including mult/div), and the assembler I've
used for making display and keyboard driver software, including
keyboard driven menu texts on the 7 segment display (with ok enough
rendering of ascii character strings), a keyboard scan routine
with hex and ascii output, number conversion from byte to decimal
and hex, and from decimal to byte, and simple one byte decimal
calculator with the to operands and the result on the display
(two decimal number with a cursor moving over the 6 digits
circularly , and a 3 digit result, of course limited from 0 to 255).
This all works from decently formatted assemly source files that
with two short dos (norton) commands can be assebled, linked,
ihx coded, and downloaded into the Z80 memory (currenlty using
gwbasic) , overall re-assemble time for all this and the below
is mayby 30 seconds.
What does the synth do now
The Z80 is tested for acting as a waveform generator, and as delay
line. Neither job necessarily fits the 10 MHz not-dsp, but waveforms
are needed, and when they'e made good enough, can make up for a
significant portion of a synthesized sound.
A basic program can add sinewaves together like a drawbar organ
for instance, and generate frequency tables, that are used to
link a certain key on the keyboard with a certain pitch of an
oscilator.
A generator routine for the z80 takes a 1/4k wavesample and a pitch
number, to generate a wave on the DAC, and two of them have been
combined (using the alternate register sets in the Z80) to have two
oscillators, with sampling frequency somewhere between the
ultra sonic boundary (my tweeter and amp are quite up to
undegraded peformance way over 20kHz) and CD rate, depending on the
key scan code up to about 50kHz.
One row of the keyboard (8 keys) is scanned at sampling rate, and table
converted to one octave of pitches, with the black notes being
playable by two adjacent keys, and an octave shift by pressing the
highest key with other notes.
The main fun is to have a good sample, and detuned oscilators, to
get beating patterns in the sound. The key-to-pitch tables are
per note, and can specify slighly different pitches for the
oscilators, completely controllable per key combination. The
accuracy of the pitch control (basically the phase increment sampling
error) for the current try-out software makes it possible to
have slowly varying relative phases of the oscilators, fattening
the sound.
The samples themselves are mainly three types: simple waveform,
simple harmonic content, and more advanced. The first types are
fine, like sine (nice and quiet for the higher sample rates where
the mechanical damping of the sampling frequency is good), sawtooth,
triangle and pulse (both ok enough buth sensitive to the
interferance of the sample frequency with the (fundamentally
infinite) harmonic structure), the latter in need of additional
analog or digital filtering. More complicated samples I've
generated by making use of additive (sine) synthesis, subtractive
digitally simulated filtering synthesis and by newer forms of
synthesis: additive time localized harmonic synthesis, combined
with the former two methods.
The latter method should not be confused with wave table sequencing,
that is clearly planned extension, requiring only overseeable
software changes, I'm refering to making a single harmonic come
up and damp inside a wave-sample, i.e. within one period of the
fundamental.
Idea wise its like producing a smooth spike, which envelopes
an harmonic (a sine wave) with a rise and fall time of roughly
the same order as the wavelength of the harmonic. Interestingly
enough, the ear is quite capable of distinguishing the harmonic
even when the visual sine characteristics are almost completely
masked by the pulse. The pulse shape that I use can be a gaussian
is like a gaussion distribution function from statistics or
physics, a sort of bell form, or a the sine wave can simply be
divided by its own (zero-centred, i.e. phase shifted to
k+pi) argument to arrive at the fundamental 'sinc' function in
frequency band limited fourier resynthesis / sampling theory.
The result is interesting, and definately more varied than only
traditionally made waveforms. The traditional ones include
additive organ tones, similar to the ones on my web site,
because when the detune is carefully chosen, nice vibrating
effects can be made, and filtered notes, even including
resonant filter simulations, which are starting to get more
then satisfactory (although they take quite some time to
compute in 286 basic)m though I'm not yet satisfied with
the relation of the filter coeeficients and the analog filter
diagrams I'm interested in, and of course the waveforms to
start with combined with the filter (a 4th order IIR with +&-
overall feedback prceeded by a 3 sample weighted average FIR)
must be bandlimited (easiest with additive synthesis) to
be fed moise free enough through this.
The idea of the smooth pulse within a wave sample acting as
an envelope for a single harmonic is similar to a pulse waveform
added to a sample, with possibly the same 'nasal' qualities,
but it offers other possibilities as well, it adds the harmonic
to the spectrum without making the sine wave of that harmonic
sample-long. Now consider the beating patterns that result from
detuned samples with similar harmonic content (including phases).
When the phase difference between the samples is 0 degrees,
all harmonics are added and basically the samples are reproduced
at +6 dB (i.e. twice as loud) as a single oscilator.
No lets say the phase difference is 180 degrees: then all even
harmonics cancel out, because of their symmetry: the second
half of a sine wave is exactly inverted compared with the
first half. There is no way out of this, that is in the beating
patterns there is a complete daming of all even harmonics at some
point, no matter what their amplitude is. By phase shifting,
it is possible to make them damp out at different points in
time, which makes their interaction more interesting.
For instance in the case of detuned organ notes, the vibrations in
amplitute (and after non-linear mixing also in frequency)
become more varied when the harmonics (such as 1st, 2d, 3d, 5th,
7th, 8th, 9th, 12th, 16th) are mixed with a phase offset.
Still, the beating patterns are regular (they can be computed),
and have the same envelope for each harmonic as a result,
except with different time scale. When a harmonic is present in
only a part of the (repeated) wave sample, the interference
between the two oscilators for that harmonic has a different
quality, amplification and/or damping take place when the pulsed
harmonics 'come together', because the phase diffence
slowly makes the locations where they occur have equal phases
and then move away again. The result is worth it: interesting
harmonics can be combined, and have sudden amplitude changes
when two oscilators are combined.
The sound is good enough to use as basis for good synthesized sounds,
with peaks that are actually good enough to be presentable
straight away from keyboard-ish imitations and squeeks. Some of
the sounds have quality enough in them to be realy pleasing.
Various organ sound in some key ranges, various simulated
filter sounds from good enough starting samples mainly because
of their pleasing filter fatness, and a some of the engineered
standard plus localized harmonic sample pairs with mild or heavily
resonant filtering are good enough to switch on and keep listening
to for a sustained period of time, because they sound good,
depending on the sample rate and the accuracy of the phase
increment computation, they sound clean enough to be real loud
even (with 8 bit per oscilator and no particular attention paid
to the optimal use of headroom), while they don't need volume
to sound rich.
Mind that all this is without envelope generators (only note
on or off), with two samples of 1/4 of a kilobyte each, no
wavetable sequencing, i.e. the samples remain the same.
In general there are interesting (and predictable enough) observations:
the phase increment must be accurate enough (otherwise the result
sucks), the sampling artifacts must very much be part of the
sounds and the reproduction system, they easily noise up the result
considerably, and give sampling rate with harmonics interference
products that are absolutely unacceptable.
Ah, and there is more to the current synth software, it does a
digital delay simulation as well, even with feedbach control,
though currently only at quite a low sampling frequency. Sound?
serious enough, depending on the sample fed through it, and not
too long (only 4 k samples lenght, at lets say 12kHz sample rate
for the sake of argument, that is about 1/3 second.). The interesting
part of the sound being that the direct driving without any processing
or tricks in the signal pathm which gives it a solid general
and 'slap-back' effect. Of course on louder volumes the echo-ing
component gets grainy with 8 bits resolution. It currently takes
only one oscilator as input, and the result is that for certain
sample and note combinations, the delay line starts resonating
with the oscilator slowly, which makes the whole sound nicely
acoustic as an effect.
Over the whole the in digital sense limited horsepower of the
system as it is (not in old analog type synthesis terms, btw)
requires accurate engineering of sounds, that mostly sound
strong enough as basis, but regularly are limited and often
not up to high beefyness standards. Some of them already are,
and reasoning leads to the whys for this, which makes for
interesting enough possibilities.
The next things?
Prepared for are that I have more memory (128k CMOS e.g.), more
synth circuitry (several filer types, non-linear circuits, vca
type of circuitry), and maybe more digital circuitry to do sample
playing and also sampling with, mayne i'll get some wav's with
instrument samples from the web or something, though on a 286 its
not all too fast. While i'm at it, maybe some buffered parallel
port (wav based) sample output is an interesting id, though
this would beinteresting enough on a bigger system, too. That is
the development work might be saved for later. The z80 system is
good for its job as synth controller and waveform manager, as well
as doing a lot of IO, but not as a dsp or fast number cruncher,
of course. Industial thinking type of assessments, of course.
sampling tests
special hardware facils
actual UI for synth