bool DSP_table_set_dsp(DSP_table* table, int index, DSP* dsp) { assert(table != NULL); assert(index >= 0); assert(index < table->size); assert(dsp != NULL); if (!Etable_set(table->dsps, index, dsp)) return false; Device_set_existent((Device*)dsp, Bit_array_get(table->existents, index)); return true; }
void DSP_table_set_existent(DSP_table* table, int index, bool existent) { assert(table != NULL); assert(index >= 0); assert(index < table->size); Bit_array_set(table->existents, index, existent); DSP* dsp = Etable_get(table->dsps, index); if (dsp != NULL) Device_set_existent((Device*)dsp, existent); return; }
Module* new_Module(void) { Module* module = memory_alloc_item(Module); if (module == NULL) return NULL; if (!Device_init(&module->parent, false)) { memory_free(module); return NULL; } Device_set_existent(&module->parent, true); // Clear fields module->random_seed = 0; module->songs = NULL; module->album_is_existent = false; module->track_list = NULL; module->ch_defs = NULL; module->pats = NULL; module->au_map = NULL; module->au_controls = NULL; module->au_table = NULL; module->connections = NULL; module->is_dc_blocker_enabled = true; module->mix_vol_dB = COMP_DEFAULT_MIX_VOL; module->mix_vol = exp2(module->mix_vol_dB / 6); module->force_shift = 0; module->env = NULL; module->bind = NULL; for (int i = 0; i < KQT_SONGS_MAX; ++i) module->order_lists[i] = NULL; for (int i = 0; i < KQT_TUNING_TABLES_MAX; ++i) module->tuning_tables[i] = NULL; // Create fields module->songs = new_Song_table(); module->pats = new_Pat_table(KQT_PATTERNS_MAX); module->au_controls = new_Bit_array(KQT_CONTROLS_MAX); module->au_table = new_Au_table(KQT_AUDIO_UNITS_MAX); if (module->songs == NULL || module->pats == NULL || module->au_controls == NULL || module->au_table == NULL) { del_Module(module); return NULL; } module->env = new_Environment(); if (module->env == NULL) { del_Module(module); return NULL; } Streader* conn_sr = Streader_init(STREADER_AUTO, NULL, 0); module->connections = new_Connections_from_string(conn_sr, false, module->au_table, &module->parent); if (module->connections == NULL) { del_Module(module); return NULL; } return module; }