Create orchestra with additive and subtractive synthesis of several minutes

Ok but use that to paste the code itself, not the link to it! Better to keep things in this thread than having to rely on external services, things can easily get lost.
So future users will still be able to read this conversation for learning!

Btw the link above works now

ok Looks like I managed to get it preformatted. ok I learned but, except that if I paste the code I get a very long response if it’s not a problem I’ll post the codes directly :slight_smile:
Thanks very much for the help

No worries, it’s important to understand if there are issues on the forum itself since it’s still relatively young. So feel free to ask if you have any doubt or issue.
If your code is very long you could also use the two things in combination, so preformatted text inside a summary

My really long code
instr 1

kamp = .6
kcps = 440
ifn  = p4

asig oscil kamp, kcps, ifn
     outs asig,asig

endin

instr 2

kamp = .6
kcps = 440
ifn  = p4

asig oscili kamp, kcps, ifn
     outs asig,asig

endin

Hi again Mau, I was able to download the file this time. Can you be more specific on what you want to change or achieve? Apologies, I guess I’m just not exactly sure.

what I want to achieve is the same exercise as instr 1 to 7 but with the option to filter the signal for each group of frequencies that glide. instr 8 must play starting from a triangular wave sound and then descend after the freq of 1000, 2000 up to 4000hz in a sawtooth wave through a filter.
same in concept as your example of application of the freq. of 200hz which changes from sawtooth to square wave in 3 or 5 seconds.
Which would be the basic exercise of instr 18! I hope that with the translator it can be clear :slight_smile: Thanks for All

Hello to you St Music. I also sent you a private message about what I hope to achieve is easier to understand.
Thanks, I’m waiting for your news :slight_smile:

Hi, sorry for the delay. I don’t see the private message for some reason, maybe I’m not looking correctly? You can try sending again or post here and I’ll try to help you figure things out.

One thing I noticed you mentioned if I understand correctly - you want to go up in pitch as a triangle then down as a saw filtering to square? Perhaps others might have a better suggestion but I don’t know how to properly filter from a triangle to a saw, seems tricky.

I can think of other ways to do that, such as morphing or interpolating between the tables but I’ll wait to hear from you before I make any suggestions. Talk soon😉

@maupetrucci if you want you can send me a message in Italian with your idea and I can try to translate it. I cannot help with the Csound code at the moment as I am super busy, but I can probably translate it in English better than an automatic translator, those sometimes can fail (or be imprecise) with technical stuff.

hi st. No let me explain :slight_smile: . in instr 8 I should do the same thing as instr 18 (which is the example of the subtractive synthesis that you carried out) but using the frequencies that I chose as you can see on the last file you downloaded on instr 8.
So I have a glissado that it starts from a sawtooth wave and ends with a square wave through subtraction for each kfreqinviluppo e onwards such as kfreqinviluppo2, kfreqinviluppo3 etc…
Example: fkreqinviluppo from 50hz to 400hz sawtooth wave then at 1000hz it starts to change to square and go down to 50hz again. Thanks, I hope it’s very clear now :slight_smile:

Ok, I think I get it now. The issue here with instr 8 is you have 4 oscils, each with seperate output names, but you have 20 filters many which share the same name which I don’t think will work. I think that’s why you are getting odd results.

There are a few ways around this. One would be to rename them aflt1 thru aflt 20, then to add them all together as you have done on line 103 (aquadra).

Another would be to have one oscil & 5 filters in instr 8. Then to modify the 4 envelopes:
kfreqinviluppo linseg p6, p3/5, p7, p3/5, p8 , p3/5, p9, p3/5, p10, p3/5, p11, p3/5, p12

You could then use 4 score entries:

i8 80 30 .5 3 50 100 400 1000 400 100 50
I8 . . . . 2000 500 200 and so on

And finally, but a little more advanced, you could probably create something called an UDO which would simplify the code. I need to give it some more thought unless someone here has a better idea.

I’ll try to look at this again later tonight. It’s not meant as a criticism but sometimes it’s hard for me to understand the intent of another person’s code, I’m not a very experienced user. And there are some small problems I see, for example with:
kfreqinviluppo linseg 50, p3/5, 100, p3/5, 400 , p3/5, 1000, p3/5, 400, p3/5, 100, p3/5, 50

you use p3/5 but get are 7 different frequencies. So it will never reach the final one (50).

