Old 11-03-2019, 09:32 AM   #1881
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,580
Default

@timbralzoom

This is not exactly what you requested, but can still be useful when working on hundreds or thousands of MIDI items:

Transpose selected MIDI items (all takes) to target octave
  • It transposes selected MIDI takes by octaves, so that the lowest note lands on that certain (user defined) octave
  • You can edit the last line to set the target octave



Code:
function get_notes_and_range(take)
  local MIDI_notes = {}
  local note_min, note_max = 127, 0
  local retval, note_cnt = reaper.MIDI_CountEvts(take)
  for n=1, note_cnt do
    local ret, selected, muted, startppqpos, endppqpos, chan, pitch, vel = reaper.MIDI_GetNote(take, n-1)
    MIDI_notes[#MIDI_notes+1] = {selected, muted, startppqpos, endppqpos, chan, pitch, vel}
    if pitch < note_min then note_min = pitch end
    if pitch > note_max then note_max = pitch end
  end
  return MIDI_notes, note_min, note_max
end


function transpose_to_octave(octave) -- octave 4 is middle C
  octave = octave + 1
  local item_cnt = reaper.CountSelectedMediaItems(0)
  for i=1, item_cnt do
    local item = reaper.GetSelectedMediaItem(0, i-1)
    if item then
      local take_count = reaper.GetMediaItemNumTakes(item)
      for t=1, take_count do
        local take = reaper.GetMediaItemTake(item, t-1)
        if take and reaper.TakeIsMIDI(take) then
          local note_tbl, note_min, note_max = get_notes_and_range(take)
          local note_min_transposed = note_min % 12 + octave*12
          local pitch_diff = note_min_transposed - note_min     
          for noteidx=1, #note_tbl do
            local n = note_tbl[noteidx]
            --boolean reaper.MIDI_SetNote(MediaItem_Take take, integer noteidx, optional boolean selectedIn, optional boolean mutedIn, optional number startppqposIn, optional number endppqposIn, optional number chanIn, optional number pitchIn, optional number velIn, optional boolean noSortIn)
            reaper.MIDI_SetNote(take, noteidx-1, n[1], n[2], n[3], n[4], n[5], n[6]+pitch_diff, n[7], false)
          end
        end
      end
    end
  end
  reaper.Undo_OnStateChange("Transpose")
end

transpose_to_octave(4) -- 4 is middle C (5 = middle C + 1 octave etc.)
spk77 is offline   Reply With Quote
Old 11-03-2019, 01:35 PM   #1882
timbralzoom
Human being with feelings
 
timbralzoom's Avatar
 
Join Date: Apr 2010
Location: Turkey/Istanbul
Posts: 1,694
Default

Quote:
Originally Posted by MusoBob View Post
That should be easy enough to make but I think there may already be something that will do that. Try in Reapack.
Thank you!
i checked everything i found "Transpose" related .. didn't work.



Quote:
Originally Posted by spk77 View Post
@timbralzoom

This is not exactly what you requested, but can still be useful when working on hundreds or thousands of MIDI items:

Transpose selected MIDI items (all takes) to target octave
  • It transposes selected MIDI takes by octaves, so that the lowest note lands on that certain (user defined) octave
  • You can edit the last line to set the target octave



Code:
function get_notes_and_range(take)
  local MIDI_notes = {}
  local note_min, note_max = 127, 0
  local retval, note_cnt = reaper.MIDI_CountEvts(take)
  for n=1, note_cnt do
    local ret, selected, muted, startppqpos, endppqpos, chan, pitch, vel = reaper.MIDI_GetNote(take, n-1)
    MIDI_notes[#MIDI_notes+1] = {selected, muted, startppqpos, endppqpos, chan, pitch, vel}
    if pitch < note_min then note_min = pitch end
    if pitch > note_max then note_max = pitch end
  end
  return MIDI_notes, note_min, note_max
end


function transpose_to_octave(octave) -- octave 4 is middle C
  octave = octave + 1
  local item_cnt = reaper.CountSelectedMediaItems(0)
  for i=1, item_cnt do
    local item = reaper.GetSelectedMediaItem(0, i-1)
    if item then
      local take_count = reaper.GetMediaItemNumTakes(item)
      for t=1, take_count do
        local take = reaper.GetMediaItemTake(item, t-1)
        if take and reaper.TakeIsMIDI(take) then
          local note_tbl, note_min, note_max = get_notes_and_range(take)
          local note_min_transposed = note_min % 12 + octave*12
          local pitch_diff = note_min_transposed - note_min     
          for noteidx=1, #note_tbl do
            local n = note_tbl[noteidx]
            --boolean reaper.MIDI_SetNote(MediaItem_Take take, integer noteidx, optional boolean selectedIn, optional boolean mutedIn, optional number startppqposIn, optional number endppqposIn, optional number chanIn, optional number pitchIn, optional number velIn, optional boolean noSortIn)
            reaper.MIDI_SetNote(take, noteidx-1, n[1], n[2], n[3], n[4], n[5], n[6]+pitch_diff, n[7], false)
          end
        end
      end
    end
  end
  reaper.Undo_OnStateChange("Transpose")
end

transpose_to_octave(4) -- 4 is middle C (5 = middle C + 1 octave etc.)

This is exactly does what i was trying to describe!
not in the Midi Editor,
but even better in the Arrangement with the Takes!

Thank you so much!
now i need an email address of yours to send a humble Amazon eGift card .. please PM me.
(paypal still doesn't work here/Turkey)



timbralzoom is offline   Reply With Quote
Old 11-04-2019, 12:59 PM   #1883
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,580
Default

Quote:
Originally Posted by timbralzoom View Post
Thank you so much!
now i need an email address of yours to send a humble Amazon eGift card .. please PM me.
(paypal still doesn't work here/Turkey)
Thanks! PM sent.

My pm box has been full for ages...just removed all old messages.
I was inactive for a year and a half, so apologies to those who didn't get any reply!
spk77 is offline   Reply With Quote
Old 11-04-2019, 02:20 PM   #1884
timbralzoom
Human being with feelings
 
timbralzoom's Avatar
 
Join Date: Apr 2010
Location: Turkey/Istanbul
Posts: 1,694
Default

Quote:
Originally Posted by spk77 View Post
Thanks! PM sent.

My pm box has been full for ages...just removed all old messages.
I was inactive for a year and a half, so apologies to those who didn't get any reply!
i am not using a broom avatar for nothing

joking apart, script is a huge time saver to me,

Thanks a lot !
timbralzoom is offline   Reply With Quote
Old 11-04-2019, 02:29 PM   #1885
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,580
Default

Quote:
Originally Posted by timbralzoom View Post
i am not using a broom avatar for nothing

joking apart, script is a huge time saver to me,

Thanks a lot !
Glad it worked and thanks for the gift card!
spk77 is offline   Reply With Quote
Old 11-05-2019, 08:16 AM   #1886
Vagelis
Human being with feelings
 
Join Date: Oct 2017
Location: Larisa, Greece
Posts: 400
Default

Hi! I'd like to ask if someone could make a script that duplicates selected items or AI at mouse position but to snap the start of the duplicated item at the end of the previous item and the opposite to snap the end of the duplicated item at the start of the next item?
Here's a gif that shows how it is done in FL:
https://imgur.com/NaKJC0Y

The advantage of FL way compared to Reaper(Draw copy), is that you can change the length of each duplication from their edge.
Is there a script that could split the looped items, to the area shown in the next pic, so we could do the same in Reaper?

Vagelis is offline   Reply With Quote
Old 11-10-2019, 12:58 AM   #1887
LarrySeyer
Human being with feelings
 
LarrySeyer's Avatar
 
Join Date: Sep 2006
Location: Austin, Tx
Posts: 22
Default Smart tool assigned to keystroke?

I've created several buttons and I can turn them into 'Smart Tools' via a right click on the mouse.

But what I'm trying to figure out now to do is have a keystroke trigger the smart tool.

So far, I haven't been able to find anything in the documentation that describes how to do this?

To explain further... I have a button that I can turn into a smart tool.

I want to assign a keystroke that will trigger that button as a smart tool (not just trigger the button)

Any help would be greatly appreciated.

Thank you!
LarrySeyer is offline   Reply With Quote
Old 11-10-2019, 05:37 AM   #1888
timbralzoom
Human being with feelings
 
timbralzoom's Avatar
 
Join Date: Apr 2010
Location: Turkey/Istanbul
Posts: 1,694
Default

is this possible:

Item: Extend last note length to the end of the item?
for filling the end gap with the last note's length

i hope image explains a bit better

timbralzoom is offline   Reply With Quote
Old 11-10-2019, 07:40 AM   #1889
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,503
Default

Quote:
Originally Posted by LarrySeyer View Post
I've created several buttons and I can turn them into 'Smart Tools' via a right click on the mouse.

But what I'm trying to figure out now to do is have a keystroke trigger the smart tool.
You can do that using custom actions.
Create a new custom action, give it a name, e.g., Arm MyScript.
Add action "Action: Arm next action".
Add your script: MyScript.
Click OK.
Set a shortcut key to the new custom action.
Edgemeal is online now   Reply With Quote
Old 11-10-2019, 09:19 AM   #1890
LarrySeyer
Human being with feelings
 
LarrySeyer's Avatar
 
Join Date: Sep 2006
Location: Austin, Tx
Posts: 22
Default

Quote:
Originally Posted by Edgemeal View Post
You can do that using custom actions.
Create a new custom action, give it a name, e.g., Arm MyScript.
Add action "Action: Arm next action".
Add your script: MyScript.
Click OK.
Set a shortcut key to the new custom action.
Thank you for attempting to help but I don’t think that will do what I’m trying to do.

I need to Trigger a particular button into smart tool mode. Not arm a “next” button since there are several buttons and several keystrokes that need this function - all of them different. So a “next” feature will not work.

Any other suggestions?

L

Last edited by LarrySeyer; 11-10-2019 at 09:44 AM.
LarrySeyer is offline   Reply With Quote
Old 11-10-2019, 11:10 AM   #1891
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,580
Default

Quote:
Originally Posted by LarrySeyer View Post
Thank you for attempting to help but I don’t think that will do what I’m trying to do.

I need to Trigger a particular button into smart tool mode. Not arm a “next” button since there are several buttons and several keystrokes that need this function - all of them different. So a “next” feature will not work.

Any other suggestions?

L
This seems to work, but you have to create a copy of this script (with different "action_id_str") for each of your buttons:

Code:
local action_id_str = "_RSbfc5312090ba047544b89a315793ce5754c95bdd" -- Copy/paste this Command ID from the action list
local sectionname = "" -- empty string for main section actions

local action = reaper.NamedCommandLookup(action_id_str)
local retval, sec = reaper.GetArmedCommand()
if retval == action and sec == sectionname then
  action = 0 -- disarm
end

reaper.ArmCommand(action, sectionname)
reaper.defer(function() end) -- no undo point
spk77 is offline   Reply With Quote
Old 11-10-2019, 11:19 AM   #1892
LarrySeyer
Human being with feelings
 
LarrySeyer's Avatar
 
Join Date: Sep 2006
Location: Austin, Tx
Posts: 22
Default

Quote:
Originally Posted by spk77 View Post
This seems to work, but you have to create a copy of this script (with different "action_id_str") for each of your buttons:

Code:
local action_id_str = "_RSbfc5312090ba047544b89a315793ce5754c95bdd" -- Copy/paste this Command ID from the action list
local sectionname = "" -- empty string for main section actions

local action = reaper.NamedCommandLookup(action_id_str)
local retval, sec = reaper.GetArmedCommand()
if retval == action and sec == sectionname then
  action = 0 -- disarm
end

reaper.ArmCommand(action, sectionname)
reaper.defer(function() end) -- no undo point
That works perfectly! Thank you!

BTW, what theme are you using? It looks awesome!

L
LarrySeyer is offline   Reply With Quote
Old 11-10-2019, 11:23 AM   #1893
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,580
Default

@LarrySeyer

Glad it works!
The theme is "Default 5 Dark Extended": https://forum.cockos.com/showthread.php?t=172024
spk77 is offline   Reply With Quote
Old 11-13-2019, 11:10 AM   #1894
free2worship
Human being with feelings
 
Join Date: Jul 2018
Posts: 3
Default SWS Extensions Update for MacOS 10.15.1 (Catalina)

Does anyone know the ETA for an update that will work with Mac OS Catalina? I did the Mac upgrade and SWS-Extensions are non functioning as is also the latest version of Reaper. I had to downgrade back to MacOS 10.14.6.

Thanks for any feedback. I didn't find any info at sws-extension.org.
free2worship is offline   Reply With Quote
Old 11-13-2019, 11:16 AM   #1895
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 3,873
Default

Quote:
Originally Posted by free2worship View Post
Does anyone know the ETA for an update that will work with Mac OS Catalina? I did the Mac upgrade and SWS-Extensions are non functioning as is also the latest version of Reaper. I had to downgrade back to MacOS 10.14.6.

Thanks for any feedback. I didn't find any info at sws-extension.org.
Have a look at this thread (post #8 and #10): https://forum.cockos.com/showthread.php?t=226059
__________________
ReaLauncher
solger is offline   Reply With Quote
Old 11-15-2019, 10:06 AM   #1896
Triode
Human being with feelings
 
Triode's Avatar
 
Join Date: Jan 2012
Posts: 550
Default

Hi Folks

Is it possible to script an action that starts playback from the left hand visible edge of the currently focussed midi editor window?

Many thanks for any tips
__________________
Brush and Beater Drums Online: www.outoftheboxdrums.co.uk
Triode is offline   Reply With Quote
Old 11-21-2019, 03:33 PM   #1897
b0se
Human being with feelings
 
Join Date: Jan 2019
Posts: 51
Default

Hey there!

As my Render To File is bugging out, I'm needing to loop through my hardware chain via track sends/receives.

Could someone help me with a simple script that:

1) Sets the current/selected track Audio Hardware Output to: Output 3 / Output 4 and disables Parent Send
2) Creates a new track using '$track-print' as the name, volume at 0dB, Armed, Monitoring On and Input:Stereo (Input 3 / Input 4).

Happy to donate via PayPal as this would be a big time saver!
b0se is offline   Reply With Quote
Old 11-22-2019, 06:03 AM   #1898
b0se
Human being with feelings
 
Join Date: Jan 2019
Posts: 51
Default

Quote:
Originally Posted by b0se View Post
Hey there!

As my Render To File is bugging out, I'm needing to loop through my hardware chain via track sends/receives.

Could someone help me with a simple script that:

1) Sets the current/selected track Audio Hardware Output to: Output 3 / Output 4 and disables Parent Send
2) Creates a new track using '$track-print' as the name, volume at 0dB, Armed, Monitoring On and Input:Stereo (Input 3 / Input 4).

Happy to donate via PayPal as this would be a big time saver!
Never mind, dipped the proverbial toes into scripting and done it. Works a treat.

Code:
-- get selected track ID, add FX, disable parent send
trackCurrent = reaper.GetSelectedTrack(0,0)
val,trackName = reaper.GetTrackName(trackCurrent)
reaper.TrackFX_AddByName(trackCurrent, "VST:NotJustAnotherDither", 0, 1 )
reaper.SetMediaTrackInfo_Value(trackCurrent, "B_MAINSEND", 0) 

-- set 3/4 HW output
_, chunk = reaper.GetTrackStateChunk(trackCurrent, '')
chunk = chunk:gsub('MAINSEND','HWOUT 2 0 1 0 0 0 0 -1:U -1\nMAINSEND')
reaper.SetTrackStateChunk(trackCurrent, chunk, false)

-- unarm all tracks
total_tracks = reaper.CountTracks(0)

for i = 0, total_tracks-1 do
 track = reaper.GetTrack(0,i)
 if reaper.GetMediaTrackInfo_Value(track, "I_RECARM") == 1 then
   reaper.SetMediaTrackInfo_Value(track, "I_RECARM", 0)
 end
end

-- Cload template and rename
reaper.Main_openProject("/Volumes/SSD/Reaper/KEEP/SBOUT.RTrackTemplate")
trackCurrent = reaper.GetSelectedTrack(0,0)
reaper.GetSetMediaTrackInfo_String(trackCurrent, "P_NAME", trackName..'-SB', true)
Found the HWOUT string via this script mentioned here:

https://forum.cockos.com/showpost.ph...&postcount=659

Also unarms all other tracks as to only record via HW loop, and adds Airwindows NJAD (dither) before hitting the hardware.
b0se is offline   Reply With Quote
Old 12-03-2019, 06:04 AM   #1899
Bertrand H
Human being with feelings
 
Join Date: Feb 2018
Location: Belgium
Posts: 5
Default

Quote:
Originally Posted by spk77 View Post
Thanks, it worked!

(I still had to use parameter modulation (for testing): If I move a slider on the ReaControlMIDI, it becomes "last focused FX" and the script doesn't work )



Here's the first attempt:

Lua - Adjust wet parameter of floating and focused track FX.
Code:
function msg(m)
  return reaper.ShowConsoleMsg(tostring(m) .. "\n")
end

function adjust_wet_param()
  local is_new_value, filename, sectionID, cmdID,mode, resolution, val = reaper.get_action_context()
  local retval, track_number, item_number, fx_number = reaper.GetFocusedFX()
  if retval == 1 and item_number == -1 then -- this script works only on track FXs
    local track = reaper.CSurf_TrackFromID(track_number, false)
    local is_open = reaper.TrackFX_GetOpen(track, fx_number)
    if not is_open then
      return
    end
    for i=1, reaper.TrackFX_GetNumParams(track, fx_number) do
      local ret, param_name = reaper.TrackFX_GetParamName(track, fx_number, i-1, "")
      --msg(param_name)
      if param_name == "Wet" then
        --msg(val/127)
        reaper.TrackFX_SetParam(track, fx_number, i-1, val/127)
        break
      end
    end
  end
end

reaper.defer(adjust_wet_param)
Thats very nice thank you!!! Now I have a button in absolute mode and it toggle between 0 and 100% of a selected FX without glitches. Is it a way I could use this script in order to toggle 0%-100% simultaneously on evrey fxs of the selected tracks? Regards, B
Bertrand H is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 11:22 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.