Create orchestra with additive and subtractive synthesis of several minutes

Greetings .
I wanted some advice on how to lengthen this starter patch to make it more interesting. Remaining in the additive synthesis with fixed and variable spectrum plus a subtractive one at most. How would you modify and add to bring it to a good duration of at least 4 minutes?

Then based on the number of samples I’m going to set the range of dbfs. With regard to the patch, expect to add equal frequencies like 200 202 204 etc. every few seconds, all having the amplitude of a square wave and after like 40 60 seconds do the same thing but setting after the gen10 or 9 harmonics with an amplitude of a 'triangular wave or tooth signal .
And then in the last subtractive sound in descending order only the odd with an increasingly decreasing amplitude. I just find it a bit hard to do it completely alone, and for this I was also looking for an opinion on how to tell csound to play in series only even frequencies with harmonics of a square wave instead of writing each string for each minimum frequency as reported above that is 202 ,204 ,206 up to type 6khz for example a huge will come out.

In short, on the book I stopped at the first two chapters and the subtractive, but I haven’t found a way (or I’ve seen it wrong) to simplify the process a bit that I would like to do.
ps.I put in the starter patch I’m building on hoping to build it up to like 5 minutes worth of sounds.
Thanks for all

1 Like

I’m not sure exactly from your description what you fully intend to do but a few ideas. Hopefully some of those more familiar with Csound can help.

First, your file was very heavily distorted for me as there were many samples far out of range. When using 0dbfs, a single oscillator with an amplitude of 1 is the maximum before samples go out of range and distortion occurs. You have many oscili that use amp values in the hundreds or thousands.

If using many osc then all combined amplitudes should have a value of less than 1. Older books and files not using an orchestra setting of 0dbfs = 1 will use very large raw values, up to 32,767:

With 0dbfs = 1, all amp values should be between 0 and 1. They can be decimal, like .36, .6, or .014.

I modified your file to reflect more realistic values while trying to still somewhat keep the relative values. It now has a maximum amp value of .8, or 80% of full amplitude when played, to avoid distortion.

I’m not sure what you want to do in terms of adding frequencies, I suspect it’s just me or a language barrier. You mention things like adding harmonics of a square wave. I may be off base but one way you could achieve this is by morphing thru tables, or you could keep adding frequencies thru the score.

Here’s an example of creating the first several harmonics needed to create a basic type of square wave by morphing thru tables:

Chapter 4A of the Csound FLOSS manual might have some information you would find useful. You can download it here or read it online:

You can also download all the csd
files here:

Hope that helps a bit,

Thanks scott so much for your advice and for fixing the amplitude problem. I’ll go straight to the point with my post by asking you: what would you do to extend this patch to 4 minutes like using fixed and variable spectrum additive synthesis followed by a subtractive one?
My idea is to broaden the one you corrected and to sensibly insert various frequencies (fixed additive \ variable) and then filter them with a butterworth filter (subtractive) This would be enough for me. Thank you so much for everything and for your vision of this orchestra.

Hello boys .
the first exercise bringing it to a minute of which I would like to understand if I have done well enough. I wanted to create envelopes in freq. taking advantage of the various harmonics of gen 10.

  1. are they good as I set sin wave, triangular and saw tooth?
  2. I would like to make the spectrum of each frequency that plays in the envelope more complex in a short time, keeping myself on the wave established in the score. How can I give advice?
  3. if I wanted to generate the square oda differently using a subtractive synthesis starting from the sawtooth that I have already composed, how would you do it?
    Ps other tips to increase the duration of this patch are welcome.
    Many thanks to whoever will help me

Hello again.

I’ll try to help as I can, but I’m not a very advanced Csound user. There are some problems with your file affecting the results.

You are generating many repetitive ftables in the score and they unnecessarily repeat. Also, as they are generated in the score, the ftables overwrite each other affecting the result.

In the score you indicate sine, triangle and saw but it is instead using only the saw waveform since the saw ftables have overwritten the others before starting to play the instruments in the score. So from time 0 until the end, pretty much every single waveform produced is a saw. If rendered to audio and viewed in an audio editor there are no sine or triangle waves, only saw. And if you listen closely you can also hear only the saw waveform.

It is only necessary, and much safer, to create the wave ftables “globally”, which generates the different waveforms only once before compiling the score. Also, giving each table a separate number avoids one overwriting another.

I modified your file so that each wave table is generated only once. All instruments can use and share a single ftable. In the score you can see that p5 will allow the instrument to choose between sine, triangle, saw or square. And in each instrument, the oscili uses p5 from the score to select the table.

