External synth has distorted lissajous art rendering

Hello everybody.
In order to try producing some oscilloscope music using sonic-pi I created a new Ugen in Supercollider as a plugin and wrapped it with a synthdef.
When creating a synth from that synthdef with the Supercollider-IDE there are no problems and everything works fine.
However, when I try to play that synth from sonic-pi and display the result in the scope in Lissajous mode or on a real oscilloscope attached to my soundcard,
the pattern is disturbed and somehow rotated.
Therefore I think this might be a sonic-pi problem.
Can anyone please try to reproduce this or suggest a fix?
You can find the needed files on github: https://github.com/gedobbles/oszi-music.
Thank you for your help.

Copy files to:
MyOsc.sc -> to Supercollider plugins dir
build/MyOsc.so -> to Supercollider plugins dir

if that doesnt work, try to execute build/make_commands to rebuild the plugin

In SupercolliderIDE:

var syn = SynthDef("tbaum",{arg out_bus=0, amp=1, note=60, sustain = 1;
	var freq = note.midicps;
	o = Out.ar(out_bus, MyOsc.ar([freq,freq],0,[0,1]) * Line.kr(amp,amp,sustain,doneAction: 2), 0.0);

In sonic-pi:

load_synth_defs "/whatever/dir/"
use_synth :tbaum
play 52

I found a kind of workaround, however i still want to know, why SonicPi distorts my synth.
Something like this works:

In SupercolliderIDE

var syn = SynthDef("tbaum",{arg out_bus=0, amp=1, note=60, sustain = 1;
	var freq = note.midicps;
	o = Out.ar(out_bus, MyOsc.ar([freq,freq],0,[0,1]) * Line.kr(amp,amp,sustain,doneAction: 2), 0.0);

o = OSCFunc.newMatching({|msg, time, addr, recvPort| Synth(\tbaum)}, '/play', n);

In SonicPi:

use_osc "localhost", 57120
osc "/play", "Hello"

Hi, when you say “distorted” does your synth sound like it is being passed through a distortion effect? Or are you just saying that the wave form looks slightly different? Can you hear any difference between your synth played with standard supercollider and with Sonic Pi?

Sonic Pi has a master mixer synth which all sound is passed through which has a compressor and a number of other ugens which act as a safety system. This will definitely be affecting your sound - although it shouldn’t be audibly different.

Thanks a lot for your fast reply.
If you plot the outcome on the sillajous view, a tree should be visible.
However the problem is, that the edges are not too sharp and the whole graphic is sheared to the right quite a bit, that means that probably one audio channel has a higher latency than the other I guess.
So to fully answer your question, I at least can not hear a difference.

Ah, so you’re not talking about a distorted sound, but a distorted lissajous visualisation.

Try bypassing the global mixer and see if that helps:

set_mixer_control! hpf_bypass: 1, lpf_bypass: 1, limiter_bypass: 1, lead_dc_bypass: 1

I just tried it out, you had a little tipoe at lpf:_bypass (there was a : too much),
however the same issue still occurs. Have a look:
When i run it it Supercollider directly it is perfect and straight.

OK, something odd is going on here then.

There’s either something happening in the signal chain to modify the sound before it gets to the visualiser, or the visualiser isn’t rendering it correctly.

I’ll take a closer look, although it might not be easy to resolve before the next release depending on how long it takes…

In my opinion you don’t have to concentrate on the visualizer rendering, because on a real oscilloscope attached to my soundcard, the graphings just look the same.

1 Like

Unfortunately, you’re using your own ugen here, so it’s not trivial for me to try it out without building it locally. Also, we have a new lissojous renderer in the upcoming release, so there may also be some new problems with that - so it will be useful to test it out there.

Yes of course it is not trivial. I have a prebuilt version on github as I mentioned in my first post.
Thank you very much for your great effort.

Is it prebuilt for either macOS or Windows?

No, it is build for
Linux 4.15.0-76-generic #86-Ubuntu SMP Fri Jan 17 17:24:28 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Also, one more thing to try if you have a sound card with more than 2 outputs is to use the sound_out_stereo FX to output to channels 3 and 4 as that currently doesn’t have a global mixer in its signal chain:

with_fx :sound_out_stereo, output: 3 do
  # play sound here

Ah ok, I currently don’t have a linux machine set up as I don’t currently have the resources to support linux at this stage. Sorry.

I’m sorry, I am working on my laptop here which has only got 2 channel audio, my Clavinova too.
I could route the audio from SonicPi outputs 3 and 4 to my main out with jack audio but then I guess I could not use the lissajous view in SP any more.
I just attach my oscilloscope for you and check whats going on on audio 3 and 4.
The problem may also not be a linux specific problem but please try on Windows or MacOS even if it’s a little bit harder to build.

I just tried it out:
On Audio 3/4 a little bit better (at least there’s hope :smile:)

But directly from Supercollider it looks like this:

1 Like

OK, that suggests the global mixer is having an effect on the output - even with the bypassing options set. I suspect there’s more work I can do to bypass it.

However, it’s odd that using the :sound_out_stereo FX still produces quirks as it should be piping your synth straight to the sound card’s output.

Here’s the design for that FX and you can see it just routes the audio with no modifications at all:

I just remembered, that I had forgotten to disconnect audio channels 1 and 2 from my stereo output, when trying to use the :sound_out_stereo fx. Therefore, the output from the fx still being passed through to the main context (, because I did not set mix: 0 on the fx,) may have influenced the waveform on my oscilloscope.
I will do some further testing having channels 1 and 2 completely disconnected from any output as soon as I passed my university exam today :wink: .

1 Like

Good luck with your exam!!! :slight_smile:

Sorry for my late response, I had a couple of things to do these weeks.
I just tried with the :sound_out_stereo on channels 3, 4 which worked perfectly when having SonicPi outputs 1 and 2 disconnected from my sound card or with

with_fx :sound_out_stereo, output: 3, amp: 0 do
  play 40

I suggest the problem is the main mixer, as I described in my last post.
By the way, do you think there might be problems building the latest SonicPi on Linux?
And did you already think about some changes concerning the global mixer bypass opts?
Another question: Is it possible to select channels 3 and 4 (or any other) to be rendered in the lissajous art view?