From 8e6d4696e8c3ce2e9ea4c93077ac15bcb0d933bf Mon Sep 17 00:00:00 2001 From: Zly Date: Fri, 16 Feb 2024 01:39:07 +0300 Subject: [PATCH] - Fixed poor sorting for drums. - Updated metapackage --- MIDI/MIDI_To_Items/Zly_MIDI_To_Items.lua | 92 ++---------------------- MIDI/meta_MIDI_To_Items.lua | 18 +++-- 2 files changed, 18 insertions(+), 92 deletions(-) diff --git a/MIDI/MIDI_To_Items/Zly_MIDI_To_Items.lua b/MIDI/MIDI_To_Items/Zly_MIDI_To_Items.lua index ab1efbe..6f68992 100644 --- a/MIDI/MIDI_To_Items/Zly_MIDI_To_Items.lua +++ b/MIDI/MIDI_To_Items/Zly_MIDI_To_Items.lua @@ -84,15 +84,6 @@ for name, func in pairs(reaper) do end --local FLT_MIN, FLT_MAX = ImGui.NumericLimits_Float() -local function get_script_path() - local filename = debug.getinfo(1, "S").source:match("^@?(.+)$") - return filename:match("^(.*)[\\/](.-)$") -end -local function add_to_package_path(subpath) - package.path = subpath .. "/?.lua;" .. package.path -end -add_to_package_path(get_script_path()) - --[[===================================================]]-- -- 61 drums @@ -506,58 +497,6 @@ function M2I:ProcessMIDI(midi_take) end -_G._print = print -_G.print = function(...) - local string = "" - for _, v in pairs({...}) do - string = string .. tostring(v) .. "\t" - end - string = string.."\n" - reaper.ShowConsoleMsg(string) -end - -local function printTable(t, show_details) - show_details = show_details or false - local printTable_cache = {} - - local function sub_printTable(_t, indent, indenty) - indenty = indenty or indent - - if printTable_cache[tostring(_t)] then - print(indenty .. "*" .. tostring(_t)) - return - end - - - printTable_cache[tostring(_t)] = true - if type(_t) ~= "table" then - print(indenty..(show_details and tostring(_t) or "")) - return - end - - - for key, val in pairs(_t) do - if type(val) == "table" then - print(indenty .. "[" .. key .. "] => " .. (show_details and tostring(_t) or "") .. "{") - sub_printTable(val, indent, indenty..indent) - print(indenty .. "}") - elseif type(val) == "string" then - print(indenty .. "[" .. key .. '] => "' .. val .. '"') - else - print(indenty .. "[" .. key .. "] => " .. tostring(val)) - end - end - end - - if type(t) == "table" then - print((show_details and tostring(t)..": " or "").."{") - sub_printTable(t, "\t") - print("}") - else - sub_printTable(t, "\t") - end -end - function M2I:Generate(midi_take) self.widget.generated_notes = 0 @@ -635,26 +574,23 @@ function M2I:Generate(midi_take) --[[============================================]]-- - -- TODO: Sorting drums holy fuck what the fuck - print("Sorting drums") -- Sort drums folder if self.channel_tracks[10] then local selected_tracks_count = reaper.CountSelectedTracks(0) - for i=1, selected_tracks_count do + -- Deselect every track, this gave me so much pain regarding sorting holy shit + for i = 1, selected_tracks_count do local sel_track = reaper.GetSelectedTrack(0, i-1) reaper.SetTrackSelected(sel_track, false) end - for i = 1, #self.channel_tracks[10].tracks do + local drum_group_index = reaper.GetMediaTrackInfo_Value(self.channel_tracks[10].group_track, "IP_TRACKNUMBER") + for i = #self.channel_tracks[10].tracks, 1, -1 do local drum_track_data = self.channel_tracks[10].tracks[i] if drum_track_data.track then - local drum_group_index = reaper.GetMediaTrackInfo_Value(self.channel_tracks[10].group_track, "IP_TRACKNUMBER") - print(drum_track_data.items[1].pitch-drums_start_pitch) reaper.SetTrackSelected(drum_track_data.track, true) reaper.ReorderSelectedTracks(drum_group_index, 0) reaper.SetTrackSelected(drum_track_data.track, false) - break end end end @@ -684,7 +620,6 @@ function M2I:Generate(midi_take) else for i = drums_end_pitch-drums_start_pitch+1, 1, -1 do local found_drum = channel_group_data.tracks[i] - print(i, found_drum) if found_drum.track ~= nil then found_last_track_in_group = found_drum.track break @@ -707,22 +642,6 @@ function M2I:Generate(midi_take) ::cntn_folders:: end - -- Reorder Channel Folders according to the sorted table - --for _, channel_group_track in pairs(self.channel_tracks) do - -- if channel_group_track.is_empty then - -- goto cntue_reorder - -- end - -- if not reaper.ValidatePtr(channel_group_track.group_track, "MediaTrack*") then - -- goto cntue_reorder - -- end - -- - -- reaper.SetTrackSelected(channel_group_track.group_track, true) - -- reaper.ReorderSelectedTracks(track_index-1, 0) - -- reaper.SetTrackSelected(channel_group_track.group_track, false) - -- - -- ::cntue_reorder:: - --end - --[[============================================]]-- --[[============================================]]-- @@ -753,10 +672,9 @@ function M2I:Generate(midi_take) end for _, notes_track in pairs(channel_group_track.tracks) do if not notes_track.track then - print("Item create: skip") goto skip_trackless end - print("Items:", notes_track.items) + for _, note in pairs(notes_track.items) do local start_pos local end_pos diff --git a/MIDI/meta_MIDI_To_Items.lua b/MIDI/meta_MIDI_To_Items.lua index ecf8023..55f4c0e 100644 --- a/MIDI/meta_MIDI_To_Items.lua +++ b/MIDI/meta_MIDI_To_Items.lua @@ -2,7 +2,7 @@ @metapackage @description MIDI -> Items @author Zly -@version 2.3 +@version 2.3.1 @provides [main] .\MIDI_To_Items\Zly_MIDI_To_Items.lua @about @@ -13,12 +13,20 @@ - Creates Channels in their own Folder Tracks for ease of work. - Able to choose a sample source file for each Channel before generating all the Media Items. - Drag and Drop features: - - Ability to drop sources into the Channels. - - Ability to rearrange the sources in the Channels. + * Ability to drop sources into the Channels. + * Ability to rearrange the sources in the Channels. - And some more. @screenshot Overview https://github.com/Zly-u/NAGASHIZAR_reapack/blob/master/MIDI/MIDI_To_Items/img_MIDI2Items.png - DnD Preview https://github.com/Zly-u/NAGASHIZAR_reapack/blob/master/MIDI/MIDI_To_Items/Preview_DnD_Feature.gif +@links + Author https://twitter.com/zly_u + DnD_Preview https://github.com/Zly-u/NAGASHIZAR_reapack/blob/master/MIDI/MIDI_To_Items/Preview_DnD_Feature.gif @changelog - - Added a feature for Channel 10 (drums channel): feature redistributes notes to their own tracks and renames tracks to their corresponding drum names that those pitches are mapped to by the MIDI standard. + - Fixed crashing when Channels are filtered out in the MIDI Editor. + - Fixed sometimes wacky folder generation. + - Fixed poor sorting for drums. + - Added Roland GS drums into the drums list. + - Added notes counter in the progress bars. + - Tweaked style a bit. + - Added hint about not entirely loaded MIDI. --]] \ No newline at end of file