diff --git a/Qt/Qt_PresetBrowser.cpp b/Qt/Qt_PresetBrowser.cpp index becce01cf..8ff0eabdf 100644 --- a/Qt/Qt_PresetBrowser.cpp +++ b/Qt/Qt_PresetBrowser.cpp @@ -309,7 +309,7 @@ void PresetBrowser::usePreset(const QModelIndex & index){ QFileInfo fileInfo(ff); if (fileInfo.exists() && fileInfo.isFile()){ QString fileName = fileInfo.baseName(); - instrument_t ins = createAudioInstrumentFromPreset(make_filepath(filePath), "", 0, 0, true); // create instrument from preset + instrument_t ins = createAudioInstrumentFromPreset(make_filepath(filePath), "", 0, 0, true, true); // create instrument from preset setInstrumentForTrack(ins, currentTrack(currentBlock(0), 0), currentBlock(0),0); // add instrument to current track connectAudioInstrumentToMainPipe(ins); @@ -352,7 +352,7 @@ void PresetBrowser::playPreset(const QModelIndex & index){ QFileInfo fileInfo(ff); if (fileInfo.exists() && fileInfo.isFile()){ //qDebug() << "create preset demo instrument"; - presetDemoInstrument = createAudioInstrumentFromPreset(make_filepath(filePath), "PresetPlayer", 1, 1, false); + presetDemoInstrument = createAudioInstrumentFromPreset(make_filepath(filePath), "PresetPlayer", 1, 1, false, false); //qDebug() << "connect preset instrument "; connectAudioInstrumentToMainPipe(presetDemoInstrument); diff --git a/api/api_instruments.cpp b/api/api_instruments.cpp index ac8fc370d..be5fef092 100644 --- a/api/api_instruments.cpp +++ b/api/api_instruments.cpp @@ -581,13 +581,13 @@ instrument_t createMIDIInstrument(const_char *name) { } // There was a good reason for the 'name' parameter. Think it had something to do with replace instrument, and whether to use old name or autogenerate new one. -instrument_t createAudioInstrument(const_char *type_name, const_char *plugin_name, const_char *name, float x, float y, bool set_as_current) { +instrument_t createAudioInstrument(const_char *type_name, const_char *plugin_name, const_char *name, float x, float y, bool set_as_current, bool is_visible) { printf("createAudioInstrument called\n"); if (name!=NULL && strlen(name)==0) name = NULL; - struct Patch *patch = PATCH_create_audio(type_name, plugin_name, name, NULL, set_as_current, x, y); + struct Patch *patch = PATCH_create_audio(type_name, plugin_name, name, NULL, set_as_current, is_visible, x, y); if (patch==NULL) return createIllegalInstrument(); @@ -601,8 +601,12 @@ instrument_t createAudioInstrument(const_char *type_name, const_char *plugin_nam return patch->id; } -instrument_t createAudioInstrumentFromPreset(filepath_t filename, const_char *name, float x, float y, bool set_as_current) { - return PRESET_load(filename, name, false, set_as_current, x, y); +instrument_t createAudioInstrumentFromPreset(filepath_t filename, const_char *name, float x, float y, bool set_as_current, bool is_visible) { + if (set_as_current){ + R_ASSERT_NON_RELEASE(is_visible); + } + + return PRESET_load(filename, name, false, set_as_current, is_visible, x, y); } const char *getAudioInstrumentDescription(const_char* container_name, const_char* type_name, const_char* plugin_name){ @@ -642,7 +646,7 @@ static bool get_type_name_from_description(const char *instrument_description, c return false; } -instrument_t createAudioInstrumentFromDescription(const char *instrument_description, const_char *name, float x, float y, bool set_as_current){ +instrument_t createAudioInstrumentFromDescription(const char *instrument_description, const_char *name, float x, float y, bool set_as_current, bool is_visible){ radium::ScopedUndo scoped_undo; if (strlen(instrument_description)==0) @@ -662,14 +666,14 @@ instrument_t createAudioInstrumentFromDescription(const char *instrument_descrip if (strlen(container_name) > 0) PR_ensure_container_is_populated(container_name, type_name); // Might fail, but we let createAudioInstrument print error message. - return createAudioInstrument(type_name, plugin_name, name, x, y, set_as_current); + return createAudioInstrument(type_name, plugin_name, name, x, y, set_as_current, is_visible); } else if (instrument_description[0]=='2'){ const wchar_t *filename = STRING_fromBase64(STRING_create(&instrument_description[1])); //printf("filename: %s\n",filename); - return PRESET_load(make_filepath(filename), name, true, set_as_current, x, y); + return PRESET_load(make_filepath(filename), name, true, set_as_current, is_visible, x, y); } else if (instrument_description[0]=='3'){ @@ -690,7 +694,7 @@ instrument_t cloneAudioInstrument(instrument_t instrument_id, float x, float y, hash_t *state = PATCH_get_state(old_patch); - struct Patch *new_patch = PATCH_create_audio(NULL, NULL, talloc_format("Clone of %s",old_patch->name), state, set_as_current, x, y); + struct Patch *new_patch = PATCH_create_audio(NULL, NULL, talloc_format("Clone of %s",old_patch->name), state, set_as_current, true, x, y); if (new_patch==NULL) return createIllegalInstrument(); @@ -2870,7 +2874,7 @@ void setIncludeSystemVolumeInMixerConfig(bool doit){ instrument_t createModulator(void){ //struct Patch *curr_patch = PATCH_get_current(); - instrument_t instrument_id = createAudioInstrument(MODULATOR_NAME, MODULATOR_NAME, "", 0, 0, false); + instrument_t instrument_id = createAudioInstrument(MODULATOR_NAME, MODULATOR_NAME, "", 0, 0, false, true); if (!isLegalInstrument(instrument_id)){ //printf("\n\n NOT FOUND\n\n"); //getchar(); diff --git a/api/protos.conf b/api/protos.conf index 95390c878..fb7204286 100755 --- a/api/protos.conf +++ b/api/protos.conf @@ -1258,10 +1258,10 @@ int64_t getAudioInstrumentDeletionGeneration # audio -instrument_t createAudioInstrument | const_char* type_name | const_char* plugin_name | const_char* name ? "" | float x ? 0 | float y ? 0 | bool set_as_current ? true # returns instrument_id -instrument_t createAudioInstrumentFromPreset | filepath_t filename | const_char* name ? "" | float x ? 0 | float y ? 0 | bool set_as_current ? true +instrument_t createAudioInstrument | const_char* type_name | const_char* plugin_name | const_char* name ? "" | float x ? 0 | float y ? 0 | bool set_as_current ? true | bool is_visible ? true # returns instrument_id +instrument_t createAudioInstrumentFromPreset | filepath_t filename | const_char* name ? "" | float x ? 0 | float y ? 0 | bool set_as_current ? true | bool is_visible ? true const_char* getAudioInstrumentDescription | const_char* container_name | const_char* type_name | const_char* plugin_name # container_name is usually "" (for vst containers). All arguments must be in base64 format. -instrument_t createAudioInstrumentFromDescription | const_char* instrument_description | const_char* name ? "" | float x ? 0 | float y ? 0 | bool set_as_current ? true # returns instrument_id +instrument_t createAudioInstrumentFromDescription | const_char* instrument_description | const_char* name ? "" | float x ? 0 | float y ? 0 | bool set_as_current ? true | bool is_visible ? true # returns instrument_id instrument_t cloneAudioInstrument | instrument_t instrument_id | float x ? 0 | float y ? 0 | bool set_as_current ? true dyn_t createNewInstrumentConf | float x ? 0 | float y ? 0 | bool connect_to_main_pipe ? false | bool do_autoconnect ? false | bool include_load_preset ? true | bool must_have_inputs ? false | bool must_have_outputs ? false | int64_t parentgui ? -2 void createInstrumentDescriptionPopupMenu | dyn_t instrument_conf diff --git a/audio/Presets.cpp b/audio/Presets.cpp index 0dbcfdd13..cb8a4e96f 100644 --- a/audio/Presets.cpp +++ b/audio/Presets.cpp @@ -209,7 +209,7 @@ static hash_t *get_preset_state_from_filename(QString filename){ return state; } -static instrument_t PRESET_load_multipreset(hash_t *state, const char *name, filepath_t filename, bool inc_usage_number, bool set_as_current, float x, float y){ +static instrument_t PRESET_load_multipreset(hash_t *state, const char *name, filepath_t filename, bool inc_usage_number, bool set_as_current, bool is_visible, float x, float y){ QHash patch_id_mapper; @@ -221,7 +221,7 @@ static instrument_t PRESET_load_multipreset(hash_t *state, const char *name, fil for(int i = 0 ; i < num_presets ; i++) { hash_t *patch_state = HASH_get_hash_at(patches_state, "patch", i); - struct Patch *patch = PATCH_create_audio(NULL, NULL, name, patch_state, set_as_current ? i==0 : false, 0, 0); + struct Patch *patch = PATCH_create_audio(NULL, NULL, name, patch_state, set_as_current ? i==0 : false, is_visible, 0, 0); //printf("i: %d. Org id: %d. New id: %d. name1: -%s-, name2: -%s-, name3: %s\n",i, (int)HASH_get_instrument(patch_state, "id").id, (int)patch->id.id, name,patch->name,HASH_get_chars(patch_state,"name")); //getchar(); VECTOR_push_back(&patches, patch); // NULL values must be pushed as well. @@ -262,8 +262,13 @@ static instrument_t PRESET_load_multipreset(hash_t *state, const char *name, fil return first_patch->id; } -static instrument_t PRESET_load_singlepreset(hash_t *state, const_char *name, filepath_t filename, bool inc_usage_number, bool set_as_current, float x, float y){ - struct Patch *patch = PATCH_create_audio(NULL, NULL, name, state, set_as_current, x, y); +static instrument_t PRESET_load_singlepreset(hash_t *state, const_char *name, filepath_t filename, bool inc_usage_number, bool set_as_current, bool is_visible, float x, float y){ + + if (set_as_current){ + R_ASSERT_NON_RELEASE(is_visible); + } + + struct Patch *patch = PATCH_create_audio(NULL, NULL, name, state, set_as_current, is_visible, x, y); if (patch==NULL) return createIllegalInstrument(); @@ -285,20 +290,30 @@ static instrument_t PRESET_load_singlepreset(hash_t *state, const_char *name, fi return patch->id; } -static instrument_t insert_preset_into_program(hash_t *state, const_char *name, filepath_t filename, bool inc_usage_number, bool set_as_current, float x, float y){ +static instrument_t insert_preset_into_program(hash_t *state, const_char *name, filepath_t filename, bool inc_usage_number, bool set_as_current, bool is_visible, float x, float y){ + + if (set_as_current){ + R_ASSERT_NON_RELEASE(is_visible); + } + bool is_multipreset = HASH_has_key(state, "multipreset_presets") && HASH_get_bool(state, "multipreset_presets"); if (is_multipreset) - return PRESET_load_multipreset(state, name, filename, inc_usage_number, set_as_current, x, y); + return PRESET_load_multipreset(state, name, filename, inc_usage_number, set_as_current, is_visible, x, y); else - return PRESET_load_singlepreset(state, name, filename, inc_usage_number, set_as_current, x, y); + return PRESET_load_singlepreset(state, name, filename, inc_usage_number, set_as_current, is_visible, x, y); } // Note that this is the general preset loading function, and not the one that is directly called when pressing the "Load" button. (there we also have to delete the old instrument and reconnect connections) // // A less confusing name could perhaps be PRESET_add_instrument // -instrument_t PRESET_load(filepath_t wfilename, const_char *patchname, bool inc_usage_number, bool set_as_current, float x, float y) { +instrument_t PRESET_load(filepath_t wfilename, const_char *patchname, bool inc_usage_number, bool set_as_current, bool is_visible, float x, float y) { + + if (set_as_current){ + R_ASSERT_NON_RELEASE(is_visible); + } + if (patchname!=NULL && strlen(patchname)==0) patchname = NULL; @@ -314,12 +329,12 @@ instrument_t PRESET_load(filepath_t wfilename, const_char *patchname, bool inc_u PRESET_set_last_used_filename(filename); - return insert_preset_into_program(state, patchname, make_filepath(filename), inc_usage_number, set_as_current, x, y); + return insert_preset_into_program(state, patchname, make_filepath(filename), inc_usage_number, set_as_current, is_visible, x, y); } instrument_t PRESET_paste(float x, float y){ if (g_preset_clipboard != NULL) - return insert_preset_into_program(g_preset_clipboard, NULL, HASH_get_filepath(g_preset_clipboard, "filename"), true, true, x, y); + return insert_preset_into_program(g_preset_clipboard, NULL, HASH_get_filepath(g_preset_clipboard, "filename"), true, true, true, x, y); else return make_instrument(-1); } diff --git a/audio/Presets_proc.h b/audio/Presets_proc.h index d472a9373..cdbfae037 100644 --- a/audio/Presets_proc.h +++ b/audio/Presets_proc.h @@ -7,7 +7,7 @@ extern LANGSPEC dynvec_t PRESET_get_all_mrec_files_in_path(filepath_t wpath); extern LANGSPEC void PRESET_request_load_instrument_description(int64_t parentgui, func_t *callback); -extern LANGSPEC instrument_t PRESET_load(filepath_t filename, const char *name, bool inc_usage_number, bool set_as_current, float x, float y); +extern LANGSPEC instrument_t PRESET_load(filepath_t filename, const char *name, bool inc_usage_number, bool set_as_current, bool is_visible, float x, float y); extern LANGSPEC void PRESET_set_last_used_filename(filepath_t wfilename); extern LANGSPEC filepath_t PRESET_get_current_preset_dir(void); diff --git a/bin/scheme/init.scm b/bin/scheme/init.scm index 95b5a77a3..cd9c4307c 100644 --- a/bin/scheme/init.scm +++ b/bin/scheme/init.scm @@ -976,7 +976,8 @@ FROM_C-show-mixer-popup-menu-effect (define (FROM-C-assert-that-function-can-be-called-from-C funcname) (define sym (string->symbol funcname)) - (when (and (not (memq sym *functions-and-symbols-used-by-C*)) + (when (and #f + (not (memq sym *functions-and-symbols-used-by-C*)) (not (memq sym *functions-and-symbols-used-by-C-that-are-not-available-at-program-startup*))) (define message (string-append "The function \"" funcname "\" has not been added to the list of functions that can be called from C")) (display message)(newline) diff --git a/common/nsmtracker.h b/common/nsmtracker.h index f1bbcdecd..6ce24cef9 100755 --- a/common/nsmtracker.h +++ b/common/nsmtracker.h @@ -2288,6 +2288,8 @@ struct Patch{ DEFINE_ATOMIC(bool, is_recording); DEFINE_ATOMIC(bool, always_receive_midi_input); + + bool is_visible; }; #define PATCH_FAILED 0 #define PATCH_SUCCESS 1 diff --git a/common/patch.cpp b/common/patch.cpp index 347915d38..a8899a3a2 100755 --- a/common/patch.cpp +++ b/common/patch.cpp @@ -429,6 +429,8 @@ struct Patch *PATCH_alloc(void){ patch->comment = "Comment"; patch->wide_mixer_strip = true; + patch->is_visible = true; + PATCH_init_voices(patch); return patch; @@ -702,13 +704,19 @@ void PATCH_init_audio_when_loading_song(struct Patch *patch, hash_t *state) { } // Either type_name and plugin_name is NULL, or state==NULL -static struct Patch *create_audio_patch(const char *type_name, const char *plugin_name, const char *name, hash_t *state, float x, float y, bool is_main_pipe, bool set_as_current) { +static struct Patch *create_audio_patch(const char *type_name, const char *plugin_name, const char *name, hash_t *state, float x, float y, bool is_main_pipe, bool set_as_current, bool is_visible) { printf("PATCH_create_audio called\n"); - + + if (set_as_current){ + R_ASSERT_NON_RELEASE(is_visible); + } + struct Patch *patch = create_new_patch(name, is_main_pipe); patch->instrument=get_audio_instrument(); + patch->is_visible = is_visible; + if (PATCH_make_active_audio(patch, type_name, plugin_name, state, set_as_current, x, y)==false) return NULL; @@ -725,11 +733,15 @@ static struct Patch *create_audio_patch(const char *type_name, const char *plugi struct Patch *PATCH_create_main_pipe(void) { R_ASSERT(g_is_loading); - return create_audio_patch(talloc_strdup("Pipe"), talloc_strdup("Pipe"), talloc_strdup("Main Pipe"), NULL, 0, 0, true, false); + return create_audio_patch(talloc_strdup("Pipe"), talloc_strdup("Pipe"), talloc_strdup("Main Pipe"), NULL, 0, 0, true, false, true); } -struct Patch *PATCH_create_audio(const char *type_name, const char *plugin_name, const char *name, hash_t *state, bool set_as_current, float x, float y) { - return create_audio_patch(type_name, plugin_name, name, state, x, y, false, set_as_current); +struct Patch *PATCH_create_audio(const char *type_name, const char *plugin_name, const char *name, hash_t *state, bool set_as_current, bool is_visible, float x, float y) { + if (set_as_current){ + R_ASSERT_NON_RELEASE(is_visible); + } + + return create_audio_patch(type_name, plugin_name, name, state, x, y, false, set_as_current, is_visible); } struct Patch *PATCH_create_midi(const char *name){ diff --git a/common/patch_proc.h b/common/patch_proc.h index 39106cc9d..a10292273 100755 --- a/common/patch_proc.h +++ b/common/patch_proc.h @@ -47,7 +47,7 @@ extern LANGSPEC struct Patch *PATCH_alloc(void); extern LANGSPEC void PATCH_set_name2(struct Patch *patch, const char *name, bool update_send_receive_plugin_names); extern LANGSPEC void PATCH_set_name(struct Patch *patch, const char *name); // same as calling PATCH_set_name(patch, name, true) extern LANGSPEC struct Patch *PATCH_create_main_pipe(void); -extern LANGSPEC struct Patch *PATCH_create_audio(const char *type_name, const char *plugin_name, const char *name, hash_t *state, bool set_as_current, float x, float y); +extern LANGSPEC struct Patch *PATCH_create_audio(const char *type_name, const char *plugin_name, const char *name, hash_t *state, bool set_as_current, bool is_visible, float x, float y); extern LANGSPEC struct Patch *PATCH_create_midi(const char *name); extern LANGSPEC void PATCH_make_inactive(struct Patch *patch); extern LANGSPEC void PATCH_force_make_inactive(struct Patch *patch); diff --git a/mixergui/QM_chip.cpp b/mixergui/QM_chip.cpp index 954bc5177..31787d97e 100644 --- a/mixergui/QM_chip.cpp +++ b/mixergui/QM_chip.cpp @@ -1878,6 +1878,12 @@ Chip::Chip(QGraphicsScene *scene, SoundProducer *sound_producer, float x, float MW_set_selected_chip(this); // To unselect previously selected chip. + struct Patch *patch = CHIP_get_patch(this); + if (!patch) + R_ASSERT(false); + else if (!patch->is_visible) + setVisible(false); + printf("New Chip. Inputs: %d, Ouptuts: %d\n",_num_inputs,_num_outputs); }