10 - ScremplerBoard
Part 2 of the scrempler cleanup - now the data processing of the control data coming from it.
Class code:
`
ScremplerBoard {</p>
var <network;
var <meannode;
var <>weights;
*new{
^super.new.init;
}
init{
weights = Array.fill( 6, 1 );
network = SWDataNetwork.new;
this.addHooks;
[ [1,\pressure],[2,\mean] ].do{ |it|
network.addExpected( it[0], it[1], 6 );
};
}
addHooks{
network.addHook( 1, {
network.nodes[1].action = MFunc.new;
network.nodes[1].createBus(Server.default);
meannode = MeanNode.new( 2, network, network.nodes[1].bus, Server.default );
meannode.set( \length, 100 );
fork{ 0.2.wait; meannode.start; };
});
network.addHook( 2, {
network.nodes[2].action = MFunc.new;
});
}
setData{ |data|
network.setData( 1, data * weights );
}
addAction{ |node,label,action|
network.nodes[ node ].action.addFirst( label, action );
}
removeAction{ |node, label|
network.nodes[ node ].action.removeAt( label );
}
enableAction{ |node, label|
network.nodes[ node ].action.enable( label );
}
disableAction{ |node, label|
network.nodes[ node ].action.disable( label );
}
}
`
Glueing the two classes together code:
`
s.boot;
~players = 3.collect{ ScremplerPlayer.new( 5 ) };
~board = ScremplerBoard.new;
~board.weights = [ 1.25, 1.5, 2.5, 5, 5, 5 ];
(
OSCdef( \scrempler, { |msg|
if ( msg[1] == 9 ){
~board.setData( msg.copyRange( 2, 7 ); );
};
}, "/minibee/data" );
);
(
~board.addAction( 2, \ratemod, { |data|
data.at( [ 0,2,4] ).do{ |it, i|
~players[i].player.setUni( \ratemod, it );
};
});
~board.addAction( 2, \freqmod, { |data|
data.at( [1,3,5] ).do{ |it, i|
~players[i].filter.setUni( \freqmod, it );
};
});
~board.addAction( 2, \delayComb, { |data|
data.at( [0,2,4] ).do{ |it, i|
~players[i].comb.setUni( \delay, 1-it );
};
});
~board.addAction( 2, \delayPitch, { |data|
data.at( [1,3,5] ).do{ |it, i|
~players[i].pitcher.setUni( \delay, 1-it );
};
});
~board.addAction( 2, \decayPitch, { |data|
data.at( [0,2,3] ).do{ |it, i|
~players[i].pitcher.setUni( \decay, it );
};
});
);
`