Just to be sure - with instr 8 do you want all 4 oscil to be playing at the same time, added together? Or do you want to achieve something like at the start of the score using instr 1 - 7?

hello st :-).
So the idea is to make them play starting when the previous wave reaches its maximum frequency, the 2nd wave must start, etc.

Obviously I would like there to be no distortion. In order not to distort each subsequent oscili it must begin with a crescendo envelope and the release with a slight fade out.

However, on this I would also like your advice on what is the best solution to make each subsequent oscili heard (which starts at the maximum freq of the previous one )without creating too much chaos.
Thank you so much you are a genius :slight_smile:

Ps. My example :slight_smile ;

instr 8
  kfreqinviluppo linseg     50, p3/7, 100, p3/7, 400 , p3/7, 1000, p3/7, 400, p3/7, 100, p3/7, 50
  asega   oscil,  p4, kfreqinviluppo, p5
  kfreqinviluppo2 linseg  2000, p3/7, 500, p3/7, 200 , p3/7, 100, p3/7, 200, p3/7, 500, p3/7, 2000
  asega2   oscil, p4/2, kfreqinviluppo2, p5
  kfreqinviluppo3 linseg  200, p3/7, 300,  p3/7, 600,  p3/7, 3000, p3/7, 600, p3/7, 300, p3/7, 200 
  asega3   oscil, p4/3, kfreqinviluppo3, p5
  kfreqinviluppo4 linseg  4000, p3/7, 700, p3/7, 400 , p3/7, 300, p3/7, 400, p3/7, 700, p3/7, 3000
  asega4   oscil, p4/4, kfreqinviluppo4, p5
  ; filtro le frequenze indesiderate
  aflt1 = butbp(asega, kfreqinviluppo,      1)
  aflt2 = butbp(asega, kfreqinviluppo * 3,  1)
  aflt3 = butbp(asega, kfreqinviluppo * 5,  1)
  aflt4 = butbp(asega, kfreqinviluppo * 7,  1)
  aflt5 = butbp(asega, kfreqinviluppo * 9,  1)
  aflt6 = butbp(asega2, kfreqinviluppo2,     1)
  aflt7 = butbp(asega2, kfreqinviluppo2  * 3, 1)
  aflt8 = butbp(asega2, kfreqinviluppo2  * 5, 1)
  aflt9 = butbp(asega2, kfreqinviluppo2  * 7, 1)
  aflt10 = butbp(asega2, kfreqinviluppo2 * 9, 1) 
  aflt11= butbp(asega3, kfreqinviluppo3,     1)
  aflt12 = butbp(asega3, kfreqinviluppo3 * 3, 1)
  aflt13 = butbp(asega3, kfreqinviluppo3 * 5, 1)
  aflt14 = butbp(asega3, kfreqinviluppo3 * 7, 1)
  aflt15 = butbp(asega3, kfreqinviluppo3 * 9, 1)
  aflt16 = butbp(asega4, kfreqinviluppo4,     1)
  aflt17 = butbp(asega4, kfreqinviluppo4 * 3, 1)
  aflt18 = butbp(asega4, kfreqinviluppo4 * 5, 1)
  aflt19 = butbp(asega4, kfreqinviluppo4 * 7, 1)
  aflt20 = butbp(asega4, kfreqinviluppo4 * 9, 1)   
  ;compenso l'ampiezza tra onda a dente di sega e quadra 
  aquadra  = (aflt1 + aflt2 + aflt3 + aflt4 + aflt5 + aflt6 + aflt7 + aflt8 + aflt9 + aflt10 + aflt11 + aflt12 + aflt13 + aflt14 + aflt15 + aflt16 + aflt17 + aflt18 + aflt19 + aflt20) * 1.8
  kfade = linseg(0, p3/3, 0, p3/3, 1, p3/3, 1)
  ;crea una dissolvenza tra sega e quadra
  aout  = ntrpol(asega, aquadra, kfade)   
  outs aout, aout
endin

hi st music I added another instrument. Everything seems ok to me but it doesn’t work in patches it’s a simple fixed spectrum additive synthesis.

Function 1 refers to sine which is what I need. but it doesn’t sound like everything. Ps have you already viewed the previous exercise in the post?
Thank you infinitely

instr 9 ;Additiva Spettro Fisso

iamp = p4 ;ampiezza

