Noob: Basic MIDI help needed

Hello, I really am a beginner and have just botched my way through SC for years now. I set up a really basic midi synth and get the following error:
ERROR: Message ‘at’ not understood.
Perhaps you misspelled ‘as’, or meant to call ‘at’ on another receiver?
RECEIVER:
Symbol ‘robBasic’
ARGS:
Symbol ‘freq’
Float 82.406889 791E127C 40549A0A
Symbol ‘amp’
Float 0.163800 FD8ADABA 3FC4F765
KEYWORD ARGUMENTS:
CALL STACK:
DoesNotUnderstandError:reportError
arg this =
Nil:handleError
arg this = nil
arg error =
Thread:handleError
arg this =
arg error =
Object:throw
arg this =
Object:doesNotUnderstand
arg this = ‘robBasic’
arg selector = ‘at’
arg args = [*4]
arg kwargs = [*0]
< FunctionDef in closed FunctionDef >
arg veloc = 52
arg num = 40
arg chan = 0
arg src = -898120851
MIDIMessageDispatcher:value
arg this =
arg src = -898120851
arg chan = 0
arg num = 40
arg val = 52
Meta_MIDIIn:doNoteOnAction
arg this =
arg src = -898120851
arg chan = 0
arg num = 40
arg veloc = 52
^^ ERROR: Message ‘at’ not understood.
Perhaps you misspelled ‘as’, or meant to call ‘at’ on another receiver?
RECEIVER: robBasic

The code I am using is this:
(
var notes, on, off;

MIDIClient.init;
MIDIIn.connectAll;

notes = Array.newClear(128); // array has one slot per possible MIDI note

on = MIDIFunc.noteOn({ |veloc, num, chan, src|
notes[num] = Synth(\robBasic [\freq, num.midicps,
\amp, veloc * 0.00315]);
});

off = MIDIFunc.noteOff({ |veloc, num, chan, src|
notes[num].release;
});

q = { on.free; off.free; };
)

(
SynthDef(\robBasic,{|out= 0 freq = 440 amp = 0.1 gate=1 lforate = 4.85 lfowidth= 0.5 cutoff= 2000 rq=0.5 pan = 0.0|

var pulse, filter, env;

pulse = SinOsc.ar(freq)+ LFTri.ar(freq,0.5,0.5,0.05);
pulse = pulse*(Dust.ar(100,1,0.5)*LFPar.ar(freq,0,0.5));

env = EnvGen.ar(Env.adsr(0.9,1.0,0.8,3.0),gate,doneAction:2);

//keyboard tracking filter cutoff
filter = BLowPass4.ar(pulse,(cutoff*(env.squared))+200+freq,rq);

Out.ar(out,Pan2.ar(Mix(filter)*env*amp,pan));

}).add;
)

Can anyone explain what the error means, and what the solution is; I just cannot work it out.

First, I’ll link a good document for understanding errors Understanding errors | SuperCollider 3.14.1 Help

So, looking at your error, you’ll see

ERROR: Message ‘at’ not understood.
Perhaps you misspelled ‘as’, or meant to call ‘at’ on another receiver?
RECEIVER:
Symbol ‘robBasic’
ARGS:
Symbol ‘freq’

So, at some point you seem to call at on robBasic - but since robBasic is a Symbol, which does not respond to at, you’ll trigger this error message.

So, this gives us the clue to look at the regions where robBasic is used - so e.g.

notes[num] = Synth(\robBasic [\freq, num.midicps,
\amp, veloc * 0.00315]);
});

brackets [ and ] are syntactic sugar for at, so we seem to have something here which matches the error: Calling at on the symbol robBasic with arguments, freq - if you look closer, you see that you are missing a , here, so the code should be Synth(\robBasic, [\freq, num.midicps,.

I haven’t checked your code beyond that, but it could be this simple.

1 Like

It would appear it was that simple. Thank you so much for the explanation, and solution.

Btw, you can get code to look like code (monospaced font, no curly quotes) by putting three backticks before and three after:

```
code here
```

code here

If you don’t do this, then sometimes other readers would have to take time to correct some characters, such as:

“if you try to run this, it’s a syntax error”.postln;

vs

"if you try to run this, it's fine".postln;

(Because, if you don’t format your code as code, the forum software will format your quote marks as typographic quotes, instead of typewriter-style straight quotes. SC doesn’t understand the former but it does understand the latter.)

hjh

1 Like