[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] changing the frequency of an oscillator at the zero crossing



Till, that doesn't work. The k that you assign is different from the k
you use as the latch (because the latch happens before the
assignment).

I'm not 100% sure that it's possible, not straightforwardly anyway.
The reason I'm thinking this way is that it's essentially a feedback
loop:

  oscillator -> zerocrossing check -> frequency latch -> oscillator

These kind of things can be done in SC using things like LocalOut and
LocalIn to make the feedback loop, but there's an inherent delay (by
default this is 64 samples, it can be changed). The delay means that
sample-accurate changes like the one you have in mind (Peter) are not
possible.

Changing the delay is achieved by changing the server's "control
block" size (see the ServerOptions helpfile). You can ram it all the
way down to 1 for sample-accurate but this is undesirable because it
means all the control-rate processes start to run at audio-rate and it
becomes inefficient. Maybe you're OK with an up-to-64-sample lag (==
about 1.5 milliseconds)? If so, here's a way to do it:

Sever.default = s = Server.internal;
s.boot;
s.scope;


(
x = {
	var freq, latchedFreq, son;
	
	freq = WhiteNoise.ar.exprange(10, 20); // Low freqs, watchable on scope
	
	latchedFreq = LocalIn.ar(1).max(10); // max prevents locking at 0 Hz
	
	son = SinOsc.ar(latchedFreq, 0, 0.1);
	
	LocalOut.ar(Latch.ar(freq, son));
	
	son.dup;
	
}.play;
)


Dan


2007/10/31, Till Bovermann <tboverma@xxxxxxxxxxxxxxxxxxxxxxxx>:
>
> On 31.10.2007, at 01:10, <yx6@xxxxx> <yx6@xxxxx> wrote:
>
> > hi ,im trying to change the frequency of an oscillator only when
> > its output value crosses 0 ,
> > something like this :
> >
> > k = { SinOsc.ar(Latch.ar(WhiteNoise.ar(1400), k.value), 0, 1) };
> >
>
> l = {
>         k = SinOsc.ar(
>                 Latch.ar(WhiteNoise.ar(1400), k),
>                 0,
>                 1
>         )
> };
>
> l.play
>
> perhaps this way?
>
> regards
> Till
>
>
> >
> > ,any tips?
> >
> > -peter
> > (yx6@xxxxx)
> >
> > _______________________________________________
> > sc-users mailing list
> > sc-users@xxxxxxxxxxxxxxx
> > http://www.create.ucsb.edu/mailman/listinfo/sc-users
>
> _______________________________________________
> sc-users mailing list
> sc-users@xxxxxxxxxxxxxxx
> http://www.create.ucsb.edu/mailman/listinfo/sc-users
>


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