Ejemplo n.º 1
0
Archivo: file.py Proyecto: msg/g2ools
  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()
Ejemplo n.º 2
0
Archivo: file.py Proyecto: msg/g2ools
 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()
Ejemplo n.º 3
0
 def format(self, patch, data):
     bitstream = BitStream(data)
     if self.area == SETTINGS:
         self.format_settings(patch.settings, bitstream)
     else:
         area = get_patch_area(patch, self.area)
         self.format_area(area, bitstream)
     return bitstream.tell_bit()
Ejemplo n.º 4
0
Archivo: file.py Proyecto: msg/g2ools
 def format(self, patch, data):
   bitstream = BitStream(data)
   if self.area == SETTINGS:
     self.format_settings(patch.settings, bitstream)
   else:
     area = get_patch_area(patch, self.area)
     self.format_area(area, bitstream)
   return bitstream.tell_bit()
Ejemplo n.º 5
0
 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()
Ejemplo n.º 6
0
Archivo: file.py Proyecto: msg/g2ools
 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()
Ejemplo n.º 7
0
 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()
Ejemplo n.º 8
0
    def format(self, performance, data):
        bitstream = BitStream(data)
        write_bits = bitstream.write_bits
        description = performance.description

        for name, nbits in self.description_attrs:
            write_bits(nbits, getattr(description, name))

        for slot in performance.slots:
            write_string(bitstream, slot.name, 16)
            for name, nbits in self.slot_attrs:
                write_bits(nbits, getattr(slot.description, name))

        return bitstream.tell_bit()
Ejemplo n.º 9
0
Archivo: file.py Proyecto: msg/g2ools
  def format(self, performance, data):
    bitstream = BitStream(data)
    write_bits = bitstream.write_bits
    description = performance.description

    for name, nbits in self.description_attrs:
      write_bits(nbits, getattr(description, name))

    for slot in performance.slots:
      write_string(bitstream, slot.name, 16)
      for name, nbits in self.slot_attrs:
        write_bits(nbits, getattr(slot.description, name))

    return bitstream.tell_bit()
Ejemplo n.º 10
0
Archivo: file.py Proyecto: msg/g2ools
 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()
Ejemplo n.º 11
0
 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()
Ejemplo n.º 12
0
    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()
Ejemplo n.º 13
0
 def format(self, patch, data):
     bitstream = BitStream(data, 7 * 8)
     self.format_description(patch.description, bitstream)
     return bitstream.tell_bit()
Ejemplo n.º 14
0
Archivo: file.py Proyecto: msg/g2ools
 def format(self, patch, data):
   bitstream = BitStream(data)
   bitstream.write_str(patch.textpad)
   return bitstream.tell_bit()
Ejemplo n.º 15
0
Archivo: file.py Proyecto: msg/g2ools
 def format(self, patch, data):
   bitstream = BitStream(data)
   area = get_patch_area(patch, self.area)
   self.format_area(area, bitstream)
   return bitstream.tell_bit()
Ejemplo n.º 16
0
 def format(self, patch, data):
     bitstream = BitStream(data)
     area = get_patch_area(patch, self.area)
     self.format_area(area, bitstream)
     return bitstream.tell_bit()
Ejemplo n.º 17
0
 def format(self, patch, data):
     bitstream = BitStream(data)
     bitstream.write_str(patch.textpad)
     return bitstream.tell_bit()