Пример #1
0
    def testEncodeDecode(self):
        cmd = sysex.Command(sysex.Z48_ID, '\x20\x04', 'get_no_disks', (), (sysex_types.TYPEBYTE, sysex_types.BYTE,),
            userref_type=sysex_types.USERREF)
        request = sysex.Request(cmd, (), 0)
        bytes = z48._execute(request.get_bytes())
        length, request_id = sysex_types.USERREF.decode(bytes[3:])

        self.assertEquals(0, request_id)

        cmd = sysex.Command(sysex.S56K_ID, '\x10\x04', 'get_no_disks', (), (sysex_types.BYTE,),
            userref_type=sysex_types.S56K_USERREF)
        request = sysex.Request(cmd, (), 16000)

        bytes = z48._execute(request.get_bytes())
        length, request_id = sysex_types.USERREF.decode(bytes[3:])

        self.assertEquals(3, length)
        self.assertEquals(16000, request_id)

        cmd = sysex.Command(sysex.Z48_ID, '\x20\x04', 'get_no_disks', (), (sysex_types.TYPEBYTE, sysex_types.BYTE,),
            userref_type=sysex_types.Z48USERREF)

        request = sysex.Request(cmd, (), 126)
        bytes = z48._execute(request.get_bytes())
        result = sysex.Reply(bytes, cmd)
        request_id = result.get_request_id()
        self.assertEquals(126, request_id)

        request = sysex.Request(cmd, (), 16000)
        bytes = z48._execute(request.get_bytes())
        result = sysex.Reply(bytes, cmd)
        request_id = result.get_request_id()
        self.assertEquals(16000, request_id)
Пример #2
0
 def testParseHandleNameArray(self):
     bytes = sysex.repr_bytes(['F0','47','5F','00','52','14','02','20','08','44',
         '72','79','20','4B','69','74','20','30','32','00','08','50','72','6F','67','72','61','6D','20','31','00',
         '08','53','79','6E','74','68','54','65','73','74','00','F7'])
     cmd = sysex.Command(sysex.Z48_ID, '\x14\x02\02', 'programtools', 'get_handles_names', (), None)
     reply = sysex.Reply(bytes, cmd)
     self.assertEquals(('Dry Kit 02', 'Program 1', 'SynthTest'), reply.get_return_value())
Пример #3
0
    def testCreateRequest(self):
        # Select disk
        command = sysex.Command('\x5f', '\x20\x02', 'disktools', 'select_disk', (sysex_types.WORD,), None)
        bytes = sysex.Request(command, (256,)).get_bytes()
        self.assertEquals(
            '\xf0\x47\x5f\x00\x20\x02\x00\x02\xf7', bytes)

        # Select root folder:
        folder = ''
        command = sysex.Command('\x5f', '\x20\x13', 'disktools', 'open_folder', (sysex_types.STRING,), None)
        bytes = sysex.Request(command, (folder,)).get_bytes()
        self.assertEquals(
            '\xf0\x47\x5f\x00\x20\x13\x00\xf7', bytes)

        # Select autoload folder:
        folder = 'autoload'
        command = sysex.Command('\x5f', '\x20\x13', 'disktools', 'open_folder', (sysex_types.STRING,), None)
        bytes = sysex.Request(command, (folder,)).get_bytes()
        self.assertEquals(
            '\xf0\x47\x5f\x00\x20\x13\x61\x75\x74\x6f\x6c\x6f\x61\x64\x00\xf7', bytes)
Пример #4
0
 def testParseExtendedDisklist(self):
     bytes = sysex.repr_bytes(
         ['f0', '47', '5e', '20', '00', '00', '52', '10', '05', '01', '00', '00',
         '08', '00', '01', '4e', '6f', '20', '64', '69', '73', '6b', '00', '01', '01',
         '03', '08', '01', '00', '4e', '6f', '20', '64', '69', '73', '6b', '00', '01',
         '02', '03', '08', '02', '00', '4e', '6f', '20', '64', '69', '73', '6b', '00',
         '02', '03', '03', '01', '04', '01', '4e', '6f', '20', '44', '69', '73', '6b',
         '20', '4e', '61', '6d', '65', '00', 'f7'])
     cmd = sysex.Command(sysex.S56K_ID, '\x10\x05', 'dummy', 'dummy', (),(
         sysex_types.DISKLIST,), sysex_types.USERREF)
     reply = sysex.Reply(bytes, cmd)
     self.assertEquals(
         ((1, 0, 8, 0, 1, 'No disk'), (129, 3, 8, 1, 0, 'No disk'),
         (257, 3, 8, 2, 0, 'No disk'), (386, 3, 1, 4, 1, 'No Disk Name'))
         , reply.get_return_value())
