/* * hexter_instance_handle_patches */ char * hexter_instance_handle_patches(hexter_instance_t *instance, const char *key, const char *value) { int section; DEBUG_MESSAGE(DB_DATA, " hexter_instance_handle_patches: received new '%s'\n", key); section = key[7] - '0'; if (section < 0 || section > 3) return dssp_error_message("patch configuration failed: invalid section '%c'", key[7]); pthread_mutex_lock(&instance->patches_mutex); if (!decode_7in6(value, 32 * sizeof(dx7_patch_t), (uint8_t *)&instance->patches[section * 32])) { pthread_mutex_unlock(&instance->patches_mutex); return dssp_error_message("patch configuration failed: corrupt data"); } if ((instance->current_program / 32) == section && instance->current_program != instance->overlay_program) dx7_patch_unpack(instance->patches, instance->current_program, instance->current_patch_buffer); pthread_mutex_unlock(&instance->patches_mutex); return NULL; /* success */ }
/* * hexter_instance_select_program */ void hexter_instance_select_program(hexter_instance_t *instance, unsigned long bank, unsigned long program) { /* no support for banks, so we just ignore the bank number */ if (program >= 128) return; instance->current_program = program; if (instance->overlay_program == program) { /* edit buffer applies */ memcpy(instance->current_patch_buffer, instance->overlay_patch_buffer, DX7_VOICE_SIZE_UNPACKED); } else { dx7_patch_unpack(instance->patches, program, instance->current_patch_buffer); } }
void on_editor_discard_button_press(GtkWidget *widget, gpointer data) { GUIDB_MESSAGE(DB_GUI, ": on_editor_discard_button_press called\n"); gtk_widget_hide(edit_save_position_window); edit_buffer_active = FALSE; gui_data_send_edit_buffer_off(); edit_buffer.program = current_program; dx7_patch_unpack(patches, current_program, edit_buffer.voice); patch_edit_update_editors(); }
/* * hexter_instance_handle_edit_buffer */ char * hexter_instance_handle_edit_buffer(hexter_instance_t *instance, const char *value) { struct { int program; uint8_t buffer[DX7_VOICE_SIZE_UNPACKED]; } edit_buffer; pthread_mutex_lock(&instance->patches_mutex); if (!strcmp(value, "off")) { DEBUG_MESSAGE(DB_DATA, " hexter_instance_handle_edit_buffer: cancelled\n"); if (instance->current_program == instance->overlay_program) { dx7_patch_unpack(instance->patches, instance->current_program, instance->current_patch_buffer); } instance->overlay_program = -1; } else { DEBUG_MESSAGE(DB_DATA, " hexter_instance_handle_edit_buffer: received new overlay\n"); if (!decode_7in6(value, sizeof(edit_buffer), (uint8_t *)&edit_buffer)) { pthread_mutex_unlock(&instance->patches_mutex); return dssp_error_message("patch edit failed: corrupt data"); } instance->overlay_program = edit_buffer.program; memcpy(instance->overlay_patch_buffer, edit_buffer.buffer, DX7_VOICE_SIZE_UNPACKED); if (instance->current_program == instance->overlay_program) { /* applies to current patch also */ memcpy(instance->current_patch_buffer, instance->overlay_patch_buffer, DX7_VOICE_SIZE_UNPACKED); } } pthread_mutex_unlock(&instance->patches_mutex); return NULL; /* success */ }