Dear list,
I can not figure out why instr. 1 does sound different to instr. 2?
The only thing I changed is to use "+" instead of "sum" in instr. 2.
My Csound-version is:
6.18 (double samples) May 30 2022 (which I compiled from git-sources on Ubuntu 20.4)
Has anyone any idea?
Best,
Jan Jacob
<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 128
nchnls = 2
0dbfs = 1.0
instr 1
aout = 0
aout0 oscil .2, 220
aout sum aout, aout0
aout1 oscil .2, 440
aout sum aout, aout1
outs aout, aout
endin
instr 2
aout = 0
aout0 oscil .2, 220
aout = aout + aout0
aout1 oscil .2, 440
aout = aout + aout1
outs aout, aout
endin
</CsInstruments>
<CsScore>
i1 0 1
i2 1.2 1
</CsScore>
</CsoundSynthesizer>
ST_Music
(ST Music)
September 25, 2022, 7:42pm
2
Hi Jan,
I can neither hear nor see a difference. Perhaps something about the way you are playing this back is not always uniform?
Anyways, for me - when in doubt, render to file and view in an editor. You’ll see both waves are virtually identical.
Here is an image :
https://drive.google.com/file/d/1iY8iAAZAfmNxEvB0NFcQi13M0pLD1j2R/view?usp=drivesdk
Scott Daughtrey
ST Music
https://soundcloud.com/stoons-1
https://youtube.com/channel/UCGhwmkS1uWmX6mhTIQ0IDsg
john
(john)
September 25, 2022, 11:39pm
3
A bug in sum was fixed recently which could explain this
Get TypeApp for Android
Using sum is convenient as you don’t have to bother with
the “+” sign every time. Very good.
-PBS
ST_Music
(ST Music)
October 1, 2022, 1:51am
5
I’m a programming noob, so I have to ask this question :
“sum” requires typing 3 characters, “+” is only one, so in what way is sum more convenient for you
Scott
ST Music
https://soundcloud.com/stoons-1
https://youtube.com/channel/UCGhwmkS1uWmX6mhTIQ0IDsg
john
(john)
October 1, 2022, 10:31am
6
Each call to + is an opcode and has a certain amount of overhead. Sum is one opcode do has less overhead of adding many arguments. The effect marginal
The other answer is to do with coding style/preference
Get TypeApp for Android
I’d say for a very large number of arguments, there may be some gain in using sum. Part of the trouble with this opcode in recent releases is that it was updated
to be more efficient, but some bugs were introduced as part of this. Now it should be good.
The gains of using sum depend on the number of inputs. With 16 inputs I see a speedup of ~2.6x when using sum, with 8 inputs, ~1.9x and with 4 the speedup is reduced to 1.2x. With 3 or less there is no measurable speedup. This is with -mavx
Line of code is shorter. I don’t use it all the time though.
Sometimes I just like seeing the “+” as part of it all, overall
sense of the look of it all. But that’s just me.
-PBS
Oh, now that’s even better. I like that.
-PBS
Yes. I did a 32 band Fourier sum where I used that. It was very handy.
-PBS
ST_Music
(ST Music)
October 1, 2022, 9:08pm
12
Noob here again with another quick question.
So, if I’m understanding this correctly, adding two things together like asig + asig is fine, whether + or sum the opcode is getting called once.
However, if adding multiple things together, in general sum is preferred since the opcode only has to be called once.
Is that the basic idea?
Scott Daughtrey
ST Music
https://soundcloud.com/stoons-1
https://youtube.com/channel/UCGhwmkS1uWmX6mhTIQ0IDsg