This simplifies the code & now each section of the score is producing the correct waveforms.

It may take you some time to fully understand but hopefully you can see how much simpler this is to accomplish and also much easier to read.

Try looking this example over first and then perhaps I or someone else can help you accomplish what you would like to do next.

Here is a link to the example:

You can also find some good examples in the Csound FLOSS manual, such as:

Look at example 03D04.

If you have questions feel free to ask.



Hello scott. Thanks
I changed the value from p3/3 to p3/4 since there are 4 frequencies and not 3 and so to get to the precise note I speeded up the speed. should it be more correct like this?. If I wanted to add something to these glissando to make the exercise fuller and more interesting in the first minute, what would you recommend?

Finally I would like to start from the sawtooth wave to obtain a square wave through subtractive synthesis. a subtractive synthesis that only removes the useless harmonics. I’m reading something to figure out how to do this.

Hi Mau,

I’m not aware of any single filter that would remove all unwanted frequencies in one pass.

To create a square from saw, one method would be to use several filters to remove all frequencies except the ones you wanted to keep. Each individual filter will keep a specific frequency and eliminate all others. Then by adding all the frequencies that were kept the result is a square wave. Since some frequencies have been eliminated the amplitude is lower, so it can be compensated for by increasing the amplitude.

In this example I used ntrpol to crossfade between the original saw wave and the resulting square.

-o dac
; the following line can be used to render output to a file
; -o example.wav
sr = 44100
ksmps = 10
nchnls = 2
0dbfs = 1

giSaw       ftgen 3, 0, 4096, 10, 1, -1/2, 1/3, -1/4, 1/5, -1/6,  1/7,  -1/8, 1/9 
giSquare    ftgen 4, 0, 4096, 10, 1,  0,   1/3,  0,   1/5,  0,    1/7,   0,   1/9

instr 1 
  kfreq = 220
  asaw    oscil, p4, kfreq, p5
  ; subtractive synthesis (filter out unwanted frequencies)
  aflt1 = butbp(asaw, kfreq, 1)
  aflt2 = butbp(asaw, kfreq * 3, 1)
  aflt3 = butbp(asaw, kfreq * 5, 1)
  aflt4 = butbp(asaw, kfreq * 7, 1)
  aflt5 = butbp(asaw, kfreq * 9, 1)
  ; add leftover frequencies & increase amplitude
  ; to compensate for loss
  asqu  = (aflt1 + aflt2 + aflt3 + aflt4 + aflt5) * 1.8
  kfade = linseg(0, p3/3, 0, p3/3, 1, p3/3, 1)
  ; use ntrpol to fade from saw to square
  aout  = ntrpol(asaw, asqu, kfade)
  outs aout, aout

; saw to square
; 4 sec. saw, 4 sec. crossfade, 4 sec. square
i1   0    12    .5   3

I’m not sure how you would make the first minute more interesting, I’ll give it some thought & perhaps others might be able to give you some suggestions.

Hi, I hope all is well with you. I made some changes and would like a little help. in your example (instr 18) I took it and modified it to create the same previous exercise (which is now deactivated in the score) to always create the envelope but modifying the sawtooth into a square. I have to create something like this to make sense of the sound like the previous additive.

  1. I’m wondering why if I disable the score as I did it until instr 7 then it doesn’t play 8? let’s say that the first part of the exercise up to 75 seconds is all ok. now I have to continue and I would like to avoid hearing the whole instrument first, wasting time to understand if it is right. as I did it doesn’t work bypassing sine , saw, Triangle, Square.

  2. As I was saying, example 8 is the first string to play then I would have to copy instr 8 for i9 i10 etc… to have all the freq groups ranging from 100 to 10000. let’s say that I want to do the same thing as the first glissato exercise but adding the filter that you suggested.
    Thank you so much
    Filebin | xzed9ez5qz2rbjrw

In the score, you place several “comment out the following lines” markers to disable them: /*

but you don’t close them: */

To disable multiple score lines place them between /* and */

The second score parameter for i8 is 80 which is the time it should start playing. That means even with instrument i1 thru i7 disabled in the score, it will take 80 seconds before i8 starts playing.

If you want to play i8 immediately, you need to add:


just before i8. This will subtract 80 seconds from the start time of every score event that follows. Then i8 will play right away. So if you change the following by adding those two changes:


