diff options
| author | Yuval Adam <yuv.adm@gmail.com> | 2014-06-08 01:18:11 +0300 |
|---|---|---|
| committer | Yuval Adam <yuv.adm@gmail.com> | 2014-06-08 01:21:40 +0300 |
| commit | b96cff07e6e9915980d3c924e60fe92d9739f142 (patch) | |
| tree | f8b6e3e6fe7b9365b28dfc1ff2a57503cee004b7 /client.py | |
| parent | b5b443ff46f4e02c804b942d1aa0d53ef8f5d125 (diff) | |
Process single ugly
Diffstat (limited to 'client.py')
| -rw-r--r-- | client.py | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -1,3 +1,4 @@ +from pprint import pprint from unipath import FSPath as Path DATA_DIR = Path(__file__).absolute().ancestor(1).child('data') @@ -22,7 +23,7 @@ class LightLoopClient(object): def init_sequences(self, sequence_data): for sequence in sequence_data.split('#')[1:]: lines = sequence.split('\n') - name, sequence_data = lines[0].strip(), [map(int, list(x)) for x in filter(lambda x: x != '', lines[1:])] + name, sequence_data = lines[0].strip(), [list(x) for x in filter(lambda x: x != '', lines[1:])] self.sequences[name] = sequence_data def init_composition(self, composition_data): @@ -30,8 +31,18 @@ class LightLoopClient(object): self.tempo = composition_data[0].split('_')[1] self.composition = [c.split(',') for c in composition_data[1:]] + def gen_packet(tree, channel, mode): + if tree > 7 or channel > 7 or mode > 1: + raise Exception('Bad values') + return (tree << 5) | (channel << 2) | mode + def process_single_loop(self): - print zip(*self.composition) + raw_data = '' + for frame in zip(*self.composition): + print frame + sequences = zip(*[zip(*self.sequences[seq]) for seq in frame]) + raw_data += ''.join([''.join([''.join(y) for y in x]) for x in sequences]) + print raw_data def loop(self): print self |
