how to create correct synthdefs

73 views
Skip to first unread message

maxprofitisback

unread,
Feb 22, 2012, 8:00:45 AM2/22/12
to supercollider-android-developers
Hi,

I've tried PinkNoise synthdef on a custom project based on
supercollider-android and it sounds well on my device.
(
SynthDef(\pinknoise, { |amp=0.1|
Out.ar(0, PinkNoise.ar(amp))
}).add
)

When I try the following synthdefs the sound is horrible on my device,
but correct on desktop with a normal supercollider.
(
SynthDef(\oscsin, { |amp= 0.2, freq=220|
var sin = SinOsc.ar(freq, 0, amp, 0);
Out.ar(0, sin)
}).add
)

(
SynthDef(\cymbal, { |amp = 0.2|
var lodriver, locutoffenv, hidriver, hicutoffenv, freqs, res,
thwack;
locutoffenv = EnvGen.ar(Env.perc(0.5, 5)) * 20000 + 10;
lodriver = LPF.ar(WhiteNoise.ar(0.1), locutoffenv);
hicutoffenv = 10001 - (EnvGen.ar(Env.perc(1, 3)) * 10000);
hidriver = HPF.ar(WhiteNoise.ar(0.1), hicutoffenv);
hidriver = hidriver * EnvGen.ar(Env.perc(1, 2, 0.25));
thwack = EnvGen.ar(Env.perc(0.001,0.001,1));
freqs = {exprand(300, 20000)}.dup(100);
res = Ringz.ar(lodriver + hidriver + thwack, freqs).mean;
Out.ar(0, ((res * 1) + (lodriver * 2) + thwack).dup * amp)
}).add
)

I just don't get why PinkNoise works and not the other synthdefs. The
sound look like saturated/compressed, sorry I can't describe what I'm
hearing :-)

Thanks

Dan Stowell

unread,
Feb 23, 2012, 10:20:41 AM2/23/12
to supercollider-an...@googlegroups.com
Hi -

I'm not sure what's happening for you. It could be that everything is
amplified, or maybe the bits/bytes are in the wrong order (things that
could happen if the float-to-int conversion that's needed before
sending the audio to android's java layer is buggy or is compiling
wrong on your machine). If you turn the "amp" values down really low
(e.g. 0.0002) and gradually increase them, what happens? Do you always
get distortion, or does it fade in and then distort beyond a
particular level?

Dan


2012/2/22 maxprofitisback <maxprof...@gmail.com>:

--
http://www.mcld.co.uk

maxprofitisback

unread,
Feb 28, 2012, 4:02:47 AM2/28/12
to supercollider-android-developers
Yes, thanks, the issue was about mixing byte and short sizes data in
my code.
I am not working on Android platform, I am trying to port
SuperCollider on MeeGo N9 based on what you did on Android.
I've pushed the code here: https://gitorious.org/supergollider

I still have issue with the cymbal synthdef described on your
tutorial: http://www.mcld.co.uk/cymbalsynthesis/
Only this synthdef is working
(
SynthDef(\cymbal, { |amp = 0.2|
Out.ar(0, Ringz.ar(PinkNoise.ar(amp), {exprand(300,
20000)}.dup(100)).mean);
}).play
)

When I try this one, the sound is horrible. I will try to use very low
amp values
(
x = {
var driver, cutoffenv, freqs, res;
cutoffenv = EnvGen.ar(Env.perc(0, 5)) * 20000 + 10;
driver = LPF.ar(WhiteNoise.ar(0.1), cutoffenv);
freqs = {exprand(300, 20000)}.dup(100);
res = Ringz.ar(driver, freqs).mean
}.play;
)

On Feb 23, 5:20 pm, Dan Stowell <danstow...@gmail.com> wrote:
> Hi -
>
> I'm not sure what's happening for you. It could be that everything is
> amplified, or maybe the bits/bytes are in the wrong order (things that
> could happen if the float-to-int conversion that's needed before
> sending the audio to android's java layer is buggy or is compiling
> wrong on your machine). If you turn the "amp" values down really low
> (e.g. 0.0002) and gradually increase them, what happens? Do you always
> get distortion, or does it fade in and then distort beyond a
> particular level?
>
> Dan
>
> 2012/2/22 maxprofitisback <maxprofitisb...@gmail.com>:

Dan Stowell

unread,
Feb 28, 2012, 4:31:36 AM2/28/12
to supercollider-an...@googlegroups.com
Aha, I see! Nice project name.

I'd suggest that you'll find it easier to use a sine-wave to test if
the signal is being output correctly. Just use a full-amplitude (i.e.
amplitude=1) SinOsc. If it doesn't sound pure and lovely then you know
you've got a problem. Pink noise, you might not tell the difference.
So if the SinOsc isn't outputting correctly, then you can try swapping
the bytes around or whatever your hardware/OS needs.

Dan


2012/2/28 maxprofitisback <maxprof...@gmail.com>:

--
http://www.mcld.co.uk

maxprofitisback

unread,
Mar 7, 2012, 10:08:48 AM3/7/12
to supercollider-android-developers
SinOsc sounds well with an amplitude at 1.0

But when I try this other SynthDef:
(
SynthDef(\cymbal1, { |amp = 0.2|
var driver, cutoffenv, freqs, res;
cutoffenv = EnvGen.ar(Env.perc(0, 5)) * 20000 + 10;
driver = LPF.ar(WhiteNoise.ar(0.0002), cutoffenv);
Out.ar(0, driver);
}).store
)
x = Synth(\cymbal1);
x.free;

Whatever the amplitude is at 0.00001 or 1.0, I still get horrible
squeezed noises. The sound I hear has 2 parts with a squeezed noise
and at remaining parts I hear the sound well.

BTW I've pushed the code the application here: https://gitorious.org/supergollider
"SuperGollider" can be also installed from OVI Store (equivalent to
Android Market) on your N9 if you have such device.

On Feb 28, 11:31 am, Dan Stowell <danstow...@gmail.com> wrote:
> Aha, I see! Nice project name.
>
> I'd suggest that you'll find it easier to use a sine-wave to test if
> the signal is being output correctly. Just use a full-amplitude (i.e.
> amplitude=1) SinOsc. If it doesn't sound pure and lovely then you know
> you've got a problem. Pink noise, you might not tell the difference.
> So if the SinOsc isn't outputting correctly, then you can try swapping
> the bytes around or whatever your hardware/OS needs.
>
> Dan
>
> 2012/2/28 maxprofitisback <maxprofitisb...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages