Advertisement

Programming an Additive Synthesiser - Reverb

Started by August 29, 2011 12:41 PM
3 comments, last by Sappharos 13 years, 5 months ago
Here's a rudimentary additive synthesiser I made using C++ and OpenAL: http://dl.dropbox.co...4/add-synth.zip

The program produces basic, organ-like tones (including square/sawtooth waves). There are 12 different signals the user can toggle on/off by clicking the small squares in the top 2 panels. They can also adjust the envelope on each signal (the blue arrows) and zoom in/out of the waveform using the small blue sliders at the very bottom.

I'm eventually aiming for realistic-sounding instruments such as bells and pianos, but obviously I'm a long way off at the moment. No problem. :)

The sound is stored as an array of [font="Courier New"]short[/font] values. What I'm looking for is a way to apply a reverb effect to this without causing a ridiculous amount of feedback when the frequencies coincide. What I tried was this:

[source lang="cpp"]
for (int i = 0; i < soundArraySize; ++i)
if (i > 350)
soundArray += soundArray[i - 350] * 0.85f;
[/source]

Making 0.85f lower results in no effect, keeping it makes certain frequencies resonate with the reverb and go crazy. I just want a simple echo so instruments fade out instead of stopping sharply. How is it normally done?

Edit: Would this be more suitable in a different forum?

Here's a rudimentary additive synthesiser I made using C++ and OpenAL: http://dl.dropbox.co...4/add-synth.zip

The program produces basic, organ-like tones (including square/sawtooth waves). There are 12 different signals the user can toggle on/off by clicking the small squares in the top 2 panels. They can also adjust the envelope on each signal (the blue arrows) and zoom in/out of the waveform using the small blue sliders at the very bottom.

12 partials aren't much for additive synthesis; lower pitches are going to sound dull. For example, 12*60 Hz=720 Hz: the highest harmonic would be a medium frequency.

I'm eventually aiming for realistic-sounding instruments such as bells and pianos, but obviously I'm a long way off at the moment. No problem. :)
[/quote]Bells? Do you have inharmonic partials? If you do, how can they be controlled?

The sound is stored as an array of [font="Courier New"]short[/font] values.
[/quote]On modern hardware, 32 bits are cheap and 64 bits are mainstream; 16 bit samples are outright nostalgic.

What I'm looking for is a way to apply a reverb effect to this without causing a ridiculous amount of feedback when the frequencies coincide. What I tried was this:

[source lang="cpp"]
for (int i = 0; i < soundArraySize; ++i)
if (i > 350)
soundArray += soundArray[i - 350] * 0.85f;
[/source]
[/quote] This is a comb filter, not a reverb. A reverb has many more taps, spread over such a long time that it's normally implemented with clever approximations rather than as a FIR filter; here, instead, you have a single tap and the filter evidently has a gain of 1.85 at every period that is a multiple of 350 samples. At a sampling rate of 44.1 kHz, it's 126, 63, 31.5 and 15.75 Hz.

Making 0.85f lower results in no effect, keeping it makes certain frequencies resonate with the reverb and go crazy. [/quote] It's still a comb filter, whatever coefficient and audio-range delay you choose. Try to use it as a proper filter, to alter timbre, because it will never sound like a reverb.
I just want a simple echo so instruments fade out instead of stopping sharply. How is it normally done?
[/quote] An echo is something else still: it has two (or very few) taps, but a longer delay (say half a second or more). Imagine that, as the delay increases, the resonant and notch frequencies of your comb filter are pushed to the subsonic range, leaving only a separate echo of the source signal without significant filtering.
I guess you are asking for a way to begin and end notes: it is normally done by multiplying the oscillator output by an envelope, usually with an ADSR structure.

Omae Wa Mou Shindeiru

Advertisement

12 partials aren't much for additive synthesis; lower pitches are going to sound dull. For example, 12*60 Hz=720 Hz: the highest harmonic would be a medium frequency.

Bells? Do you have inharmonic partials? If you do, how can they be controlled?

There will be more than 12; initially I just chose enough that the boxes would comfortably fit on the screen without scrolling. I read somewhere that most realistic sounds would require on the order of hundreds of partials - I'd need to figure out some way of generating the values for these according to input parameters, so I don't have to manually change so many values each time I want a new sound.

At the moment, the frequencies are hard-coded. Yeah, I know, I know. :)
I had found this table of frequencies, or one similar to this: http://www.computerm...l.tutorial.html. It resulted in a bell-like sound but... what's the underlying relationship between these values? How could it be put into code and adapted to use many more partials?

A reverb has many more taps[/quote]
This is something I've been wondering too: How would I combine many taps, all at the same frequency into the final sound without the volume increasing about 20 times? Just adding the values seems stupid. Or put a different way, how to mix multiple waveforms properly? So far I've just been adding them and dividing the final amplitude by the number of partials.

An echo is something else still: it has two (or very few) taps, but a longer delay (say half a second or more). Imagine that, as the delay increases, the resonant and notch frequencies of your comb filter are pushed to the subsonic range, leaving only a separate echo of the source signal without significant filtering.
I guess you are asking for a way to begin and end notes: it is normally done by multiplying the oscillator output by an envelope, usually with an ADSR structure.
[/quote]
I looked at ADSR but the release stage decreases the amplitude linearly with time, instead of reducing it by a factor every few seconds. Isn't the desired effect (a gradual dying away of the tone) a natural product of reverb?
Nothing says ADSR or any variant of it has to be done linearly. You can apply whatever curve you want to your envelope segments. Honestly though, you'll find even doing it linearly will sound very good.

Nothing says ADSR or any variant of it has to be done linearly. You can apply whatever curve you want to your envelope segments. Honestly though, you'll find even doing it linearly will sound very good.



I'll try that. :) I'm thinking of a bell or piano, which dies off quickly soon after release and then trails on for a long time.

This topic is closed to new replies.

Advertisement