def __init__(self, channel=-1, sysex_buffer=None,
                 req_procedure=-1, error_code=-1):
        self.req_procedure = req_procedure
        self.error_code = error_code
        self.error_msg = ''

        JStationSysexEvent.__init__(self, channel, sysex_buffer=sysex_buffer)
Beispiel #2
0
    def __init__(self, sysex_buffer=None, program=None, isolated=False):
        self.bank = -1
        self.number = -1
        self.program = None
        self.isolated = isolated
        if program:
            self.program = program.copy()
            if isolated:
                self.program.number = 0

            self.bank = self.program.bank
            self.number = self.program.number

        JStationSysexEvent.__init__(self,
                                    JStationSysexEvent.ALL_CHANNELS,
                                    sysex_buffer=sysex_buffer)

        if sysex_buffer != None and self.is_valid():
            # first part is a header (already parsed)
            # second part is a OneProgramResponse
            one_prg_resp = OneProgramResponse(JStationSysexEvent.ALL_CHANNELS,
                                              sysex_buffer=self.sysex_buffer)
            if one_prg_resp.is_valid():
                self.program = one_prg_resp.program
            else:
                self.has_error = True
                print('Invalid nested event: %s' % (one_prg_resp))
 def parse_data_buffer(self):
     JStationSysexEvent.parse_data_buffer(self)
     # no length in this message
     self.req_procedure = self.read_next_bytes(2)
     self.error_code = self.read_next_bytes(2)
     self.error_msg = self.ERRORS.get(self.error_code)
     if self.error_msg == None:
          self.error_msg = '*Unknown code*'
Beispiel #4
0
    def parse_data_buffer(self):
        JStationSysexEvent.parse_data_buffer(self)
        data_length = self.read_next_bytes(4)

        if self.is_valid:
            self.receive_channel = self.read_next_bytes(2)
            self.transmit_channel = self.read_next_bytes(2)
            self.sysex_channel = self.read_next_bytes(2)
Beispiel #5
0
    def parse_data_buffer(self):
        JStationSysexEvent.parse_data_buffer(self)
        if self.is_valid():
            self.bank = self.read_next_bytes(2)
            self.number = self.read_next_bytes(2)
            self.unknown_data = self.read_next_bytes(2)
            self.null_len = self.read_next_bytes(4)

            self.isolated = (self.number == 0)
Beispiel #6
0
    def build_data_buffer(self):
        data_set = list()
        data_set.append(self.bank)
        data_set.append(self.number)
        data_set.append(1)  # unknown data

        JStationSysexEvent.build_data_buffer(self,
                                             pre_len_data=data_set,
                                             post_len_data=[])
    def build_data_buffer(self):
        data = list()
        data.append(self.stereo_mono)
        data.append(self.dry_track)
        data.append(self.digital_out_level)
        data.append(self.global_cabinet)
        data.append(self.midi_merge)
        data.append(self.midi_channel)

        JStationSysexEvent.build_data_buffer(self, post_len_data=data)
Beispiel #8
0
    def build_sysex_buffer(self):
        JStationSysexEvent.build_sysex_buffer(self)

        if self.is_valid():
            one_prg_resp = OneProgramResponse(JStationSysexEvent.ALL_CHANNELS,
                                              program=self.program)
            if one_prg_resp.is_valid():
                self.sysex_buffer.append(one_prg_resp.sysex_buffer)
            else:
                self.has_error = True
Beispiel #9
0
 def build_data_buffer(self):
     if self.RESP_ON_CHANNEL == self.response_on or \
             self.RESP_ON_7f == self.response_on:
         JStationSysexEvent.build_data_buffer(
             self, pre_len_data=[self.response_on]
         )
     else:
         self.data_buffer = list()
         self.is_valid = False
         print('Response on not defined for ReqWhoAmI SysEx')
    def __init__(self, channel=-1, sysex_buffer=None,
                 stereo_mono=-1, dry_track=-1, digital_out_level=-1,
                 global_cabinet=-1, midi_merge=-1, midi_channel=-1):
        self.stereo_mono = stereo_mono
        self.dry_track = dry_track
        self.digital_out_level = digital_out_level
        self.global_cabinet = global_cabinet
        self.midi_merge = midi_merge
        self.midi_channel = midi_channel

        JStationSysexEvent.__init__(self, channel, sysex_buffer=sysex_buffer)