ifreq = p5 ;frequenza base

a9 poscil iamp* 2,ifreq,1 ;freq fondamentale

a10 poscil iamp*.9,ifreq*1.2,1

a11 poscil iamp*.8,ifreq*1.4,1

a12 poscil iamp*.7,ifreq*1.6,1

a13 poscil iamp*.6,ifreq*1.8,1

a14 poscil iamp*.5,ifreq*2,1

a15 poscil iamp*.4,ifreq*2.2,1

a16 poscil iamp*.2,ifreq*2.4,1

outs a9+ a10 + a11 + a12 +a13 +a14 +a15 +a16, a9+ a10 + a11 + a12 +a13 +a14 +a15 +a16

endin
score
;Additiva A spettro Fisso
i9   110    5   .1   50
i10  115    5   .1   50
i11  120    5   .1   50
i12  125    5   .1   50
i13  130    5   .1   50
i14  135    5   .1   50
i15  135    5   .1   50
i16  135    5   .1   50

Hi Mau. I still need to answer the previous question, it’s a little more involved so need to think of the easiest, cleanest solution. Will try to look at it later tonight.

I’m not sure about your newest question. First of all 50 Hz is a very low frequency for a sine wave so it’s difficult to hear. It might be better to start with a higher base frequency. And I’m not sure why you chose certain frequency ratios like ifreq * 1.2. Are you deliberately looking to add inharmonic frequencies?

Here’s an example that would use additive synthesis to create a simple saw, similiar to what you did before:

giSine = ftgen(1, 0, 4096, 10, 1)

instr 9 ;Additiva Spettro Fisso

iamp = p4 ;ampiezza

ifreq = p5 ;frequenza base

a9  poscil iamp * 4, ifreq, 1 ;freq fondamentale

a10 poscil iamp * 2, ifreq * 2, 1

a11 poscil iamp * 1, ifreq * 3, 1

a12 poscil iamp * .5, ifreq * 4, 1

a13 poscil iamp * .25, ifreq * 5, 1

a14 poscil iamp * .125, ifreq * 6, 1

a15 poscil iamp * .0625, ifreq * 7, 1

a16 poscil iamp * .03125, ifreq * 8, 1

aOut = a9 + a10 + a11 + a12 + a13 + a14 + a15 + a16 
outs aOut, aOut
endin

</CsInstruments>
<CsScore>
;Additiva Spettro Fisso
b-110
i9   110   6   .1   110

It might be cleaner/easier to read using a more simple instr and instead adding a few extra lines and parameters in the score. Here’s an example that adds the harmonics in one at a time to create a saw:

giSine = ftgen(1, 0, 4096, 10, 1)

instr 9 ;Additiva Spettro Fisso

iamp  = p4 ;ampiezza

istr  = p5 ;forza armonica

ifreq = p6 ;frequenza base

imult = p5 ;frequenza multiplo

aSig  = poscil(iamp / istr, ifreq * imult, 1) ;freq fondamentale

aEnv  = linseg:a(0, .05, 1, p3 - .1, 1, .05, 0)

outs aSig * aEnv, aSig * aEnv

endin

</CsInstruments>
<CsScore>
b-110
;Additiva Spettro Fisso
;              p4  p5  p6
; 
i9   110   22  .4   1  110
i.   112   20  .    2  .
i.   114   18  .    3  .
i.   116   16  .    4  .
i.   118   14  .    5  .
i.   120   12  .    6  .
i.   122   10  .    7  .
i.   124    8  .    8  .
i.   126    6  .    9  .
i.   128    4  .   10  .

</CsScore>
</CsoundSynthesizer>

Again I’m not sure exactly what you want to do with instr 9. The nice thing about Csound is there are many ways to do things so it’s just a matter of understanding what your goal is.

Best wishes,
Scott

Hi Scott.
So my intent is to add a fixed spectrum additive as in instr number 9 that you did. and now create a variable spectrum additive with g buzz as in instr 10.

I would like to make instr 10 more interesting so as to make it play longer.

Meanwhile the instr 8 convinces me enough but if you can take a look at it as I made it. the idea is always the one I listed in the previous answer regarding instr8. Thank you so much :slight_smile:

Good morning St.music I wish you my best wishes for a happy new year.
I wanted to know if you had taken a look at the latest work I posted.
Thanks again :slight_smile: