Cabbage Logo
Back to Cabbage Site

A problem with combining inharmonic partials

I tried to combine some inharmonic partials using different copies of one instrument playing many sine waves with GEN10 and using another instrument adding them together inside it with some GEN10s, but they don’t sound quite the same.
this is my code:
trying to add inharmonic partials.csd (3.2 KB)
What am I doing wrong? can you help me?

Without looking too deep into your code I imagine that you’re not recreating the same sounds. I see some distortion taking place too which will also alter the timbre of the sound. My advise would be to simplify the example, strip it all back and start building up again. There is no reason, as far as I can tell, for the sounds to be different…

I have already had a simplified example I wanted to send but I accidentally sent the more complicated one:
trying to add inharmonic partials.csd (1.2 KB)

These sounds pretty close to me, but I don’t think all the harmonics were correct. Here’s a further simplified version that sounds closer. trying to add inharmonic partials(1).csd (1.0 KB)
There is some variation in volume between the two tones. I think this has to do with how Csound sums and normalizes partials in GEN10 but I can’t say for certain without looking deeper into it.

I’m pretty sure all the partials (harmonic and inharmonic) were correct. Which one do you think wasn’t correct?
I made the notes in your file the same amplitude but it still sounds differently. quite weird. Does someone have any idea why it happens, which version is the right addition of harmonics and how to fix this?
trying to add harmonic partials.csd (1004 Bytes)

I don’t think it’s ever a good idea to accommodate clipping. If you reduce the amplitude of the original harmonics it sounds better.

instr 1
iamp = p5*.5
ifreq = p4
asig poscil iamp, ifreq, p6
     outs   asig, asig
endin

I still hear a slight difference, but I think it may be psychological as I’ve been listening too long for differences! When I do an FFT of the two tones they look identical.

There may be some rounding errors taking in place somewhere, and the amplitude of the second tone is not quite right, that would need looking at. Back to your question, if you need control over each partial’s amplitude phase or frequency, it’s probably best to use a bank of oscillators. Otherwise use a function table that combines partials for you.