Hi,

I'm a SuperCollider user getting started with Bela, I want to run interactive patches for saxophone on it.

Last night I tried connecting a dynamic mic and wrote a quick test SynthDef to check that some of the things I usually use (and need) were working, along these lines:
SynthDef(\test, {
var in = Soundin.ar(0);
var amp = Amplitude.kr(in);
var freq = Pitch.kr(in);
sig = SinOsc.ar(freq: freq, mul:amp);
Out.ar(0, sig);
}).send(s);

so just controlling a SinOsc with pitch and amplitude information from the mic input.

All of the other code for booting the server, setting up the channels and calling the synth was included above and below the SynthDef. When the code is executed and I sing or play into the mic all I get is very high pitched tones, which respond slightly to mic inputs but not in the way intended.

I tried replacing SoundIn.ar with AnalogIn.ar - I'm wondering if the necessary plugins for the above to run are included in the Bela version of SC, or if AnalogIn behaves differently to SoundIn, or if I have a faulty in connector?

Thanks,

Mark

Hi @markh,
you haven't pasted much code there. (PS: to make sure it is formatted appropriately, please enclose it in triple backticks:

```
your.code
```
)

Full code was:


s = Server.default;

s.options.numAnalogInChannels = 2;
s.options.numAnalogOutChannels = 2;
s.options.numDigitalChannels = 16;

s.options.blockSize = 16;
s.options.numInputBusChannels = 2;
s.options.numOutputBusChannels = 2;

s.options.postln;

s.waitForBoot({

SynthDef("amppitchsin", {
	var in = SoundIn.ar(0); // also tried AnalogIn.ar 
	var pitch = Tartini.kr(in)[0]; // also tried Pitch.kr 
	var amp = Amplitude.kr(in);
	var output = SinOsc.ar(freq:pitch, mul:amp);
	Out.ar(0, output);
    }).send(s);
  s.sync;
  Synth.new("amppitchsin", target: s);
});

uops, it seems you used three commas ,,, instead of three backticks ```. I fixed it for you.

The issue is that you are running this code at 16 samples per block, but probably your pitch analysis ugens are doing infrequent, expensive block-based computation (e.g.: FFT), leading to underruns. Ideally, you'd figure out what the analysis step is (e.g.: every how many samples the FFT is performed), and use that as the blocksize in s.options.blockSize. I blindly tried the code with

s.options.blockSize = 256;

and it seems to work fine, as far as I can tell.

I think we fixed the commas thing simultaneously! I realised at the time.

Thanks for the help, that makes sense - I tried running it as you suggested with s.options.blockSize = 256;
and now I'm getting the following error:
scsynth: symbol lookup error: /root/Bela/lib/libbela.so: undefined symbol: _ZN19BelaContextSplitter5setupEjjPK11BelaContext

Oh ok, you then need to update your Bela core code to fix that. See instructions here.

All working now!
It turns out the effect of passing Amplitude.kr to mul of SinOsc was horrible, but it all works as it should now. Thanks! 🙂