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: ~input = Array.newClear(20); //Array to put the UGen values in ( var count; count = 0; //Initialize counter to 0 o = OSCresponder(s.addr, '/tr', { arg t, r, msg; //[count, msg[3]].postln; ~input.put(count, msg[3]); count = (count + 1) % ~input.size; //Increment the counter, but wrap it between 0 and size of your input array minus 1 }).add; //Some SynthDef were you want to poll the values from SynthDef.new("detectPitch", { arg trigID = 1; var input, freq, hasFreq, amp; input = SinOsc.ar(440, 0, 1); //A source amp = Amplitude.kr(input); # freq, hasFreq = Pitch.kr(input, ampThrehold: 0.02. median: 7); freq = freq.cpsmidi.round(1); SendTrig.kr(Impulse.kr(5), trigID, freq); //Increase the rate of Impulse to achieve more precision. Further note that you can send an array like //[freq, amp] but that OSCresponder will 'unpack' the array into 2 separate values so you can't use it //to write 2 values into an array at the same time. }).send(s); ) The solution with a Routine is maybe a little more complicated, but then you can put more than 1 item in a database at the same time. I hope you can do something with this and if you would like to know more about the Routine solution let me know, then I'll post a little example of that one too. gr. Michael Date: Mon, 29 Dec 2008 16:44:02 -0800 From: efsubenovex@xxxxxxxxx To: sc-users@xxxxxxxxxxxxxxxx Subject: Re: [sc-users] Fill array with UGen output Ah! Michael, a code snippet is worth a thousand nodes. Please do, and thanks! Sounds great. On Mon, Dec 29, 2008 at 4:19 AM, Michael Dzjaparidze <m_dzjaparidze@xxxxxxxxxxx> wrote:
-- Schell Scivally efsubenovex@xxxxxxxxx http://blog.efnx.com Win elke dag een HTC Touch Diamond. Beter nog... win er twee! |