Twibright Syntring, a low-profile ASCII tablature string synthesizer
*** DEMO TUNE ***
This Demo tune
MP3 has been produced without a single sound sample - 100% mathematically
calculated from timbre parameters configured in the tab
file!
Provides
- A simple C program that takes an input
file which contains the tablature (tab) in a format similar to the one common
on the Internet, just going top-down. Outputs a .wav file on the stdout. The
tab is interspersed with commands
- volume and tempo change, instrument tuning, timbre setup. Example Syntring tab
- Free software, under GNU
Public License.
- Alpha
prototype stage. Some parameters are variable only in the source, which is a
shame. I would like to make them configurable gradually in my free time
if the program is going to be enjoyed by anyone. Make your voice heard
if you want it to be further developed!
- Timbre is programmed as overtone content during the strike and two decay
controlling parameters. One is reflection loss at the bridge which causes frequency-independent
decay. The other is bending loss of the string (how much energy is lost in
one bending cycle), which causes the N-th overtone to have it's decay time
N+1-times shorter than the fundamental.
- A program named overtones which takes a
spectrum exported from Audacity and calculates the overtone spectrum in
minus decibels. One can
reverse engineer and approximate an existing sound this way. The output file
can be pasted directly into the tab file for Syntring.
- Can be used to learn or practice playing guitar, bass, etc. without
a complicated MIDI or audio setup or complicated editing software.
- Editing is done by a plain text editor, using usual block copy and also
search and replace function to create repetitions, replace certain chords
with others etc.
- Comments can be placed inside the file liberally which helps orienting inside the
musical piece a lot. Everything that is not recognized as a command or tab
line (beginning with _) is considered a comment.
- Should be extremely portable. I have OpenBSD and couldn't get any tab
editor or module tracker or MIDI editor or MIDI player make work, because
people usually write free software for Unix in a way that it compiles only on
Linux. So I wrote this to be able to experiment with music.
- Doesn't require any patches. For example TuxGuitar relies on the MIDI
subsystem with patches. Algorithmic synthesis also ensures configurable timbre
of the sound without a need to download any waveforms.
Requires
- Just a C compiler (GCC
if you don't know one)
- If you want to be
creative with music, then you need a text editor - Vim, Emacs
to name some famous ones.
- Doesn't require anything MIDI or any sound library, subsystem, ALSA, Jack,
patches, samples, Java (TuxGuitar), KDE/Qt (KGuitar), nothing at all!
Download - Try out - Usage
- Download syntring.c
- Compile with gcc -o syntring -O2 -Wall -Wuninitialized -lm syntring.c
- Download the demonstration tab which is an excerpt from the melody
of Devo: Gut Feeling, based on the
tabs available on the Internet.
- Run ./syntring < tune > demo.wav
- Play the resulting wav file with a suitable player
- Change anything you want in the tab file and run the program again to
"compile" a new wavfile.
Make and contribute own guitar timbres
Unimplemented things
- Setting the tune length. This is currently hardcoded to 35 seconds, has
to be changed in the source code
- Adjusting the tuning. Standard tempered tuning is used with Middle A at 440 Hz
- Changing the number of overtones. Hardcoded at the moment.
- Distortion (fuzz) code is present but disabled since it's not configurable
from the tab file at the moment.
- Chorus (additive and multiplicative) code is present but disable since it's not
configurable from the tab file.
- Setting inharmonicity for instruments individually. Currently there is only
one global setting in the tab file.
- Easier marks for dynamics (accented and gentle strike) than a command-based
global volume setting
- Relative volume (who should constantly remember the current
instrument/string volume when doing a minor adjustment?)
- Configuration of spatial position of individual instruments
- Changing the sample frequency in the tab file or on the commandline
- Telling the program on the commandline to synthesize only a portion of the tune
for quick preview cycles.
- Reverb, echo, delay effects would be nice to not sound so flat
- Some softstart of the excitation would be easy to implement and open way to
softer string sounds than just a plain hard pluck. Would just need
an excitation vector that would rotate together with the main vector.
- Currently changing the fret on a vibrating string produces a cat squeak
/ slide sound (Syntring is still a bad player hehe!) because there is no finger
release with resulting string damping. Needs just another counter and
dampening parameter or so.
- There should be also a brief period of damping just before the pluck,
otherwise the volume accumulates in quick successive plucks.
- The strings 6-12 have a hardwired strum, 0-5 are plainly plucked which
really sucks. Needs configurable strum start and end delay mechanism, and a
suitable mark into the tab file (<, >?).
- Frequency response of the pickup. Real instruments have pickups with a
frequency response that's given by the inductance, capacitance and resistance
inside the electric guitar. Further equalization can be added into the
amplifier chain and that determines the sound of the guitar. For example the
test tune has too screamy trebles in the guitar that's playing the melody. Can
be easily implemented by multiplying the strength during pluck with the
system response at the given frequency.
Technical notes
- Karplus Strong algorithm (patented - SW patents
suck) or Digital Waveguide Sythesis (also patented - sucks!) was not used
mainly because I learned about their existence after I had my own algorithm
developed. Instead, the sound is broken down into overtones and these
synthesized by simple damped sinewave oscillators - vectors that turn in time
and decay through multiplication by a decay constant. I reckon it requires
substantial sophistication
to precisely control the frequency and phase response of the inserted filter in
Karplus Strong or Digital waveguide. My algorithm allows setting the decay
amplitude and frequency of individual overtones easily.
- My method allows easy implementation of arbitrarily strong inharmonic
overtone behaviours, which I reckon is difficult with digital
waveguide synthesis.
- To simulate frequency-independent decay, a non-unity reflection efficiency
is assumed at the bridge.
- To simulate frequency-dependent decay, it's assumed that each bending cycle
of the string returns only a close to unity fraction of the energy put into the
bending. Since bending occurs more often with higher frequencies, their decay
time is inversely proportional to the frequency.
- The disadvantage of my method is that it's slower and the speed depends on the number of
overtones.
To speed calculation up, if an oscillator reaches some very small level, it's
zeroed out and pronounced mute. This constant, ALMOST_ZERO, can be changed in the source code
to get a faster calculation with a crappier sound for faster preview.
- The timbres in the demo tracks are based on spectral analysis of the bass guitar and guitar
timbre of the original Devo - Gut Feeling track using the overtones
program. The two loss parameters were adjusted manually to get least crappy sound.
Unfortunately the guitar is always backed by a bass so it wasn't possible to
obtain clean spectrum. Therefore a bogus guess was done and it doesn't sound
very realistic. Needs a dedicated recording of a real instrument pluck to sound
better!
- I don't know if the tab is correct. I seriously doubt my musical abilities. If you are
skilled in music and find a bug in the tab and fix it or even better supply a
different tab based on free music (GFDL, Creative Commons etc.), that would be
great.
- There is a special anti-aliasing code so it should produce proper output (and seems to produce) even
on low sampling rates like 8kHz. A low sampling rate can be used for a fast preview if doing frequent
edit-compile-listen cycles when working on the tab.
- The string is plucked abruptly and created a significant problem with unpleasant sharp clicking.
I solved this by shifting all the frequencies in time by 1/4 of the string
roundtrip. This doesn't change the shape of the waveform, but the pluck doesn't
start at a peak, but instead in the middle between them, so the problem goes
away.
- Relative pluck and pickup positions are hardcoded in the source based on
rough GIMP measurement of a Fender Stratocaster picture - pickup is the bridge pickup and
pluck between the middle and neck pickup. They are used to calculate the phases
of the individual overtones.
Other demo tunes
References
- Devo: Gut
Feeling tab
- Devo:
Gut Feeling bass tab
-
Karplus Strong string synthesis (Wikipedia)
- Digital Waveguide Synthesis (Wikipedia)
-
M. Laurson, C. Erkut, V. Va:lima:ki, and M. Kuuskankare, ``Methods for Modeling Realistic Playing in Acoustic Guitar Synthesis,'' Computer Music Journal, vol. 25, no. 3, pp. 38-49, 2001 - How to do it
properly (but unfortunately heavily patented way)
- SMAC
Proceedings 03 - Guitars, Violines, Pianos, etc. - How to do it
properly
- The
picture of Fender Stratocaster used to measure the positions in GIMP