Question

So I'm coding a synthesizer from scratch in C# using NAudio. I've gotten it play different frequencies, which is cool, but I notice that the higher pitches are significantly louder than the lower pitches. Is that due to this effect:

http://en.wikipedia.org/wiki/Equal-loudness_contour

Or am I doing something wrong when I'm generating the sine wave? How would I implement an Equal-loudness contour curve if it is indeed necessary?

Thanks

My Code:

NAudio expects a buffer filled with floating point values in the range of -1 to +1 to represent the waveform.

Generating the sine wave:

buffer[n + offset] = (float)(Amplitude * Math.Sin(angle));
angle = (angle + angleIncrement) % (2 * Math.PI);

Setting a frequency:

public double Frequency
{
    set
    {
        angleIncrement = 2 * Math.PI * value / sampleRate;
    }
    get
    {
        return angleIncrement * sampleRate / 2 / Math.PI;
    }
}
Was it helpful?

Solution

Controlling the amplitude of the audio from your synthesizer based on equal-loudness contours is probably not what you want.

In theory, you would need to know the absolute level (SPL) produced by the speakers in order to choose the appropriate contour. In practice, a bigger issue would be when you extend your synthesizer to use complex waveforms instead of merely pure tones, possibly processed by filters etc. The equal-loudness contours are based on pure tones, and when you generate complex signals (i.e. containing many frequencies) you would instead need a loudness model to estimate the loudness of your synthesized sound.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top