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

Re: [sc-users] Fill array with UGen output



> Function source and its superclass does not expose a .plot method

Yes it does actually - not in the main "Function" class file but in a
separate file named SignalPlusGUI.sc

The method you are looking for is Function:loadToFloatArray

HTH
Dan


2008/12/30 Batuhan Bozkurt <batuhan@xxxxxxxxxxxxxxxxxx>:
> Something keeps me thinking about this:
>
> .plot is a lang side method which Function also utilizes. And something like
> this works:
>
> { SinOsc.ar(1) }.plot(1)
>
> So I'm assuming that this kind of communication between server and lang is
> already present. If we can buffer and plot the data coming from an UGen with
> a simple method, then it should be easy to implement similar functionality
> for Arrays (i.e. that gives the values instead of creating a window and
> plotting them). I really don't know where to look for adding this though,
> Function source and its superclass does not expose a .plot method so I think
> its built into the lang at source level (clueless here, maybe its somewhere
> else).
>
> BB.
>
> Michael Dzjaparidze 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:
>>  ~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 <mailto:m_dzjaparidze@xxxxxxxxxxx>> wrote:
>>
>>    I have been working on the same thing bassically. I came up with 2
>>    solutions. 1 indeed by using OSCresponder and SendTrig, but
>>    actually the one I ended up using was to just use a control rate
>>    bus to send my Ugen data to and then I build a loop with a
>>    Routine that accesses the bus with the .getn message and stores
>>    the data in an Array with a counter that gets incremented each
>>    time through the loop.
>>        If you need more specific code, I can put up a short example.
>>        Good luck,
>>        gr.
>>        Michael
>>
>>
>>
>>  ------------------------------------------------------------------------
>>
>>    From: josh@xxxxxxxxxxxxxxxxx <mailto:josh@xxxxxxxxxxxxxxxxx>
>>    To: sc-users@xxxxxxxxxxxxxxxx <mailto:sc-users@xxxxxxxxxxxxxxxx>
>>    Subject: Re: [sc-users] Fill array with UGen output
>>    Date: Sun, 28 Dec 2008 20:38:24 -0800
>>
>>
>>    Take a look at OSCresponderNode and SendTrig. This would probably
>>    be the easiest way to do it (and access the values in the lang).
>>
>>    Best,
>>
>>    josh
>>
>>    On Dec 28, 2008, at 5:49 PM, Schell wrote:
>>
>>        Hi, I am wondering how to fill an array with the output of a
>>        control rate from a unit generator, possibly at pre-determined
>>        intervals [every 2nd, 3rd or 4th value]. Possibly a function
>>        that uses a ugen to return an array? I can't seem to achieve
>>        this on my own...
>>
>>        --        Schell Scivally
>>        efsubenovex@xxxxxxxxx <mailto:efsubenovex@xxxxxxxxx>
>>        http://blog.efnx.com <http://blog.efnx.com/>
>>
>>
>>    ******************************************
>>    /* Joshua D. Parmenter
>>    http://www.realizedsound.net/josh/
>>
>>
>>    "Every composer – at all times and in all cases – gives his own
>>    interpretation of how modern society is structured: whether
>>    actively or passively, consciously or unconsciously, he makes
>>    choices in this regard. He may be conservative or he may subject
>>    himself to continual renewal; or he may strive for a
>>    revolutionary, historical or social palingenesis." - Luigi Nono
>>    */
>>
>>
>>
>>  ------------------------------------------------------------------------
>>    Chat met al je vrienden. Nodig ze nu uit voor Messenger!
>>    <https://www.invite2messenger.nl/Default.aspx>
>>
>>
>>
>>
>> --
>> Schell Scivally
>> efsubenovex@xxxxxxxxx <mailto:efsubenovex@xxxxxxxxx>
>> http://blog.efnx.com <http://blog.efnx.com/>
>>
>> ------------------------------------------------------------------------
>> Win elke dag een HTC Touch Diamond. Beter nog... win er twee!
>> <http://www.overaljevriendenbijje.nl/#tagwin>
>
>
> --
> http://www.earslap.com
>
>
> _______________________________________________
> 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/
>



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

_______________________________________________
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/