Пример #5
0
 def test_create_arg_bytes(self): #IGNORE:W0212
     dcmd = sysex.Command(sysex.Z48_ID, '\x20\x05', 'dummy', 'dummy', (sysex_types.BYTE,), None)
Пример #6
0
    def testCreateReply(self):
        DEFAULT_USERREF = '\x00'
        bytes = (sysex.START_SYSEX, sysex.AKAI_ID, sysex.Z48_ID, DEFAULT_USERREF, 
                 sysex.REPLY_ID_REPLY, '\x20\x05', '\x01', sysex.END_SYSEX)
        dcmd = sysex.Command(sysex.Z48_ID, '\x20\x05', 'dummy', 'dummy', (), (sysex_types.BYTE,))
        reply = sysex.Reply(''.join(bytes), dcmd)
        self.assertEquals(1, reply.get_return_value())

        bytes =  (
            sysex.START_SYSEX, sysex.AKAI_ID, '\x5e\x20', '\x00',
            sysex.REPLY_ID_REPLY, '\x20\x05', '\x01', sysex.END_SYSEX)
        custom_cmd = sysex.Command('\x5e\x20', '\x20\x05', 'disktools', 'dummy', (),(sysex_types.BYTE,))
        reply = sysex.Reply(''.join(bytes), custom_cmd)
        self.assertEquals(1, reply.get_return_value())

        dcmd.reply_spec = (sysex_types.WORD, sysex_types.BYTE, sysex_types.BYTE, sysex_types.BYTE, sysex_types.BYTE, sysex_types.STRING)
        bytes = (
            sysex.START_SYSEX, sysex.AKAI_ID, sysex.Z48_ID, '\x00',
            sysex.REPLY_ID_REPLY, '\x20\x05', '\x00','\x02\x01\x02', '\x00',
            '\x01\x5a\x34\x38\x20\x26\x20\x4d\x50\x43\x34\x4b', '\x00', sysex.END_SYSEX)
        reply = sysex.Reply(''.join(bytes), dcmd)
        self.assertEquals((256, 1, 2, 0, 1, 'Z48 & MPC4K'), reply.get_return_value())

        # Future: should raise unknown disk error
        dcmd.id = '\x20\x05'
        dcmd.reply_spec = ()
        bytes = '\xf0G_\x00E \x00\x00\x03\xf7'
        self.assertRaises(model.SamplerException, sysex.Reply, bytes, dcmd)
        # using pad type if we encounter bytes not according to specification
        dcmd.id = '\x20\x10'
        dcmd.reply_spec = None
        bytes =  (
            sysex.START_SYSEX, sysex.AKAI_ID, sysex.Z48_ID,
            '\x00', sysex.REPLY_ID_REPLY, '\x20\x10', '\x02',
            '\x15', '\x00', '\xf7')
        reply = sysex.Reply(''.join(bytes), dcmd)
        self.assertEquals(21, reply.get_return_value())

        # not possible yet how to deal with the dump request replies
        dcmd.reply_spec = ()
        self.assertRaises(sysex.ParseException,  sysex.Reply, '\xf0G_ ' + '\x00' * 2 
                          + 'R\x10 i\x01\xf7', dcmd)

        # reply on 'bulk command 10 05' 10 0a 00 f0 47 5e 20 00 00 10 05 15 f7
        dcmd.id = '\x10\x05'
        dcmd.reply_spec = (sysex_types.WORD, sysex_types.BYTE, sysex_types.BYTE, sysex_types.BYTE, 
                           sysex_types.BYTE, sysex_types.STRING)
        bytes = '\xf0\x47\x5f\x00\x52\x10\x05\x00\x02\x01\x02\x00\x01\x5a\x34\x38\x20\x26\x20\x4d\x50\x43\x34\x4b\x00\xf7'
        reply = sysex.Reply(bytes, dcmd)
        self.assertEquals((256, 1, 2, 0, 1, 'Z48 & MPC4K'), reply.get_return_value())

        dcmd.id = '\x10\x22'
        bytes = '\xf0\x47\x5f\x00\x52\x10\x22\x4d\x65\x6c\x6c\x20\x53\x74\x72\x69\x6e\x67\x20\x41\x32\x2e\x77\x61\x76\x00\xf7'
        dcmd.reply_spec = (sysex_types.STRING,)
        reply = sysex.Reply(bytes, dcmd)
        self.assertEquals('Mell String A2.wav', reply.get_return_value())

        dcmd.id = '\x10\x22'
        bytes = '\xf0\x47\x5f\x00\x52\x10\x22\x4d\x65\x6c\x6c\x6f\x74\x72\x6f\x6e\x20\x53\x74\x72\x69\x6e\x67\x73\x2e\x61\x6b\x70\x00\xf7'
        dcmd.reply_spec = (sysex_types.STRING,)
        reply = sysex.Reply(bytes, dcmd)
        self.assertEquals('Mellotron Strings.akp', reply.get_return_value())

        dcmd.id = '\x07\x01'
        bytes = '\xf0\x47\x5f\x00\x52\x07\x01\x08\x5a\x38\x20\x53\x61\x6d\x70\x6c\x65\x72\x00\xf7'
        dcmd.reply_spec = (sysex_types.STRING,)
        reply = sysex.Reply(bytes, dcmd)
        self.assertEquals('Z8 Sampler', reply.get_return_value())

        bytes = '\xf0G_\x00E\x1eJ\x00\x00\xf7'
        self.assertRaises(NotImplementedError, sysex.Reply, bytes, self.createCommand())
