Cabbage Logo
Back to Cabbage Site

Lowpass 2 help

Hi everyone!

I am very new to csound and for a course I am taking at university we need to design an instrument in csound. The instrument should be a buzz instruments that goes into a lowpass 2 filter. The buzz instrument gave me no trouble but I can’t quite figure out how to make the signal from the buzz run through the lowpass filter. If anyone can help it would be greatly appreciated. Attached is a screenshot of my work so far! csoundlp|690x431

Hi @strri, welcome to the forum. I’ll ignore the fact that you’re using CsoundQT :laughing:

I can’t see much wrong with this. You seem to be passing your buzz output to the lowpass2 filter as I would expect. Are you not hearing any filtered sound in the output? Can you post the actual code?

Of course, here it is

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

instr 1


k1 linen p4, p6, p3, p7
a1 buzz k1, p5, p8, 1
   outs    a1, a1




endin

instr 2

idur = p3
ifreq = p4
iamp = p5 * .5
iharms = (sr*.4) / ifreq

asig gbuzz 1, ifreq, iharms, 1, .9, 1

kfreq linseg 1, idur * 0.5, 5000, idur * 0.5, 1

afilt lowpass2 asig,kfreq, 30

kenv linseg 0, .1, iamp, idur -.2, iamp, .1, 0
     out afilt * kenv
     
     endin


</CsInstruments>
<CsScore>
; a cosine wave


f1 0 8192 10 1
;p1     p2    p3   p4    p5   p6   p7    p8
;instr  start dur  ampl  freq rise decay partials
i1      0     1    50   40   .1   .1    1  
i1      1     1    50   60   .1   .1    3
i1      2     1    50   50   .1   .1    6
i1      3     1    50   70   .1   .1    9
i1      4     1    50   60   .1   .1    12
i1      5     1    50   50   .1   .1    15
i1      6     1    50   55   .1   .1    18
i1      7     1    50   60   .1   .1    21
i1      8     1    50   65   .1   .1    24
i1      9     1    50   55   .1   .1    27
i1      10    1    50   60   .1   .1    30
i1      11    2    50   50   .1   .1    30
i1      13    2    50   60   .1   .1    30
i1      15    2    50   75   .1   .1    30
i1      17    3    50   80   .1   .1    30



f2 0 8192 9 1 1 .25

i2 0 10 100 10000
i2 10 5 200 <
i2 15 5 100 100

e



</CsScore>
</CsoundSynthesizer>

I do hear the filtered sound on one channel. But what I was expecting to happen was that the buzz would be sent through the filter and so it would then combine into one signal, so a buzz with a lowpass but instead I get two. Maybe that is how it’s supposed to be but I am not sure

Another thing is that the code for the lpf I’m copying uses gbuzz so in my code it says gbuzz even though I am using buzz. And I don’t seem to be able to change it from gbuzz to buzz

I think the problem here is that you have an amplitude of 10000 when 0dbfs is set to 1. Even though you multiple p5 by .5, it’s still way too loud. Set your p5 to 1 and you should hear better results.

These two opcodes use different arguments, so you can’t simple rename gbuzz to buzz. You also need to update the rest of the arguments.

p.s. I edited your post to show the code properly. When posting code, you can format it by selecting all code and hitting the </> button in the editor. :+1: Btw, what university are you studying in?

I am studying New Media Composition and the Icelandic University of Arts. So I changed the amplitude to the new level and it’s sounding clearer, thanks. Do you know what arguments would need to be there instead of the gbuzz ones?

Cool. I’ve always wanted to go visit Iceland! It’s not really that far from Ireland I guess.

Check out the manual page for both and have a look at the code there:

https://csound.com/docs/manual/gbuzz.html
https://csound.com/docs/manual/buzz.html

Buzz is much simple, it only take an amplitude value, a frequency, the number of harmonics and a function table number.

so should the line for the lpf read:
asig buzz 1, kcps, knh, ifn

Or should it be something else?

Looks good to me.

Ok so after changing gbuzz to buzz and changing the arguments to kcps and so on as mentioned above, I still get errors as if buzz hasn’t been properly defined. The weird thing is though that when it’s set to gbuzz it works, even though I am using buzz and not gbuzz.

It’s hard for me to see your code from here…and unless I can see what you’re doing, I can’t really offer any help…

Oh sorry, here is my code:

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

instr 1


k1 linen p4, p6, p3, p7
a1 buzz 1, p5, p8, 1
   outs    a1, a1




