I tried to progam subharmonic sounds. My first attempt was brute force - simply add all fundamentals:
aSine1 = poscil:a(kAmp/(1^iDamp), kFreq/1 ) // fundamental
aSine2 = poscil:a(kAmp/(2^iDamp), kFreq/2 ) // harmonics
aSine3 = poscil:a(kAmp/(3^iDamp), kFreq/3 )
aSine4 = poscil:a(kAmp/(4^iDamp), kFreq/4 )
aSine5 = poscil:a(kAmp/(5^iDamp), kFreq/5 )
aSine6 = poscil:a(kAmp/(6^iDamp), kFreq/6 )
aSine7 = poscil:a(kAmp/(7^iDamp), kFreq/7 )
aSine8 = poscil:a(kAmp/(8^iDamp), kFreq/8 )
aSine9 = poscil:a(kAmp/(9^iDamp), kFreq/9 )
aSine10 = poscil:a(kAmp/(10^iDamp), kFreq/10)aSine = aSine1 + aSine2 + aSine3 + aSine4 + aSine5 + etc…
outall (aSine)
iDamp is a damping factor, it might be 1 or 2, to make the subharmonics more or less quieter. So partial 5 gets a volume of only 1/5 (or 1/25) of the fundamental and a frequency of 1/5 of the fundamental. This is, how I understood subharmonics.
This works fine. In a spectrum analyzer, I see a large peak, and more peaks to the left, getting gradually quieter.
But this is brute force, so I tried a more elegant loop, following the example, that I found here. It looks like this:
kIndex = 1
while kIndex < 32 do
aOuts[kIndex-1] = poscil:a(kAmp/(kIndex^iDamp), kFreq/kIndex)
kIndex += 1
odaRes = sumarray(aOuts)
out aRes
But - big surprise! - it sounds completely different and looks also complete different in an analyzer.
What am I doing wrong?