Beispiel #11
0
    def __init__(self,
                 channel=-1,
                 sysex_buffer=None,
                 receive_channel=-1,
                 transmit_channel=-1,
                 sysex_channel=-1):
        self.receive_channel = receive_channel
        self.transmit_channel = transmit_channel
        self.sysex_channel = sysex_channel

        JStationSysexEvent.__init__(self, channel, sysex_buffer=sysex_buffer)
Beispiel #12
0
    def parse_data_buffer(self):
        JStationSysexEvent.parse_data_buffer(self)
        data_len = self.read_next_bytes(4)
        if data_len > 2:
            # For some reasons, data len in a bank export from J-Edit
            # is 4 when the actual size to read is 2 just like
            # for the regular StartBankDumpResponse sent by the J-Station
            print('Fixing data len %d for StartBankDumpResponse' % (data_len))
            data_len = 2

        if self.is_valid():
            self.total_len = self.read_next_bytes(2 * data_len)
    def parse_data_buffer(self):
        JStationSysexEvent.parse_data_buffer(self)

        bank_nb = self.read_next_bytes(2)
        prg_nb = self.read_next_bytes(2)

        data_len = self.read_next_bytes(4)
        if self.is_valid():
            self.program = Program(bank_nb,
                                   prg_nb,
                                   sysex_buffer=self.sysex_buffer,
                                   data_len=data_len)
            if not self.program.is_valid:
                self.has_error = True
    def parse_data_buffer(self):
        JStationSysexEvent.parse_data_buffer(self)
        data_len = self.read_next_bytes(4)

        if self.is_valid():
            has_changed = False
            if self.version == 2:
                has_changed = self.read_next_bytes(2)
                data_len -= 1

            self.program = Program(sysex_buffer=self.sysex_buffer,
                                   data_len=data_len,
                                   has_changed=has_changed)
            if not self.program.is_valid:
                self.has_error = True
    def parse_data_buffer(self):
        JStationSysexEvent.parse_data_buffer(self)
        data_len = self.read_next_bytes(4)

        if self.is_valid():
            if data_len == 6:
                self.stereo_mono = self.read_next_bytes(2)
                self.dry_track = self.read_next_bytes(2)
                self.digital_out_level = self.read_next_bytes(2)
                self.global_cabinet = self.read_next_bytes(2)
                self.midi_merge = self.read_next_bytes(2)
                self.midi_channel = self.read_next_bytes(2)
            else:
                print('UtilitySettingsResponse: data len error: '\
                      'got %d expected 6'%(data_len))
Beispiel #16
0
    def import_buffer(self, sysex_data):
        sysex_event = JStationSysexEvent.build_from_sysex_buffer(
            sysex_buffer=SysexBuffer(sysex_data))
        if sysex_event and sysex_event.is_valid():
            has_changes = False
            if type(sysex_event) is OneProgramDump:
                self.import_current_prg(sysex_event.program)
                has_changes |= self.current_program.has_changed

            elif type(sysex_event) is BankDump:
                for program in sysex_event.programs:
                    if program.number == self.current_program.number:
                        self.import_current_prg(program)
                        has_changes |= self.current_program.has_changed
                    else:
                        self.programs[program.number].change_to(program)
                        if self.programs[program.number].has_changed:
                            self.update_program_in_list(
                                self.programs[program.number])
                            has_changes = True
            else:
                print('Attempting to import %s'%(sysex_event))

            self.set_has_changes(has_changes)
        else:
            # TODO: feedback to user - use notification?
            print('Couldn\'t import program from buffer')
 def __str__( self ):
     return '%s, stereo mono: %d, dry track: %d, '\
            'digital out level: %d, global cabinet: %d, '\
            'midi merge: %d, midi channel: %d'\
            %(JStationSysexEvent.__str__(self),
              self.stereo_mono, self.dry_track,
              self.digital_out_level, self.global_cabinet,
              self.midi_merge, self.midi_channel)