; Square da sottrattiva
i8   80     9  .5    3
i9   82.5   9  .5    3
i10  85     9  .5    3
i11  87.5   9  .5    3
i12  90     9  .5    3
i13  92.5   9  .5    3
i14  95     9  .5    3

then it will work.

I would not recommend raising the fundamental frequency (kfreq, kfreqinviluppo) above 4000. When the fundamental reaches 4000, the harmonics are at 8000, 12000, 16000 & 20000.

If you raise it above that, the harmonics go beyond the range of hearing. And when the highest harmonic hits 22,050 it is now above the Nyqist limit (1/2 of sr ; sample rate).

So, for example, when the kfreq reaches 10000, the harmonics are at 20000, 30000, 40000, 50000

Any frequency above .5 * sr (.5 * 44,100 in this case which is 22,050) will causing something referred to as aliasing - frequencies above 22,050 starting wrapping backwards towards lower frequencies, kind of like a freq mirror. Here’s an example of i8 going up to 5000; you can see/hear the aliasing:

This is why when you play i8 you will hear the pitch getting higher & higher then suddenly towards the end you start hearing lower frequencies.

Perhaps try something like this for instr 8:

kfreqinviluppo linseg 100, p3/3, 200, p3/3, 800 , p3/4, 4000

Unless you are deliberately trying to create aliasing (you can Google Nyquist theorem).

Hope that helps.

Hi, thanks for the tip. so aliasing but I hadn’t thought about it initially. so now I should change all the freqs also of instr 1 up to 7 since I use a fundamental with its 10 harmonics which creates a glissade.
This thing has upset me a bit and now I have to try not to exceed 4000 Hz as the highest fundamental freq. With instrur 8 I have to implement the various freq groups by making them play with a sawtooth frame and then changing the reverse with the square wave via subtractive.example 50, 100, 400,1000 (gliss saw )- 1000-400-100-50 (gliss square)

instr 8
kfreqinviluppo linseg 50, p3/3, 100, p3/3, 400 , p3/4, 1000, p3/4, 400, p3/4, 100, p3/3, 50
asega oscil, p4, kfreqinviluppo, 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)
;compenso l’ampiezza tra onda a dente di sega e quadra
aquadra = (aflt1 + aflt2 + aflt3 + aflt4 + aflt5) * 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

I’m working on this now. so I can then see the complete result. the idea is to reach at least 4 minutes of exercises that are not too banal but not even like a masterchef of c sound haha ​​:-)

Hi st. music.
I started from the first instr8 and added the other 3 linseg to be able to perform the same exercise with different freqs without creating other different instruments again (i.e. don’t repeat instr8 for 9 10 11 12) I hope I can make some corrections and it can be implemented the exercise like I did.

In practice I am trying to create that each sound starts from the first freq as I start with 50 to reach 1000 with a saw type wave and return with the freqs. square wave via filter, making the timbre variation audible.
Thanks again I hope you can help me.

uploadnow will not allow me to download the file without creating an account which I’d rather not do.

Perhaps you can post on on the site you use before ( or you can possibly upload here (there is an attach option) or just paste it in.

If you paste in code you can select it and choose “preformatted text” and it appears like this:

aEnv = adsr:a(.004, .1, .6, .2)
aOut = poscil(.8, 220)
out(aOut * aEnv)

hi st. it’s:
Thanks :slight_smile:

Hi, it says file was deleted.

now there is the file I can see it. they don’t understand why you can’t post external files. with the upload offered by the site it won’t let me insert it.

I have the same issue retrieving the file:

Uploading files should work using this button from the menu above:

Instead if you want to directly copy paste code, paste it in the message, select it all, then click this button:

click on Preformatted text:

And you should have your code formatted like this:

instr 1

kamp = .6
kcps = 440
ifn  = p4

asig oscil kamp, kcps, ifn
     outs asig,asig


The forum had flagged @maupetrucci for some reason. Something about new users not being able to upload stuff. Anyway, it should be Ok again now :+1:

I can’t upload them from the sign above as you say: because it gives me an error message saying new users can’t upload the files.

Now I’ll try the second method you described, hoping to do well. here it tells me on the wheel: hide details and that’s what I did now :


I pasted the link here but it gives me an error message saying I can’t post that site!

so at this point I can understand why nothing works to put an external file? what should a user do? Thank you

here I found the button where it says formatted text next to the wheel and now I followed it as per the tutorial. I hope everything is ok now!

That’s not good.
So you don’t see the Preformatted text option?

@rory I guess we need less strict rules with new users