def get_param_data_resp_cl(rcv_bytes): size_bytes = unnibblize(rcv_bytes[5:9]) nb_control_levels = unnibblize(rcv_bytes[(9+2*size_bytes):(9+2*size_bytes)+4]) control_levels = [] cl_start_b = (9+2*size_bytes)+4 for i in range(0, nb_control_levels): start_b = cl_start_b+(i*4) control_levels.append(unnibblize(rcv_bytes[start_b:start_b+4])) return control_levels
def parse_system_config_resp(rcv_bytes): return { 'version_major': unnibblize(rcv_bytes[5:7]), 'version_minor': unnibblize(rcv_bytes[7:9]), 'time': unnibblize_str(rcv_bytes[9:25]), 'date': unnibblize_str(rcv_bytes[25:47]), 'nb_params': unnibblize(rcv_bytes[47:51]), 'bottom_param': unnibblize(rcv_bytes[51:55]), 'max_control_levels': unnibblize(rcv_bytes[55:59]), }
def parse_effects_params_resp(rcv_bytes): label = unnibblize_str(rcv_bytes[9:31]) nb_params = unnibblize(rcv_bytes[31:33]) rcv_bytes = rcv_bytes[33:] params = [] for i in range(0, nb_params): params.append(unnibblize(rcv_bytes[i*4:i*4+4])) return { 'label': label, 'params': params, }
def get_param_label(inport, outport, control_levels, device_id = 0x7f, sync=True): rcv = request_by_control_levels(inport, outport, 0x05, control_levels, device_id) if sync: rcv = rcv.bytes() size_chars = unnibblize(rcv[5:9]) return { 'label': unnibblize_str(rcv[9:(9+2*size_chars)]), }
def get_param_desc(inport, outport, param_type, device_id = 0x7f, sync=True): rcv = request_by_param_type(inport, outport, 0x04, param_type, device_id, sync) if sync: rcv = rcv.bytes() p_type = unnibblize(rcv[5:9]) size_chars_label = unnibblize(rcv[9:11]) label = unnibblize_str(rcv[11:(11+2*size_chars_label)]) p = (11+2*size_chars_label) bs=2 size_bytes = unnibblize(rcv[p:p+(2*bs)]) p += (2*bs) bs=1 control_flags = unnibblize(rcv[p:p+(2*bs)]) p += (2*bs) bs=2 option_p_type = unnibblize(rcv[p:p+(2*bs)]) p += (2*bs) bs=1 nb_units_per_limit = unnibblize(rcv[p:p+(2*bs)]) p += (2*bs) rcv = rcv[p:] vals = [] nb_vals = math.floor(len(rcv)/(3*2*2)) # NB: this is hackish for i in range(0, nb_vals): vals.append({ # 'min': decode_negative_maybe(unnibblize(rcv[i*(3*2*2):i*(3*2*2)+4])), # 'max': decode_negative_maybe(unnibblize(rcv[i*(3*2*2)+4:i*(3*2*2)+8])), 'min': unnibblize(rcv[i*(3*2*2):i*(3*2*2)+4]), 'max': unnibblize(rcv[i*(3*2*2)+4:i*(3*2*2)+8]), 'display_unit': unnibblize(rcv[i*(3*2*2)+8:i*(3*2*2)+12]), }) return { 'param_type': p_type, 'label': label, 'param_size': size_bytes, 'control_flags': control_flags, 'option_param_type': option_p_type, 'nb_units_per_limit': nb_units_per_limit, 'vals': vals, }
def db_dump(inport, outport, device_id = 0x7f, sync=True): payload = [0x06, 0x09, device_id, 0x06, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] snd = mido.Message('sysex', data=payload) ic(snd.hex()) outport.send(snd) if sync: time.sleep(SYNC_RQ_WAIT) rcv = inport.receive() ic(rcv.hex()) rcv = rcv.bytes() rcv_payload = rcv[5:] out = [] nb_programs = math.floor(len(rcv_payload)/6) # NB: this is hackish for i in range(0, nb_programs): out.append({ 'effect_type': unnibblize(rcv_payload[(i*(4+2)):i*(4+2)+4]), 'source_type': unnibblize(rcv_payload[i*(4+2)+4:i*(4+2)+6]), }) return out
def parse_program_info_resp(rcv_bytes): return { 'program_number': unnibblize(rcv_bytes[5:9]), 'label': unnibblize_str(rcv_bytes[9:33]), 'algos': [ unnibblize(rcv_bytes[33:35]), # Pitch unnibblize(rcv_bytes[35:37]), # Chorus unnibblize(rcv_bytes[37:39]), # EQ unnibblize(rcv_bytes[39:41]), # Mod unnibblize(rcv_bytes[41:43]), # Reverb unnibblize(rcv_bytes[43:45]), # Delay ] }
def get_param_type(inport, outport, control_levels, device_id = 0x7f, sync=True): rcv = request_by_control_levels(inport, outport, 0x03, control_levels, device_id) if sync: rcv = rcv.bytes() return unnibblize(rcv[5:9])
def get_param_display(inport, outport, control_levels, device_id = 0x7f, sync=True): rcv = request_by_control_levels(inport, outport, 0x02, control_levels, device_id, sync) if sync: rcv = rcv.bytes() size_bytes = unnibblize(rcv[5:9]) return unnibblize_str(rcv[9:(9+2*size_bytes)])
def get_param_data_resp_v(rcv_bytes, value_type): size_bytes = unnibblize(rcv_bytes[5:9]) v_parse_fn = unnibble_fn_for_type(value_type) return v_parse_fn(rcv_bytes[9:(9+2*size_bytes)])