Skip to content

Commit

Permalink
Change instrument when locked by clicking it in mixergui / lock instr…
Browse files Browse the repository at this point in the history
…uments by default
  • Loading branch information
yust1n committed Feb 19, 2024
1 parent 4bdd7d5 commit c0a5315
Show file tree
Hide file tree
Showing 11 changed files with 321 additions and 32 deletions.
17 changes: 10 additions & 7 deletions Qt/Qt_instruments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ void InstrumentWidget_create_audio_instrument_widget(struct Patch *patch, bool s
QTimer::singleShot(g_set_current_delay + 3,[patch_id]{
struct Patch *patch = PATCH_get_from_id(patch_id);
if(patch != NULL)
GFX_PP_Update(patch,false);
GFX_PP_Update( patch, false, false );
});

}
Expand Down Expand Up @@ -915,10 +915,15 @@ static void GFX_PP_Update_internal(struct Patch *patch, bool is_loading, bool op
called_from_pp_update = false;
}

void GFX_PP_Update(struct Patch *patch, bool is_loading){
GFX_PP_Update_internal(patch, is_loading, false);
void GFX_PP_Update( struct Patch *patch, bool is_loading, bool even_if_locked )
{
GFX_PP_Update_internal( patch, is_loading, even_if_locked );
}

//void GFX_PP_Update(struct Patch *patch, bool is_loading){
// GFX_PP_Update_internal(patch, is_loading, false);
//}

void GFX_PP_Update_even_if_locked(struct Patch *patch, bool is_loading){
GFX_PP_Update_internal(patch, is_loading, true);
}
Expand Down Expand Up @@ -956,7 +961,7 @@ void InstrumentWidget_delete(struct Patch *patch){
if (!g_is_starting_up && !g_is_loading){
struct Patch *patch = PATCH_get_current();
if (patch!=NULL)
GFX_PP_Update(patch, false);
GFX_PP_Update( patch, false, false );
}
}

Expand All @@ -965,9 +970,7 @@ void GFX_update_instrument_patch_gui(struct Patch *patch){
if(patch!=NULL && patch->patchdata!=NULL){
R_ASSERT_RETURN_IF_FALSE(patch->instrument != NULL);
if (patch->instrument->PP_Update!=NULL)
patch->instrument->PP_Update(patch->instrument,
patch,
false);
patch->instrument->PP_Update( patch->instrument, patch, false, false );
}
#if 0
if(wblock->wtrack->track->patch!=NULL && wblock->wtrack->track->patch->instrument->PP_Update!=NULL)
Expand Down
16 changes: 8 additions & 8 deletions api/api_instruments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ void setInstrumentForTrack(instrument_t instrument_id, int tracknum, int blocknu

wblock->block->is_dirty = true;

(*new_patch->instrument->PP_Update)(new_patch->instrument,new_patch,false);
( *new_patch->instrument->PP_Update )( new_patch->instrument, new_patch, false, false );
}

void replaceUseOfInstrument(instrument_t old_instrument_id, instrument_t new_instrument_id){
Expand Down Expand Up @@ -594,7 +594,7 @@ void setSendMidiInputToCurrentInstrument(bool doit){

instrument_t createMIDIInstrument(const_char *name) {
struct Patch *patch = PATCH_create_midi(name);
GFX_PP_Update(patch,false);
GFX_PP_Update( patch, false, false );
return patch->id;
}

Expand Down Expand Up @@ -1537,7 +1537,7 @@ void setInstrumentEffectChangesValueWhenPressingRandom(instrument_t instrument_i

PLUGIN_set_random_behavior(plugin, effect_num, doit);

(*patch->instrument->PP_Update)(patch->instrument,patch,false);
( *patch->instrument->PP_Update )( patch->instrument, patch, false, false );
}

bool getInstrumentEffectChangesValueWhenPressingRandom(instrument_t instrument_id, const_char* effect_name){
Expand Down Expand Up @@ -1863,7 +1863,7 @@ void setInstrumentData(instrument_t instrument_id, const_char *key, const_char *

patch->instrument->setPatchData(patch, key, value, true);

(*patch->instrument->PP_Update)(patch->instrument,patch,false);
( *patch->instrument->PP_Update )( patch->instrument, patch, false, false );
}

const_char *getInstrumentData(instrument_t instrument_id, const_char *key) {
Expand Down Expand Up @@ -3041,7 +3041,7 @@ void removeModulator(instrument_t instrument_id, const char *effect_name){
MODULATOR_remove_target(modulator_id, patch, effect_num);

if(patch==PATCH_get_current())
patch->instrument->PP_Update(patch->instrument, patch, false);
patch->instrument->PP_Update( patch->instrument, patch, false, false );
}

static const char *get_modulator_patch_description(const struct Patch *modulator_patch){
Expand Down Expand Up @@ -3560,7 +3560,7 @@ bool showInstrumentGui(instrument_t instrument_id, int64_t parentgui, bool show_
GFX_InstrumentWindowToFront();

struct Instruments *instrument = get_audio_instrument();
instrument->PP_Update(instrument,patch,false);
instrument->PP_Update( instrument, patch, false, false );

struct SoundPlugin *plugin = (struct SoundPlugin*)patch->patchdata;
if (plugin != NULL){
Expand Down Expand Up @@ -3808,7 +3808,7 @@ void setCurrentInstrument(instrument_t instrument_id, bool show_instrument_windo
GFX_InstrumentWindowToFront();

if (only_change_if_unlocked)
GFX_PP_Update(patch, false);
GFX_PP_Update( patch, false, false );
else
GFX_PP_Update_even_if_locked(patch, false);

Expand Down Expand Up @@ -3849,7 +3849,7 @@ void setCurrentInstrumentDown(bool set_current_instrument, bool set_current_inst
S7CALL2(void_bool_bool,"FROM_C-move-current-instrument-down", set_current_instrument, set_current_instrument_under_mouse);
}

static bool g_curr_instrument_is_locked = false;// = createIllegalInstrument();
static bool g_curr_instrument_is_locked = true;// = createIllegalInstrument();

void setCurrentInstrumentLocked(bool lockit){
if (lockit==g_curr_instrument_is_locked)
Expand Down
2 changes: 1 addition & 1 deletion api/api_sequencer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ static void setCurrSeqtrack2(int seqtracknum, bool called_from_set_curr_seqblock
if(change_curr_instrument){
struct Patch *patch = seqtrack->patch;
if(patch!=NULL)
patch->instrument->PP_Update(patch->instrument, patch, false);
patch->instrument->PP_Update( patch->instrument, patch, false, false );
}

if (seqtracknum != old) {
Expand Down
11 changes: 6 additions & 5 deletions audio/audio_instrument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1172,13 +1172,14 @@ static void AUDIO_RT_StopPlaying(struct Instruments *instrument){
}END_VECTOR_FOR_EACH;
}

static void AUDIO_PP_Update(struct Instruments *instrument,struct Patch *patch, bool is_loading){
if(patch->patchdata==NULL){
RError("plugin==NULL for %s\n",patch->name);
static void AUDIO_PP_Update( struct Instruments *instrument, struct Patch *patch, bool is_loading, bool even_if_locked )
{
if( patch->patchdata == NULL )
{
RError( "plugin==NULL for %s\n", patch->name );
return;
}

GFX_PP_Update(patch, is_loading);
GFX_PP_Update( patch, is_loading, even_if_locked );
}

static void *AUDIO_CopyInstrumentData(const struct Tracks *track){
Expand Down
3 changes: 2 additions & 1 deletion common/OS_visual_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ extern LANGSPEC struct Patch *GFX_OS_get_system_out(void);

extern LANGSPEC void GFX_update_all_instrument_widgets(void);

extern LANGSPEC void GFX_PP_Update(struct Patch *patch, bool is_loading);
//extern LANGSPEC void GFX_PP_Update(struct Patch *patch, bool is_loading);
extern LANGSPEC void GFX_PP_Update( struct Patch *patch, bool is_loading, bool even_if_locked );
extern LANGSPEC void GFX_PP_Update_even_if_locked(struct Patch *patch, bool is_loading);

extern LANGSPEC void *OS_GFX_get_native_main_window(void);
Expand Down
2 changes: 1 addition & 1 deletion common/disk_instrument.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,6 @@ void DLoadInstrument(struct Instruments *instrument){
void DLoadInstrumentGUI(struct Instruments *instrument){
// Pretty sure this is not necessary.
VECTOR_FOR_EACH(struct Patch *patch, &instrument->patches)
instrument->PP_Update(instrument, patch, true);
instrument->PP_Update( instrument, patch, true, false );
END_VECTOR_FOR_EACH;
}
3 changes: 2 additions & 1 deletion common/nsmtracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -2366,7 +2366,8 @@ struct Instruments{
void (*CloseInstrument)(struct Instruments *instrument);
void (*StopPlaying)(struct Instruments *instrument);
void (*RT_StopPlaying)(struct Instruments *instrument); // Called from the player thread. StopPlaying is called from the main thread, and only if it apparently wasn't playing before. This function is always called right after the player has set player_state to PLAYER_STATE_STOPPED
void (*PP_Update)(struct Instruments *instrument,struct Patch *patch, bool is_loading);
//void (*PP_Update)(struct Instruments *instrument,struct Patch *patch, bool is_loading);
void (*PP_Update)(struct Instruments *instrument,struct Patch *patch, bool is_loading, bool even_if_locked );
void *(*CopyInstrumentData)(const struct Tracks *track); //Necesarry for undo.

void (*PlaySongHook)(struct Instruments *instrument, int64_t abstime);
Expand Down
Loading

0 comments on commit c0a5315

Please sign in to comment.