News for hackers. Stuff that matters.
Re:Show HN: Koelsynth – a simple FM synthesis library by driggs on Saturday November 11, 2023 @09:20PM (#38236624)
Why is it that FM synthesis was so well-suited to relatively simple early digital hardware (eg. Yamaha's DX/TX line)?

Does that also make for relatively simple software FM synthesis?

Re:Show HN: Koelsynth – a simple FM synthesis library by ClimaxGravely on Saturday November 11, 2023 @11:39PM (#38237357)
I think the reason the DX stuff broke out besides the different sound was they could do it on a cpu at the time and have a lot of voices without incurring the hardware transitor cost for each voice as much. I'm not an audio programmer but I've heard trying to emulate subtractive synthesis can be difficult.

In the github section the author somewhat alludes to this : "Next, there is "subtractive" synthesis (not really a surprise after "additive" synthesis, is it?). It involves taking a waveform with many harmonics (triangular wave, sawtooth wave, etc) and using a time-varying filter to remove the higher harmonics. I tried that too once, but it wasn't great either, at least for the effort involved in coding and tweaking the parameters."

Re:Show HN: Koelsynth – a simple FM synthesis library by kevin_thibedeau on Sunday November 12, 2023 @01:20AM (#38237810)
FM synths used dedicated ASICs to generate audio. It wasn't possible for mainstream CPUs of the era to do it in real time.
Re:Show HN: Koelsynth – a simple FM synthesis library by ClimaxGravely on Thursday November 16, 2023 @09:21PM (#38298529)
Sorry my mistake, I was trying to say that the individual oscillators/filters/etc add up in cost (at least that's often what analog synth companies say when people ask about low voice counts)

I'm assuming an ASIC has a similar cost savings to a CPU or FPGA?

Re:Show HN: Koelsynth – a simple FM synthesis library by bzzzt on Sunday November 12, 2023 @06:17AM (#38239254)
> I've heard trying to emulate subtractive synthesis can be difficult.

Just filtering frequencies isn't that difficult, but to get a digital filter sounding equivalent to a specific analog audio filter is an art. There's an entire industry trying to recreate the 'character' of certain imperfections found in old synthesizers. Some FM synthesizers also have subtractive filters. There are even analog synthesizers with FM so it's not an either/or.

Re:Show HN: Koelsynth – a simple FM synthesis library by ClimaxGravely on Thursday November 16, 2023 @09:19PM (#38298514)
It's funny, the whole analog vs digital thing I personally can't tell the difference that often with EXCEPT the filter.

I have a digital synth with a digital filter that's great but I feel like I have to put a lot more work into the filter parameters to make it sound good.

I also have a digital synth with an analog filter and I find I don't have to play with the filter much at all. It sounds pretty good in pretty much every case.

Re:Show HN: Koelsynth – a simple FM synthesis library by mrob on Sunday November 12, 2023 @06:24AM (#38239293)
The killer feature of FM synthesis is generation of inharmonic sounds. Classic analog waveforms (sawtooth/square/triangle/sine) are all perfectly harmonic, i.e. the frequencies of the higher harmonics are at integer multiples of the fundamental. Subtractive synthesis shapes the amplitudes of these harmonics but doesn't add any new ones.

Subtractive synthesis is still musically useful, because most musical instruments are harmonic or almost harmonic, but tuned percussion is a notable exception. It's very difficult to get a good bell sound out of subtractive synthesis. FM can produce inharmonic sounds, where the higher harmonics are at non-integer multiples of the fundamental. It's much easier to get good bell/chime sounds out of FM synthesis.

And the "almost harmonic" instruments are very popular (all plucked or hammered string instruments, with the inharmonicity more pronounced with thicker strings, so especially bass and piano). By adding a little inharmonicity, FM synthesis can produce more realistic versions of these sounds than subtractive synthesis.

Additive synthesis can also produce inharmonic sounds, but this requires an oscillator for each harmonic, so back when FM synthesis first hit the market this was unreasonably expensive.

Re:Show HN: Koelsynth – a simple FM synthesis library by ClimaxGravely on Thursday November 16, 2023 @09:22PM (#38298539)
Thanks for the info!

I've certainly never been able to make a decent bell sound with a subtractive synth. As for FM synths, I rarely have to because there's so many good presets out there but I've accidentally made bell patches just messing around.

Re:Show HN: Koelsynth – a simple FM synthesis library by SonOfLilit on Sunday November 12, 2023 @02:16AM (#38238082)
FM is designed to be calculated digitally, and with a few hacks (like a lookup table for a function involving sin() and log()) can be calculated very cheaply.

In the DX7 it was done on custom digital circuitry, but modern CPUs are just as happy to do a few additions and a table lookup once in a while.

Re:Show HN: Koelsynth – a simple FM synthesis library by graphitout on Sunday November 12, 2023 @07:55AM (#38239695)
Additive synthesis was a pain to configure. I had to model and estimate the behavior of each harmonic. It was too much effort.

Subtractive synthesis didn't work that well for me either. I believe my implementation of the variable cut off lowpass filter had something to do with it.

FM Synthesis worked reasonably well without much effort. Implementation was rather straightforward.

Re:Show HN: Koelsynth – a simple FM synthesis library by atoav on Monday November 13, 2023 @02:25AM (#38247827)
The typical way FM synths (and for example function generators) generate a sine wave would be DDS (Direct digital synthesis).

You basically just have an array with all the values of a sine inside (or a quarter of a sine if you want to save memory) and then you jump through that array based on a phase accumulator (basically a counter). The amount by which you increment that phase accumulator (=phase step) determines the pitch of the resulting sine wave that this lookup gives you.

This operation is quite cheap, I once made a osciallator with 9 of these on an Arduino Nano.

Now the clou is that you could just add some amount of the result of another of those sine lookups to the phase accumulator, which results in the typical FM sound.