intro soft-synth query

category: general [glöplog]
thom: there should be some intro's ect that have had there sources released by now, atleast one or two. That may help you on your way. learning the basics from other peoples examples is always a big help.
added on the 2004-04-27 03:06:04 by pacman pacman
I know that Yellow Rose of Texas released their sources with a nice 4K softsynth:


Of course, 4K softsynths don't really offer the sort of nice features you are talking about. Yellow Rose only seems to use basic sines, squares, and triangles.
added on the 2004-04-27 05:55:43 by s_tec s_tec
Yellow Rose has an FM based sample generator plus a tracker-style player with support for delay, so it's not a real softsynth. They don't have antialiased waveform generation, but this is not something i'd spend code space on in a 4k anyway. However, they've managed to create good sounds with the limited capabilities available.
added on the 2004-04-27 11:48:58 by titanstar titanstar
KB: So you use the same method I used to use? I didn't know that :) I've kinda moved to sines with self-phase-feedback though, one can do funny morhping (duty cycle-alike stuff) that way.

They are quite.. Different in some sound aspects, but I like them anyway. One can easily reduce the amount of aliasing noise with them as well.

Well, actually it isn't bandlimited, it's just a matter of not having that many overtones in it. You will get aliasing at really high tones, you could avoid this by decreasing the feedbacks at higher frequencies. And I have found that you get more overtones with negative feedback than with positive feedback. Or if it was the other way around :)
If you like the sound of it, use it. I have these different waveforms (shape goes from 0.0 to 1.0)
out = sinf(phase + lastOut * (shape - 0.5f) * 2.0f);
lastOut = out;

out = sinf(phase + lastOut * (1.0f - shape) * + lastOut * lastOut * shape);

pwm square1
square1 = sinf(phase - lastOut1 * lastOut1);
lastOut1 = square1;
square2 = sinf(phase + shape * pi * 2 - lastOut2 * lastOut2);
lastOut2 = square2;
out = (square1 + square2) * 0.5f;

pwm square2
float square1 = sinf(phase - lastOut1);
lastOut1 = square1;
float square2 = sinf(phase + shape * pi2 - lastOut2]);
lastOut2 = square2;
out = (square1 - square2) * 0.5f;

though they aren't exactly like this, I have tweaked the feedbacks everywhere, having them at like 1.1 instead of 1.0, giving for instance float square1 = sinf(phase - lastOut1 * 1.1f); in the pwm square2. Some trial and error :)
added on the 2004-04-27 20:27:38 by steffo steffo
Sorry if I'm dumb, but: Why is aliasing such a problem? I mean most demos will probably use a 44100Hz sampling rate, so aliasing will only occur with waves that have frequencies over 22050Hz, and you propbably don't want tones at that frequency, or do you?
added on the 2004-04-28 15:28:28 by 0xtob 0xtob
oxtob: Unless you're using pure sines (which I guess most musicians would be rather discontent with), all periodic waves have overtones (more or less depending on the waveform itself, of course) at 2x, 3x, 4x, 5x, etc. the base frequency. These can easily go way over 22050Hz and thus alias.
added on the 2004-04-28 16:02:46 by Sesse Sesse
0xtob: Because when your oscillators aren't band-limited you will get overtones that are above 22050Hz when playing lower frequency notes, which makes it sound like (relative) shit.
added on the 2004-04-28 16:03:51 by sagacity sagacity
well, the problem is that most oscillators (saw, square, triangle) have infinite harmonic content. Take for instance a square wave - if you decompose it into a fourier series and reassemble afterwards, you'll end up with something like

out = 0;
for(int i = 1; i < INFINITY; i += 2)
out += 4/M_PI/i*sin((base_frequency*i)/Fs*2*M_PI*t);

Now, since i goes to infinity, there will be aliased components in the resulting output. If base_frequency is small compared to Fs, the amplitudes of the aliased components will be small, and it won't sound too bad, but if base_frequency is higher, this it will sound like some parts of the oscillator is inharmonic. This effect is worsened if you do pitch bends, as half of the aliased components will actually bend in the opposite direction, which sounds really bad.

One solution is then to not generate the components that have frequencies above Fs/2, something like:

for(int i = 1; i < Fs/2/base_frequency; i += 2)
out += 4/M_PI/i*sin((base_frequency*i)/Fs*2*M_PI*t);

However, there's a catch. If you just truncate the fourier series like this, the highest remaining harmonies will make the waveform have ripples, something that is know as the Gibbs phenomenon. These ripples used to be cancelled out by even higher harmonies, but since we truncated them away, they won't be cancelled out anymore. What one usually does is to apply a cosine window to the amplitudes to dampen the higher frequency components. This will make the final waveform a closer approximation to a square wave:

