From b520d2d2ff853bdacb99636eec7d9a70d7100bf7 Mon Sep 17 00:00:00 2001 From: kjetil_matheussen Date: Sun, 25 Feb 2024 15:17:20 +0100 Subject: [PATCH] Instrument: Change current instrument, even if locked, when user changes current track with keyboard. Fix for #1412 --- Qt/Qt_MainWindow.cpp | 2 +- Qt/Qt_instruments.cpp | 13 +++++++++++-- api/api_navigate.cpp | 16 ++++++++-------- api/protos.conf | 2 +- audio/Faust_plugins_template1.cpp | 2 +- common/OS_visual_input.h | 2 +- common/block_properties.cpp | 2 +- common/disk_load.c | 2 +- common/threading.cpp | 2 +- common/track_insert.cpp | 4 ++-- common/undo.cpp | 4 ++-- common/wblocks.c | 4 ++-- common/wtracks.cpp | 4 ++-- install.sh | 14 ++++++++------ macosx/cocoa_Keyboard.m | 2 +- 15 files changed, 43 insertions(+), 32 deletions(-) diff --git a/Qt/Qt_MainWindow.cpp b/Qt/Qt_MainWindow.cpp index 35e0e66f3a..e9a24e29a5 100644 --- a/Qt/Qt_MainWindow.cpp +++ b/Qt/Qt_MainWindow.cpp @@ -483,7 +483,7 @@ void handleDropEvent(QString filename, float x){ if (tracknum != -1) setInstrumentForTrack(instrument_id, tracknum, -1, -1); - GFX_update_instrument_patch_gui(PATCH_get_from_id(instrument_id)); + GFX_update_instrument_patch_gui(PATCH_get_from_id(instrument_id), true); } }UNDO_CLOSE(); diff --git a/Qt/Qt_instruments.cpp b/Qt/Qt_instruments.cpp index b852c76e08..769a26e796 100644 --- a/Qt/Qt_instruments.cpp +++ b/Qt/Qt_instruments.cpp @@ -847,6 +847,15 @@ static bool patch_used_in_current_editor_block(struct Patch *patch){ static void GFX_PP_Update_internal(struct Patch *patch, bool is_loading, bool open_even_if_locked){ //printf("GFX_PP_Update %s\n", patch==NULL?"(null)":patch->name); +#if 0 + if (open_even_if_locked){ + if (isPlaying()){ + printf("Gakk gakk!\n"); + printf("hmm\n"); + } + } +#endif + struct Patch *old_current = PATCH_get_current(); if (old_current != NULL && g_is_loading==false && open_even_if_locked==false && isCurrentInstrumentLocked()) @@ -965,12 +974,12 @@ void InstrumentWidget_delete(struct Patch *patch){ } } -void GFX_update_instrument_patch_gui(struct Patch *patch){ +void GFX_update_instrument_patch_gui(struct Patch *patch, bool even_if_locked){ //printf("Called GFX_update_instrument_patch_gui for patch \"%s\"\n",patch==NULL?"<>":patch->name); 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, false ); + patch->instrument->PP_Update( patch->instrument, patch, false, even_if_locked); } #if 0 if(wblock->wtrack->track->patch!=NULL && wblock->wtrack->track->patch->instrument->PP_Update!=NULL) diff --git a/api/api_navigate.cpp b/api/api_navigate.cpp index 9232d99bca..52b5c517be 100755 --- a/api/api_navigate.cpp +++ b/api/api_navigate.cpp @@ -319,7 +319,7 @@ void requestCursorMove(void){ int tracknum = atoi(trackstring); if (tracknum >= 0) - setCurrentTrack(tracknum, -2, window->l.num); + setCurrentTrack(tracknum, -2, window->l.num, true); } if (strlen(line) > 0) { @@ -375,10 +375,10 @@ void selectPrevPlaylistBlock(void){ } void selectTrack(int tracknum,int windownum){ - setCurrentTrack(tracknum, -2, windownum); + setCurrentTrack(tracknum, -2, windownum, false); } -void setCurrentTrack(int tracknum, int subtrack, int windownum){ +void setCurrentTrack(int tracknum, int subtrack, int windownum, bool switch_instrument_even_if_locked){ struct Tracker_Windows *window=getWindowFromNum(windownum); if(window==NULL) return; @@ -445,7 +445,7 @@ void setCurrentTrack(int tracknum, int subtrack, int windownum){ } GFX_adjust_skew_x(window, wblock, prevcurrtrack); - GFX_update_instrument_patch_gui(wtrack->track->patch); + GFX_update_instrument_patch_gui(wtrack->track->patch, switch_instrument_even_if_locked); GFX_show_curr_track_in_statusbar(window, wblock); window->must_redraw = true; @@ -637,7 +637,7 @@ void cursorRight(int windownum){ if (!canCursorMoveToTrack(tracknum, subtracknum, -1, windownum)) return; - setCurrentTrack(tracknum, subtracknum, windownum); + setCurrentTrack(tracknum, subtracknum, windownum, true); } void cursorNextTrack(int windownum){ @@ -687,7 +687,7 @@ void cursorNextTrack(int windownum){ subtracknum = num_subtracks -1; } - setCurrentTrack(tracknum, subtracknum, windownum); + setCurrentTrack(tracknum, subtracknum, windownum, true); } static int get_previous_legal_track(int tracknum, int windownum){ @@ -776,7 +776,7 @@ void cursorLeft(int windownum){ if (!canCursorMoveToTrack(tracknum, subtracknum, -1, windownum)) return; - setCurrentTrack(tracknum, subtracknum, windownum); + setCurrentTrack(tracknum, subtracknum, windownum, true); } void cursorPrevTrack(int windownum){ @@ -823,7 +823,7 @@ void cursorPrevTrack(int windownum){ subtracknum = num_subtracks -1; } - setCurrentTrack(tracknum, subtracknum, windownum); + setCurrentTrack(tracknum, subtracknum, windownum, true); } diff --git a/api/protos.conf b/api/protos.conf index a0c26a5758..12e948476f 100755 --- a/api/protos.conf +++ b/api/protos.conf @@ -97,7 +97,7 @@ selectTrack | int tracknum | int windownum ? -1 # Swing: -2 # Tempo automation: -1 # -setCurrentTrack | int tracknum | int subtrack ? -2 | int windownum ? -1 # subtrack==-2 means try to use same subtrack as for the current track. Also note that the notetext subtrack is always -1. The swing subtracks numbers are always 0,1,2 (even though swing is to the left of the note). +setCurrentTrack | int tracknum | int subtrack ? -2 | int windownum ? -1 | bool switch_instrument_even_if_locked ? false # subtrack==-2 means try to use same subtrack as for the current track. Also note that the notetext subtrack is always -1. The swing subtracks numbers are always 0,1,2 (even though swing is to the left of the note). int getCurrentTrack | int windownum ? -1 int getCurrentSubtrack | int windownum ? -1 int getNumSubtracks | int tracknum ? -1 | int blocknum ? -1 | int windownum ? -1 # returns the number of possible horizontal cursor positions. diff --git a/audio/Faust_plugins_template1.cpp b/audio/Faust_plugins_template1.cpp index b5901d007a..1a1baa50a1 100644 --- a/audio/Faust_plugins_template1.cpp +++ b/audio/Faust_plugins_template1.cpp @@ -28,7 +28,7 @@ static float linear2db(float val){ #endif #define MIN_LINEAR_VELOCITY 0.1 -static float g_min_linear_gain = 0.001995; // = powf(10, R_SCALE(MIN_LINEAR_VELOCITY, 0.0, 1.0 ,-40, 20) / 20.0f) / 10.0f; +static constexpr float g_min_linear_gain = 0.001995; // = powf(10, R_SCALE(MIN_LINEAR_VELOCITY, 0.0, 1.0 ,-40, 20) / 20.0f) / 10.0f; // input is between 0 and 1. // output is between 0 and 1. diff --git a/common/OS_visual_input.h b/common/OS_visual_input.h index 3216f574e9..fb17be3c9b 100755 --- a/common/OS_visual_input.h +++ b/common/OS_visual_input.h @@ -184,7 +184,7 @@ extern LANGSPEC void OS_GFX_NumUndosHaveChanged(int num_undos, bool redos_are_av extern LANGSPEC void OS_GFX_SetVolume(int value); extern LANGSPEC void OS_GFX_IncVolume(int how_much); -extern LANGSPEC void GFX_update_instrument_patch_gui(struct Patch *patch); +extern LANGSPEC void GFX_update_instrument_patch_gui(struct Patch *patch, bool even_if_locked); extern LANGSPEC void GFX_remove_patch_gui(struct Patch *patch); // Also deletes the audio object itself. (yes, it's messy) struct SoundPlugin; diff --git a/common/block_properties.cpp b/common/block_properties.cpp index 8ea60115c0..b04f875500 100755 --- a/common/block_properties.cpp +++ b/common/block_properties.cpp @@ -217,7 +217,7 @@ void Block_Set_num_tracks( wblock=(struct WBlocks *)ListFindElement1(&window->wblocks->l,block->l.num); if (wblock==window->wblock) - setCurrentTrack(num_tracks-1, -1, window->l.num); + setCurrentTrack(num_tracks-1, -1, window->l.num, false); } CutListAt1(&block->tracks,num_tracks); while(window!=NULL){ diff --git a/common/disk_load.c b/common/disk_load.c index 92bc7e281f..50ea2ba0c9 100755 --- a/common/disk_load.c +++ b/common/disk_load.c @@ -368,7 +368,7 @@ static bool Load_CurrPos_org(struct Tracker_Windows *window, filepath_t filename GFX_EditorWindowToFront(root->song->tracker_windows); struct WBlocks *wblock = root->song->tracker_windows->wblock; - GFX_update_instrument_patch_gui(wblock->wtrack->track->patch); + GFX_update_instrument_patch_gui(wblock->wtrack->track->patch, false); root->song->tracker_windows->must_redraw = true; diff --git a/common/threading.cpp b/common/threading.cpp index be9322013a..f862f72fbf 100644 --- a/common/threading.cpp +++ b/common/threading.cpp @@ -487,7 +487,7 @@ priority_t THREADING_get_priority(void){ } #if !defined(RELEASE) -enum R_thread_is_RT __thread g_t_current_thread_is_RT = R_UNINITIALIZED; +enum R_thread_is_RT __thread g_t_current_thread_is_RT = R_UNINITIALIZED; // Inefficient way store thread-local variables, but only used in DEBUG mode. #endif diff --git a/common/track_insert.cpp b/common/track_insert.cpp index 0e1199a711..88eb14329f 100755 --- a/common/track_insert.cpp +++ b/common/track_insert.cpp @@ -164,8 +164,8 @@ void InsertTracks_CurrPos( curr_track=wblock->block->num_tracks-1; } - setCurrentTrack(0, -1, window->l.num); - setCurrentTrack(curr_track, -1, window->l.num); + setCurrentTrack(0, -1, window->l.num, false); + setCurrentTrack(curr_track, -1, window->l.num, false); window->must_redraw = true; } diff --git a/common/undo.cpp b/common/undo.cpp index 70bc05fc38..b8ba23f97b 100755 --- a/common/undo.cpp +++ b/common/undo.cpp @@ -868,8 +868,8 @@ static void undo_internal(void){ } if(current_patch!=NULL){ - GFX_update_instrument_patch_gui(current_patch); - GFX_update_instrument_widget(current_patch); + GFX_update_instrument_patch_gui(current_patch, false); + GFX_update_instrument_widget(current_patch); } window->must_redraw = true; // We do this instead of calling GE_set_curr_realline. GE_set_curr_realline can also cause flickering if editor is redrawn at the same time. diff --git a/common/wblocks.c b/common/wblocks.c index e35b3f93a4..38d64cb8e5 100755 --- a/common/wblocks.c +++ b/common/wblocks.c @@ -506,7 +506,7 @@ void SelectWBlock(struct Tracker_Windows *window,struct WBlocks *wblock, bool fo ATOMIC_WRITE(window->curr_track, newcurrtrack); if (window->wblock==wblock) - setCurrentTrack(newcurrtrack, newcurrtracksub, window->l.num); + setCurrentTrack(newcurrtrack, newcurrtracksub, window->l.num, false); //if (SetCursorPosConcrete(window,wblock,newcurrtrack,newcurrtracksub)==false) // ATOMIC_WRITE(window->curr_track, 0); @@ -527,7 +527,7 @@ void SelectWBlock(struct Tracker_Windows *window,struct WBlocks *wblock, bool fo if(false==is_playing() && false==PlayerIsCurrentlyPlayingLoop()){ R_ASSERT_RETURN_IF_FALSE(wblock->wtrack->track != NULL); - GFX_update_instrument_patch_gui(wblock->wtrack->track->patch); + GFX_update_instrument_patch_gui(wblock->wtrack->track->patch, false); } //window->must_redraw = false; diff --git a/common/wtracks.cpp b/common/wtracks.cpp index 77d7391008..c98c9af1fe 100755 --- a/common/wtracks.cpp +++ b/common/wtracks.cpp @@ -601,7 +601,7 @@ void MinimizeBlock_CurrPos( wblock->skew_x = 0; if (wblock==window->wblock) - setCurrentTrack(0, -1, window->l.num); + setCurrentTrack(0, -1, window->l.num, false); wblock->temponodearea.width=2; wtrack=wblock->wtracks; @@ -708,7 +708,7 @@ void MinimizeBlock_CurrPos( window->must_redraw = true; if( ! is_playing()){ - GFX_update_instrument_patch_gui(wblock->wtrack->track->patch); + GFX_update_instrument_patch_gui(wblock->wtrack->track->patch, false); } } diff --git a/install.sh b/install.sh index 990f25f21d..97f9c4aa9a 100755 --- a/install.sh +++ b/install.sh @@ -112,10 +112,12 @@ then fi # libxcb -if [[ $RADIUM_INSTALL_LIBXCB != 0 ]] -then - cp -a packages/libxcb-1.13 "$TARGET/packages/" - cd "$TARGET/packages/libxcb-1.13/src" - rm -f ./*.o - cd "$THIS_DIR/bin" +if uname -s |grep Linux ; then + if [[ $RADIUM_INSTALL_LIBXCB != 0 ]] + then + cp -a packages/libxcb-1.13 "$TARGET/packages/" + cd "$TARGET/packages/libxcb-1.13/src" + rm -f ./*.o + cd "$THIS_DIR/bin" + fi fi diff --git a/macosx/cocoa_Keyboard.m b/macosx/cocoa_Keyboard.m index 4cbb8ec174..99fe8c9bda 100644 --- a/macosx/cocoa_Keyboard.m +++ b/macosx/cocoa_Keyboard.m @@ -167,7 +167,7 @@ int OS_SYSTEM_get_modifier(void *void_event){ //case 54: // Right Command (we don't use this one anymore, it's usually not available, and the "menu" key is a bit work to turn into a modifier key) //return EVENT_EXTRA_R; case 54: // Right Command (we don't use this one anymore, it's usually not available, and the "menu" key is a bit work to turn into a modifier key) - return EVENT_CTRL_R; // We always map left Cmd into left Ctrl since left Ctrl is not always available on mac. + return EVENT_CTRL_R; // We always map right Cmd into right Ctrl since right Ctrl is not always available on mac. case 55: // Left Command if (swapCtrlAndCmd()) return EVENT_CTRL_L;