[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [sc-users] Fill array with UGen output
On Tue, Dec 30, 2008 at 4:42 AM, Michael Dzjaparidze
<m_dzjaparidze@xxxxxxxxxxx> wrote:
> Alright. The OSCresponder and SendTrig combination is probably the most
> simple. The only disadvantage is that you can only receive one value at a
> time (I think...). For me this was a problem because I did pitch analysis
> and had to put the pitch and the amplitude of a note in a database at the
> same time, but if the only thing you want to do is to put some single values
> in an array it works great. So a little code example might look like this:
You can do multiple values, with some extra care. Use SendTrig's id
argument to distinguish the values.
This assumes that a pair of /tr messages will be received in rapid
succession. If the Impulse is too fast, messages might be received out
of order and then this code would break. More could be done to protect
against that but it's probably not necessary for a reasonable rate of
data collection.
SynthDef(\pump2, {
var sig = [SinOsc.kr(0.5), LFSaw.kr(0.6)];
// this expands to:
// [SendTrig.kr(Impulse.kr(8), 0, SinOsc...),
// SendTrig.kr(Impulse.kr(8), 1, LFSaw...)]
SendTrig.kr(Impulse.kr(8), (0..1), sig);
}).send(s);
x = List.with(nil ! 2);
o = OSCresponderNode(s.addr, '/tr', { |t, r, m|
var index, value, last;
#index, value = m[2..];
if(x.last[index].notNil) {
x.add(nil ! 2);
};
x.last[index] = value;
}).add;
a = Synth(\pump2);
a.free;
x
--> List[ [ 0.0045592091046274, 0.0017414966132492 ], [
0.39053419232368, 0.15325170755386 ], [ 0.71267569065094,
0.30302041769028 ], ... etc. ]
hjh
--
James Harkins /// dewdrop world
jamshark70@xxxxxxxxxxxxxxxxx
http://www.dewdrop-world.net
"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal." -- Whitman
_______________________________________________
sc-users mailing list
info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/