for(int i = 1; i < Fs/2/base_frequency; i += 2)
window = pow(cos( (i-1)*M_PI/2* base_frequency/(Fs/2), 2);
out += window*4/M_PI/i*sin((base_frequency*i)/Fs*2*M_PI*t);

added on the 2004-04-28 16:08:51 by titanstar titanstar
What is the definition of softsynth? I allways tought, the only way to get sound in intros (only good/practical way) is to create a set of basic sounds (samples) when loading and to combine them when the intro is running. Is there an other way?
added on the 2004-04-28 17:32:35 by juhees juhees
juhees: That depends, of course, on your definition. I think most people agree that loading a standard .xm or .mod (even with generated samples) is _not_ a softsynth, though. The few intro softsynths I know of are modelled after the classic analogue (subtractive) synths, where you start with oscillators and then go through filters and effects (all realtime) but there are of course other ways.
added on the 2004-04-28 17:40:08 by Sesse Sesse
juhees: Today PCs are fast enough to calculate the whole sound for an intro in realtime, that means using eg. a virtual-analog software synth which doesn't calculate samples (for playing with an XM player) but is running throughout the whole intro generating the sound.

I did that first back in '97 in "Totraum 209" by Purge (was that the first 64k with realtime sound btw? Or did I miss something sooner?), then again in various projects and of course all Farbrausch intros.

The big advantage is that you have got many more possibilities when you want to modulate the sound, for example slowly open or close a filter or if you want to have really long, etheric pads. Softsynths sound a lot more "natural" and interesting than XM players... unless of course you pre-generate whole sequences and the whole intro precalculates longer than it runs, that is :)
added on the 2004-04-28 17:56:42 by kb_ kb_
kb: so, i have a virtual noise-generator, sine-generator, an low-pass-thing (how do you call a low-pass filter in hardware ??? ;-) some mixing-device and so on. And all my music-data is like "10 secounds after start: switch that thing on, connect that output to that input; 11 secounds after start: ..."
Or am i totaly wrong?
added on the 2004-04-28 21:06:26 by juhees juhees
juhees: That kind of music data is usually called "MIDI", but yes, that's the general idea. You'd probably add some other oscillators, some effects and such, but that's just extensions. :-)
added on the 2004-04-29 01:39:32 by Sesse Sesse
juhees: normally you have more or less fixed setups for the synthesizer parts (at least they don't change while the song is running) and then you have MIDI- or tracker-style pattern data which feed the synth with notes and parameters for the oscs/filters/etc.

So it's more or less two parts. One part that describes how everything is connected and the other part that contains the music.
added on the 2004-04-29 11:11:16 by kb_ kb_
Juhees: You kinda seem to have developed an interest in how to do softsynths. Before you even start trying to do one, learn how you use them. Get yourself a music program capable of hosting softsynths (VSTinstruments for instance), and start fooling around until you get the general idea.
There are trackers capable of hosting VSTi's, renoise and skale tracker for instance.
added on the 2004-04-29 12:19:36 by steffo steffo
Ok, thanks for all the answers, i'll look at some softsynths as soon as i have a bit more time. But are there also some open-source implementations of intro-softsynths? There is code of some intros, but the yellow rose for example dosn't seem to use a softsynth (but anyway, i learned a lot of playing with that code, mostly saving bytes :-P )
added on the 2004-04-29 12:29:04 by juhees juhees
i believe that the sourcecode to some old version of stefancrs's synth is floating around somewhere, but i'm not really sure that it'll be all that usefull. read up on dsp-stuff, think for yourself, ask the gurus if you really can't figure some details out, and try try try try try until it sounds good.
added on the 2004-04-29 13:12:20 by kusma kusma
btw, softsynth seems to be a good way for 64k (i read kb's tutorial again, thanks for that by the way!), but has anyone experiances with softsynth in 4k?
added on the 2004-04-29 22:46:48 by juhees juhees
juhees: Once you approach smaller sizes, you invariably have to cut features; I doubt you will be able to pack a very _flexible_ softsynth into 4k, at least. Still, I'd guess nobody uses plain .xm files either ;-)

kb: by the way, will part 5 of the softsynth tutorial ever come out? :-)
added on the 2004-04-30 01:21:21 by Sesse Sesse
kb :: you wrote your own tracker (or the other kind of seqencer) or maybe you have plugin that export patterns from some "commercial" music program?
added on the 2004-04-30 21:25:26 by ninja ninja
As stated on www.theproduct.de the guy wrote a plugin for logic audio (a commercial tool).
added on the 2004-04-30 21:45:30 by hitchhikr hitchhikr
The first version was a standalone MIDI synthesizer app which was connected to Logic Audio (or any other sequencing app) via MIDI loopback, you can do that with a special driver (eg. Midiyoke) or simply by using a cable to connect the computer's MIDI out back to the in.

I then exported .mid files from Logic which ran through a converter to combine them with the patch data and re-sort them for better packing (look at my 2nd article for more)

The current version is a VSTi plugin for use in any VST host app that supports multi-timbral plugins. To export a song I have that button which records all data going to the synthesizer, that means: press that button, play the whole song once, press the button again and there you have the final music file.
added on the 2004-04-30 23:34:48 by kb_ kb_
how do you feel about Emagic being snapped up by Apple by the way ?
what combination of generators & filters do you guys use for making drum sounds? For the kick - drum the best I've managed to get is a sinewave with frequency and amplitude envelopes, add a little noise on top and lowpass it. (adding to of these with different ammounts of noize & filtering makes the sound more "aggressive"). It produces a nice deep sound, but it just does not sound just "right"... How can i make it sound more "real"??
For the snare, i've found nothing even close to being acceptable...

(this is my first softsynth btw. The intro will (hopefully) be released in a weeks time)
added on the 2004-05-01 04:29:57 by Wcf Wcf