def test():
    print('\n==== MidiEventFactory test')

    CCMidiEvent.register_event_type_builder()
    CCMidiEvent.register()

    JStationSysexEvent.register_event_type_builder()
    WhoAmIResponse.register()

    sysex_data = [
        0xf0, 0, 0, 0x10, 0x7f, 0x54, 0x41, 0, 1, 0, 3, 0, 0, 0, 0, 0, 0, 0, 1,
        121, 0xf7
    ]
    print('input sysex data: %s' %
          ['x%02x' % (val & 0xff) for val in sysex_data])

    sysex_seq_event = alsaseq.SeqEvent(alsaseq.SEQ_EVENT_SYSEX)
    sysex_evt_data = dict()
    sysex_evt_data['ext'] = sysex_data
    sysex_seq_event.set_data(sysex_evt_data)

    factory = MidiEventFactory()
    sysex_event = factory.build_from_seq_event(sysex_seq_event)
    if sysex_event:
        print(sysex_event.is_valid())
        print(str(sysex_event))
    else:
        print('sysex not recognised')

    cc_seq_event = alsaseq.SeqEvent(alsaseq.SEQ_EVENT_CONTROLLER)
    cc_data = dict()
    cc_data['control.channel'] = 1
    cc_data['control.param'] = 34
    cc_data['control.value'] = 20
    cc_seq_event.set_data(cc_data)

    cc_event = factory.build_from_seq_event(cc_seq_event)
    if cc_event:
        print(cc_event.is_valid())
        print(str(cc_event))
    else:
        print('cc not recognised')
Beispiel #19
0
    def __init__(self, channel=-1, sysex_buffer=None, total_len=-1):
        self.total_len = total_len

        JStationSysexEvent.__init__(self, channel, sysex_buffer=sysex_buffer)
Beispiel #20
0
 def __str__(self):
     return '%s\n%s' % (JStationSysexEvent.__str__(self), self.program)
Beispiel #21
0
 def build_data_buffer(self):
     JStationSysexEvent.build_data_buffer(self, pre_len_data=[self.prg_nb])
Beispiel #22
0
 def __str__(self):
     return '%s, prg nb: %d' % (JStationSysexEvent.__str__(self),
                                self.prg_nb)
Beispiel #23
0
 def __str__(self):
     return '%s, receive ch: %d, transmit ch: %d, '\
            'sysex ch: %d'%(JStationSysexEvent.__str__(self),
                            self.receive_channel, self.transmit_channel,
                            self.sysex_channel)
Beispiel #24
0
 def __init__(self, channel=-1, sysex_buffer=None):
     JStationSysexEvent.__init__(self, channel, sysex_buffer)
 def __str__(self):
     return '%s, request procedure: x%02x, message: %s (%d)'\
             %(JStationSysexEvent.__str__(self),
               self.req_procedure, self.error_msg, self.error_code)
 def build_data_buffer(self):
     JStationSysexEvent.build_data_buffer(
         self,
         post_len_data=self.program.get_data_buffer(with_has_changed=True))
Beispiel #27
0
 def build_data_buffer(self):
     total_len_2_bytes = [self.total_len % 0x100, self.total_len // 0x100]
     JStationSysexEvent.build_data_buffer(self,
                                          post_len_data=total_len_2_bytes)
    def __init__(self, channel=-1, sysex_buffer=None, program=None):
        self.program = program

        JStationSysexEvent.__init__(self, channel, sysex_buffer=sysex_buffer)
Beispiel #29
0
 def __str__(self):
     return '%s, total total_len: %d' % (JStationSysexEvent.__str__(self),
                                         self.total_len)
 def build_data_buffer(self):
     JStationSysexEvent.build_data_buffer(
         self,
         pre_len_data=[self.program.bank, self.program.number],
         post_len_data=self.program.get_data_buffer())