mapping to bus index vs name

View: New views
3 Messages — Rating Filter:   Alert me  

mapping to bus index vs name

by Jonathan Segel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

so i just updated via svn (hadn't been in touch for a while) and find  
all my code is broken! yay!

so now, where previously i would use
dBus=Bus.new(\control, 25, 1, s);

and map it by index:
Synth("thing").map(\level, 25).play;

now i have to map by name?
Synth("thing").map(\level, dBus).play;


is there a easy way to continue to map by index?
_____________________________________
Jonathan Segel
http://www.magneticmotorworks.com




_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: mapping to bus index vs name

by James Harkins-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ooh, crikey, yeah, I think that should be fixed for backward compatibility.

It could check scalar-rate inputs to see if they are numbers and
assume kr mapping. (ar mapping would be less typical and would require
the user to use a Bus object.)

Maybe this? (Hope gmail doesn't muck up the formatting too badly)

        map { arg ... args;
                var bundle = this.mapMsg(*args);
                if(bundle[0].isString) {
                        server.sendBundle(nil, bundle);
                } {
                        server.sendBundle(nil, *bundle);
                };
        }
       
        mapMsg { arg ... args;
                var krVals, arVals, result;
                krVals = List.new;
                arVals = List.new;
                result = Array.new(2);
                args.pairsDo({ arg control, bus;
                        switch(bus.rate)
                                { \control } {
                                        krVals.addAll([control.asControlInput, bus.index, bus.numChannels])
                                }
                                { \scalar } {
                                        if(bus.isNumber) { krVals.addAll([control.asControlInput, bus, 1]) };
                                }
                                { \audio } {
                                        arVals.addAll([control.asControlInput, bus.index, bus.numChannels]);
                                };
                                // no default case, ignore others
                });
                if(krVals.size > 0, { result = result.add(["/n_mapn", nodeID] ++ krVals) });
                if(arVals.size > 0, { result = result.add(["/n_mapan",nodeID] ++ arVals) });
                if(result.size < 2, { result = result.flatten; });
                ^result;
        }

Jonathan, could you try this out and let us know if it works for you?

hjh

On Thu, Apr 23, 2009 at 5:25 PM, Jonathan Segel
<jsegel@...> wrote:

> so i just updated via svn (hadn't been in touch for a while) and find all my
> code is broken! yay!
>
> so now, where previously i would use
> dBus=Bus.new(\control, 25, 1, s);
>
> and map it by index:
> Synth("thing").map(\level, 25).play;
>
> now i have to map by name?
> Synth("thing").map(\level, dBus).play;
>
>
> is there a easy way to continue to map by index?


--
James Harkins /// dewdrop world
jamshark70@...
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: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: mapping to bus index vs name

by Jonathan Segel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

in Node.sc, right?
yes it appears to work..
thank you~

  Apr 23, 2009, at 3:22 PM, James Harkins wrote:

> map { arg ... args;
> var bundle = this.mapMsg(*args);
> if(bundle[0].isString) {
> server.sendBundle(nil, bundle);
> } {
> server.sendBundle(nil, *bundle);
> };
> }
>
> mapMsg { arg ... args;
> var krVals, arVals, result;
> krVals = List.new;
> arVals = List.new;
> result = Array.new(2);
> args.pairsDo({ arg control, bus;
> switch(bus.rate)
> { \control } {
> krVals.addAll([control.asControlInput, bus.index,  
> bus.numChannels])
> }
> { \scalar } {
> if(bus.isNumber) { krVals.addAll([control.asControlInput, bus,  
> 1]) };
> }
> { \audio } {
> arVals.addAll([control.asControlInput, bus.index,  
> bus.numChannels]);
> };
> // no default case, ignore others
> });
> if(krVals.size > 0, { result = result.add(["/n_mapn", nodeID] ++  
> krVals) });
> if(arVals.size > 0, { result = result.add(["/n_mapan",nodeID] ++  
> arVals) });
> if(result.size < 2, { result = result.flatten; });
> ^result;
> }

_____________________________________
Jonathan Segel
http://www.magneticmotorworks.com




_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/