def format(self, patch, data): bitstream = BitStream(data) write_bits = bitstream.write_bits bitstream.write_bitsa([8, 4, 10, 10], [ NVARIATIONS, NMORPHS, 0, 0]) # variations seem to be 9 bytes with first nibble variation # from 0 ~ 8 # number of morph parameters starts at byte 7-bit 0 for 5-bits morphs = patch.settings.morphs for variation in xrange(NVARIATIONS): write_bits(4, variation) bitstream.seek_bit(4 + (6 * 8) + 4, 1) # collect all morph_maps of this variation into 1 array morph_maps = [] for morph in morphs: morph_maps.extend(morph.maps[variation]) def mod_param_index_cmp(a, b): return cmp(a.param.module.index, b.param.module.index) morph_maps.sort(mod_param_index_cmp) write_bits(8, len(morph_maps)) for morph_map in morph_maps: values = [ morph_map.param.module.area.index, morph_map.param.module.index, morph_map.param.index, morph_map.morph.index, morph_map.range, ] # range is signed bitstream.write_bitsa([2, 8, 7, 4, 8], values) write_bits(4, 0) # always 0 bitstream.seek_bit(-4, 1) # remove last 4-bits return bitstream.tell_bit()
def format(self, patch, data): bitstream = BitStream(data) bitstream.write_bits(7, len(patch.ctrls)) for ctrl in patch.ctrls: param = ctrl.param bitstream.write_bitsa([7, 2, 8, 7], [ ctrl.midicc, param.module.area.index, param.module.index, param.index ]) return bitstream.tell_bit()
def format(self, patch, data): bitstream = BitStream(data) bitstream.write_bits(16, NKNOBS) for knob in patch.knobs: bitstream.write_bits(1, knob.assigned) if not knob.assigned: continue module = knob.param.module bitstream.write_bitsa([2, 8, 2, 7], [ module.area.index, module.index, knob.isled, knob.param.index ]) if type(patch) == Performance: bitstream.write_bits(2, knob.slot) return bitstream.tell_bit()
def format(self, patch, data): bitstream = BitStream(data) if len(patch.notes): lastnote = patch.lastnote if not lastnote: values = [ 64, 0, 0 ] else: values = [ lastnote.note, lastnote.attack, lastnote.release ] bitstream.write_bitsa([7, 7, 7], values) bitstream.write_bits(5, len(patch.notes)-1) for note in patch.notes: bitstream.write_bitsa([7, 7, 7], [note.note, note.attack, note.release]) else: bitstream.write_bits(24, 0x800000) bitstream.write_bits(24, 0x200000) return bitstream.tell_bit()
def format(self, patch, data): bitstream = BitStream(data) if len(patch.notes): lastnote = patch.lastnote if not lastnote: values = [64, 0, 0] else: values = [lastnote.note, lastnote.attack, lastnote.release] bitstream.write_bitsa([7, 7, 7], values) bitstream.write_bits(5, len(patch.notes) - 1) for note in patch.notes: bitstream.write_bitsa([7, 7, 7], [note.note, note.attack, note.release]) else: bitstream.write_bits(24, 0x800000) bitstream.write_bits(24, 0x200000) return bitstream.tell_bit()
def format(self, patch, data): bitstream = BitStream(data) write_bits = bitstream.write_bits bitstream.write_bitsa([8, 4, 10, 10], [NVARIATIONS, NMORPHS, 0, 0]) # variations seem to be 9 bytes with first nibble variation # from 0 ~ 8 # number of morph parameters starts at byte 7-bit 0 for 5-bits morphs = patch.settings.morphs for variation in xrange(NVARIATIONS): write_bits(4, variation) bitstream.seek_bit(4 + (6 * 8) + 4, 1) # collect all morph_maps of this variation into 1 array morph_maps = [] for morph in morphs: morph_maps.extend(morph.maps[variation]) def mod_param_index_cmp(a, b): return cmp(a.param.module.index, b.param.module.index) morph_maps.sort(mod_param_index_cmp) write_bits(8, len(morph_maps)) for morph_map in morph_maps: values = [ morph_map.param.module.area.index, morph_map.param.module.index, morph_map.param.index, morph_map.morph.index, morph_map.range, ] # range is signed bitstream.write_bitsa([2, 8, 7, 4, 8], values) write_bits(4, 0) # always 0 bitstream.seek_bit(-4, 1) # remove last 4-bits return bitstream.tell_bit()