How would I implement play here? Free works!

this.addCommand("startStop", "f", { arg msg;
     if (msg[1] == 0) {
        synth.free;
     } {
        synth.play;
    }
});

If synth is the same Dronecaster you posted earlier, you’d just synth.set(\amp, msg[1]);, same as your amp command you already have

Yes, it is. That was my first approach but it felt… lazy? Just turning the volume down versus actually stopping the synth. Dunno though, is it bad practiced to do something like this and free/play the synth?

it’s much more common to just change the amplitude, especially for a synth as simple as the one in your code so far. if the synth was significantly more complicated (CPU / RAM hungry), then it may make sense, but as-is it’s consuming very little.

to spell out how you would do it if you really wanted:

Here's how you'd free and re-alloc a synth
SynthDef(\mySynth, {
  arg out, hz=220, amp=0.5, amplag=0.02, hzlag=0.01;
  var amp_, hz_;
  amp_ = Lag.ar(K2A.ar(amp), amplag);
  hz_ = Lag.ar(K2A.ar(hz), hzlag);
  Out.ar(out, (SinOsc.ar(hz_) * amp_).dup);
}).add;
context.server.sync;

synth = Synth.new(\mySynth, [\out, context.out_b], context.xg);

this.addCommand("hz", "f", { arg msg;
  synth.set(\hz, msg[1]);
});

this.addCommand("amp", "f", { arg msg;
  synth.set(\amp, msg[1]);
});

this.addCommand("startStop", "f", { arg msg;
  if (msg[1] == 0, {
    synth.free;
  }, {
    if (synth.notNil, {
      synth = Synth.new(\mySynth, [\out, context.out_b], context.xg);
    });
  });
});

basically, .play is a shortcut for defining and allocating a synth in one line. instead, you separate the definition and allocation into their own lines (SynthDef(...) and Synth.new(...)) so you can call Synth.new wherever you’d like

4 Likes

Wonderful. Thank you for the explanation and code. I really appreciate it. :black_heart:

1 Like

Y’all. Supercollider is the Dark Souls of music tech. I’ve got the YOU DIED screen on every save. How did you learn it?

2 Likes

The built-in documentation helps a lot. Once I had this committed to memory, things got a lot easier:

{ SinOsc.ar(55) ! 2 }.play;

Edit: Of course you seem a ways further along than that, so that’s not really helpful. Those “does not understand message” errors can be super frustrating.

Also I got a lot out of pulling apart these tweets, trying to understand them, and mostly failing, but learning a neat trick here and there:

https://mobile.twitter.com/redfrik

1 Like

cries in binary

5 Likes

Ohh yeah that page :joy:

3 Likes

Never felt so attacked via a wiki page in my life. Almost wrote the exact same thing in my SynthDef.

2 Likes

20 characters of \kablooie

2 Likes

SinOsc = object, my only friend here.
.ar = audio rate, a method.
55 = first argument, frequency.
! = same as .dup.
2 = stereo.
.play = play.

3 Likes

20 characters of Nailed it!

1 Like

I’m trying to learn more about Crone. How come SC can’t run the CroneEngine? My thinking was I would make a little “bootstrap” environment in SC so my engines could inherit from this. Obviously, SC is clearly stating there is a syntax error. But this < is just a getter, no?

I humbly thank you for your brain cycles.

it runs just fine (it is developed on desktop,) but it is class code and not interpreter code. put Crone.sc et al in your supercollider extensions folder. (or symlink from there to norns/sc/classes)

3 Likes

Ok, I need to go back to SC 101. :sweat_smile: Thank you.

@license and I are working on a thing. Is this possible? Our understanding is that there is a hardware constraint that couples the stereo outs with the headphones. We’d like to just monitor and record the inputs.

1 Like

Nope. 20 characters of reference

2 Likes

Great. Thank you for confirming.

This look interesting.

I think it would be pretty easy to convert the free version of this SuperCollider 808 emulation into a Norns engine.

Whether it’s ethical to do that is another question, I guess.

4 Likes