Error in my code (Beginner)

Hi there,
In order to learn/get better at coding, I have been experimenting with and going over code from tutorials and forums. I found a piece of code that was one line long and decided to attempt to transcribe it into a form I’m more familiar with and then edit and work with it. I’ve tried a few different things but I keep ending up with an error that either “sig” isn’t defined or “def not understood”.
Thanks and apologies if this is a bit of a stupid question!

Here’s the original code:
play{b=SinOsc;c=LFNoise0;d=AllpassC;e=0.2;d.ar(d.ar( b.ar(c.kr(2).range(220,440) ,c.kr,e),e10,b.kr(e).range(e,e9),10))}!3;
// #supercollider

Here’s mine:

(
SynthDef.new(\SDMOTM, { |out, freq = 440, sustain = 1, amp = 0.5|
var sig;
sig = SinOsc.ar(freq, 0, amp);
LFNoise0;
AllpassC;
e=0.2;
AllpassC.ar(SinOsc(LFNoise0.kr(2).range(220,440), LFNoise0.kr,e),e10, SinOsc.kr(e).range(e,e9),10)}!3;
Out.ar(0, 2)
)

I don’t know where the original code comes from (not that it’s that important), but when I tried it it threw an error (e9 not defined). In your code, ‘e9’ reappears, so again I’m not sure what should be there.

However, if you look at your version you should notice that much of your synthdef isn’t defined, either as variables (with or without arguments) - this depends on what you wish to try, and where you wish to use them later.
You’ve defined SinOsc (line 3) as a variable, which if you notice, in your version LFNoise and Allpass (lines 4 and 5) might need to be variables too? Line 7, you repeat AllpassC.ar, but it hasn’t been defined (as I just said) as a variable … etc.

I don’t know you’re level, but I’d suggest you look at some more simple examples and maybe watch Eli Fieldsteels beginners tutorials:

Sorry if I don’t answer your question in full, but if I re-did your code and explained it, it would become a mini tutorial, hence the suggestion to watch a tutorial.

Hope that helps (a little).

hmmm… I’m also getting the same errors as joesh.
Just out of curiosity is the original code from one of the SCtweet stuff??

Also I find this tutorial series very useful since it provides actual sc files that contain explanations and also you can learn by modifying code.

http://www.ixi-audio.net/content/backyard.html

1 Like

Original code was actually posted in Github, sweet I’ll check out that tutorial! Thanks:)

Hey there,

Its meant to be e*9, seems to have deleted it when I copied it across which definitely doesn’t help haha.
Ah, I think my understanding of defining the variables might be a bit off then, I thought I’d only need to define the likes of freq, amp etc but not the LFNoise0 in this case.
It’s basically experimentation since I can build synthDef’s but they look similar to the ones I’ve seen in tutorials whereas this single line of code threw me off.

I’ll try again with your recommended changes and also look at that tutorial, thanks!

Ah… small forum gotcha: stars are interpreted as markup symbols if you don’t include the code in a code block (a code block is started and stopped by three backticks ` )

See the difference in rendering between:

example

vs

``````*example*
``````

(I twice typed `*example*`)

2 Likes