Пример #7
0
 def createCommand(self):
     return sysex.Command(sysex.Z48_ID, '\x20\x05', 'dummy', 'dummy', (), (sysex_types.BYTE,))
Пример #8
0
 def testCreateS56KRequest(self):
     command = sysex.Command('\x5e', '\x07\x01', 'disktools', 'get_sampler_name', (),(sysex_types.STRING,), sysex_types.S56K_USERREF)
     bytes = sysex.Request(command, ()).get_bytes()
     self.assertEquals(
         '\xf0\x47\x5e\x20\x00\x00\x07\x01\xf7', bytes)
Пример #9
0
 def testRequestWithNondefaultUserref(self):
     # slightly theoretical, because the z48 doesn't process these requests as expected
     command = sysex.Command('\x5f', '\x07\x01', 'disktools', 'get_sampler_name', (),(sysex_types.STRING,), sysex_types.USERREF)
     bytes = sysex.Request(command, (), request_id=129).get_bytes()
     self.assertEquals(
         '\xf0\x47\x5f\x20\x01\x01\x07\x01\xf7', bytes)
Пример #10
0
 def test_keygroup_index(self):
     cmd = sysex.Command('_', '\x13\x30', 'programtools', 'get_envelope_rate1', (sysex_types.BYTE,), None)
     req = sysex.AlternativeRequest(65536, [cmd, cmd], [[1],[2]], index=3)
     self.assertEquals('\xf0G_\x00a\x07\x00\x00\x04\x00\x03\x020\x01\x020\x02\xf7', req.get_bytes())
Пример #11
0
 def test_with_multiple_args(self):
     cmd = sysex.Command('_', '\x0E\x09', 'programtools', 'set_mod_start', (sysex_types.BYTE, sysex_types.SWORD), None)
     req = sysex.AlternativeRequest(65536, [cmd, cmd], [[1,1],[1,2]])
     self.assertEquals('\xf0G_\x00a\x02\x00\x00\x04\x00\x05\t\x01\x00\x01\x00\x05\t\x01\x00\x02\x00\xf7', req.get_bytes())
Пример #12
0
 def test_with_args(self):
     cmd = sysex.Command('_', '\x1E\x26', 'programtools', 'set_playback_mode', (sysex_types.BYTE,), None)
     req = sysex.AlternativeRequest(65536, [cmd, cmd], [[1],[2]])
     self.assertEquals('\xf0G_\x00`\x02\x00\x00\x04\x00\x02&\x01\x02&\x02\xf7', req.get_bytes())
Пример #13
0
 def test_no_args(self):
     cmd = sysex.Command(sysex.Z48_ID, '\x1F\x50', 'sampletools', 'get_sample_length', (), None)
     req = sysex.AlternativeRequest(65536, [cmd], [])
     self.assertEquals('\xf0G_\x00`\x03\x00\x00\x04\x00\x01P\xf7', req.get_bytes())
Пример #14
0
 def testParseEchoReply(self):
     bytes = sysex.repr_bytes(
         ['f0', '47', '5f', '00', '52', '00', '06', '0b', '01', '01', '01', '01', 'f7'])
     cmd = sysex.Command(sysex.Z48_ID, '\x00\x06', 'sysextools', 'query', (), None)
     reply = sysex.Reply(bytes, cmd)
     self.assertEquals((1,1,1,1), reply.get_return_value())
Пример #15
0
 def testParseUserRef(self):
      cmd = sysex.Command(sysex.S56K_ID, '\x07\x01', 'dummy', 'dummy', (), (sysex_types.BYTE,), sysex_types.S56K_USERREF)
      bytes = '\xf0\x47\x5e\x20\x7e\x00\x52\x07\x01\x08\x5a\x38\x20\x53\x61\x6d\x70\x6c\x65\x72\x00\xf7'
      reply = sysex.Reply(bytes, cmd)
      self.assertEquals(126, reply.get_request_id())