endin

instr 2

idur = p3
ifreq = p4
iamp = 1 * .5
iharms = (sr*.4) / ifreq

asig gbuzz 1, ifreq, iharms, 1, .9, 1

kfreq linseg 1, idur * 0.5, 5000, idur * 0.5, 1

afilt lowpass2 asig,kfreq, 30

kenv linseg 0, .1, iamp, idur -.2, iamp, .1, 0
     out afilt * kenv
     
     endin


</CsInstruments>
<CsScore>
; a cosine wave


f1 0 8192 10 1
;p1     p2    p3   p4    p5   p6   p7    p8
;instr  start dur  ampl  freq rise decay partials
i1      0     1    50   40   .1   .1    1  
i1      1     1    50   60   .1   .1    3
i1      2     1    50   50   .1   .1    6
i1      3     1    50   70   .1   .1    9
i1      4     1    50   60   .1   .1    12
i1      5     1    50   50   .1   .1    15
i1      6     1    50   55   .1   .1    18
i1      7     1    50   60   .1   .1    21
i1      8     1    50   65   .1   .1    24
i1      9     1    50   55   .1   .1    27
i1      10    1    50   60   .1   .1    30
i1      11    2    50   50   .1   .1    30
i1      13    2    50   60   .1   .1    30
i1      15    2    50   75   .1   .1    30
i1      17    3    50   80   .1   .1    30



f2 0 8192 9 1 1 .25

i2 0 10 100 10000
i2 10 10 200 <
i2 .  .  .  100


e

</CsScore>
</CsoundSynthesizer>

No, if you have written buzz, you’re using buzz. If you have written gbuzz, you’re using gbuzz. The code you posted uses gbuzz, with what looks like the correct arguments. Can you post the code that isn’t working for you?

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

instr 1


k1 linen p4, p6, p3, p7
a1 buzz 1, p5, p8, 1
   outs    a1, a1




endin

instr 2

idur = p3
ifreq = p4
iamp = 1 * .5
iharms = (sr*.4) / ifreq

asig buzz 1, kcps, knh, ifn

kfreq linseg 1, idur * 0.5, 5000, idur * 0.5, 1

afilt lowpass2 asig,kfreq, 30

kenv linseg 0, .1, iamp, idur -.2, iamp, .1, 0
     out afilt * kenv
     
     endin


</CsInstruments>
<CsScore>
; a cosine wave


f1 0 8192 10 1
;p1     p2    p3   p4    p5   p6   p7    p8
;instr  start dur  ampl  freq rise decay partials
i1      0     1    50   40   .1   .1    1  
i1      1     1    50   60   .1   .1    3
i1      2     1    50   50   .1   .1    6
i1      3     1    50   70   .1   .1    9
i1      4     1    50   60   .1   .1    12
i1      5     1    50   50   .1   .1    15
i1      6     1    50   55   .1   .1    18
i1      7     1    50   60   .1   .1    21
i1      8     1    50   65   .1   .1    24
i1      9     1    50   55   .1   .1    27
i1      10    1    50   60   .1   .1    30
i1      11    2    50   50   .1   .1    30
i1      13    2    50   60   .1   .1    30
i1      15    2    50   75   .1   .1    30
i1      17    3    50   80   .1   .1    30



f2 0 8192 9 1 1 .25

i2 0 10 100 10000
i2 10 10 200 <
i2 .  .  .  100


e

</CsScore>
</CsoundSynthesizer>

You haven’t defined kcps, knh or ifn. In fact, when you run this, Csound tells you exactly what the problem is by way of an error message - error: Variable 'kcps' used before defined

Define these variables before you try to use them. No programming language in the world can use a variable that hasn’t been defined.

Yeah I thought that might be the problem. I had tried defining them earlier with no luck, just errors, but I’ll make a second attempt

Right that seemed to work! I’m still hearing what seems to be two separate signals, one from buzz and one from lp. Shouldn’t they be combined into one?

You’re definitely only hearing the output of the filter, as you are not passing the output of buzz to the outputs. I don’t have much experience in using lowpass2, but changing the Q factor might help shape the sound a little better.

you are hearing 2 instruments because you are starting 2 instruments, i1 starts instrument 1, i2 starts instrument 2 :wink:
try commenting ( ;this is a commented line ) those lines:

;i2 0 10 100 10000
;i2 10 10 200 <
;i2 .  .  .  100