Old 05-07-2017, 01:33 AM   #1161
hamish
Human being with feelings
 
hamish's Avatar
 
Join Date: Sep 2007
Location: The Reflection Free Zone
Posts: 3,001
Default

Quote:
Originally Posted by reddiesel41264 View Post
Do you know the name's of the actions you have those mouse modifiers triggering? Thanks.
Sorry so late getting back, I've been away. As you know there is no 'Notation' context for mouse modifiers or actions, supposedly all actions are the same as Piano Roll.

In Piano roll context the actions are called 'horizontal zoom' and 'vertical zoom'.

In notation editor the 'vertical zoom' is effectively staff line spacing. (And 'horizontal zoom' effectively zooms both horizontally and vertically in notation, but only horizontally in piano roll)

Looking at your images of REAPER and MuseScore, the REAPER staves look like they are zoomed out too much vertically.

It would be nice to also have stave spacing control though.

Last edited by hamish; 05-07-2017 at 01:38 AM.
hamish is offline   Reply With Quote
Old 05-07-2017, 02:08 AM   #1162
Oberheim
Human being with feelings
 
Join Date: Mar 2015
Posts: 26
Default

There are two zooms.
Ctrl + mouse wheel = zoom in / out || or zoom horizontal
Alt + mouse wheel = zoom in / out || or zoom vertical
horzintal or vertical zoom is when you start zoom vertical (alt + m.w.) i think.

And if you are working on larger pieces, make special tracks where you'll controll more instruments with one. For example:
Track Woodwinds
Channel 1 - Flute 1
Ch2 - Fl2
Ch3 - Ob1
... etc.

Last edited by Oberheim; 05-07-2017 at 02:15 AM.
Oberheim is offline   Reply With Quote
Old 05-07-2017, 04:29 AM   #1163
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 425
Default

Thanks guys
__________________
David Healey
Purveyor of fine sample libraries (and Kontakt scripting tutorials) - http://xtant-audio.com/
reddiesel41264 is offline   Reply With Quote
Old 05-08-2017, 04:06 PM   #1164
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 425
Default

Is it possible that when you click on a staff it becomes the active staff for entering notes? Currently I have to click the staff name or select the track. For staff markings and copying and pasting though it seems to work just by clicking the staff already....
__________________
David Healey
Purveyor of fine sample libraries (and Kontakt scripting tutorials) - http://xtant-audio.com/
reddiesel41264 is offline   Reply With Quote
Old 05-09-2017, 08:50 AM   #1165
Oberheim
Human being with feelings
 
Join Date: Mar 2015
Posts: 26
Default

Yes. I dont know how is your set up, but this is mine:
Show TrackList on notation view > Right click on it > and check "All media items are editable on notation view"
Option When using one editor per project > all is active except two options - Selection is linked to visibility and editability.

With this option you can draw notes on every displayed track without selecting track.
If you want paste, simply click above desired track (light yellow rectangle appear and cursor change to like for edit text), track position will change and then paste copied material.
Oberheim is offline   Reply With Quote
Old 05-09-2017, 09:27 AM   #1166
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 425
Default

Quote:
Originally Posted by Oberheim View Post
Yes. I dont know how is your set up, but this is mine:
Show TrackList on notation view > Right click on it > and check "All media items are editable on notation view"
Option When using one editor per project > all is active except two options - Selection is linked to visibility and editability.

With this option you can draw notes on every displayed track without selecting track.
If you want paste, simply click above desired track (light yellow rectangle appear and cursor change to like for edit text), track position will change and then paste copied material.
Thanks for the info, I've go the same settings but it doesn't seem to be working how I expect. Could you make a video or licecap?
__________________
David Healey
Purveyor of fine sample libraries (and Kontakt scripting tutorials) - http://xtant-audio.com/
reddiesel41264 is offline   Reply With Quote
Old 05-10-2017, 08:57 AM   #1167
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 425
Default

I made a quick video to show what's happening on my system. You can see that no matter which staff I click on it doesn't change the one that is editable, except when I copy and paste - also copy and paste isn't available in the context menus so I have to use the shortcut keys.

https://youtu.be/KRMHLkab5O4
__________________
David Healey
Purveyor of fine sample libraries (and Kontakt scripting tutorials) - http://xtant-audio.com/
reddiesel41264 is offline   Reply With Quote
Old 05-11-2017, 09:35 AM   #1168
Oberheim
Human being with feelings
 
Join Date: Mar 2015
Posts: 26
Default

I apologize for late answer.

I was think, you want enter notes with mouse, not with step input. Then answer is, I think no, it is not possible, or I don't know if it is possible, only as you do it on video. I apologize for mislead.
Oberheim is offline   Reply With Quote
Old 05-11-2017, 09:37 AM   #1169
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 425
Default

Quote:
Originally Posted by Oberheim View Post
I apologize for late answer.

I was think, you want enter notes with mouse, not with step input. Then answer is, I think no, it is not possible, or I don't know if it is possible, only as you do it on video. I apologize for mislead.
No worries, I think you're right that it's not possible at the moment unfortunately, hopefully one day
__________________
David Healey
Purveyor of fine sample libraries (and Kontakt scripting tutorials) - http://xtant-audio.com/
reddiesel41264 is offline   Reply With Quote
Old 05-14-2017, 03:23 AM   #1170
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 425
Default XML and PDF Export Issue

The PDF exported from a project I'm working on has come out strange with most of the pages being half just black. Also the XML exported from the same project won't open in Musescore.
Attached Images
File Type: png Capture.PNG (37.4 KB, 59 views)
Attached Files
File Type: rpp template.rpp (417.8 KB, 19 views)
__________________
David Healey
Purveyor of fine sample libraries (and Kontakt scripting tutorials) - http://xtant-audio.com/
reddiesel41264 is offline   Reply With Quote
Old 05-16-2017, 04:49 PM   #1171
MajorLeo
Human being with feelings
 
Join Date: Dec 2016
Location: Montreal
Posts: 9
Default

Small question, when entering note with the mouse and the shift or alt mouse modifier on Left click, Insert note, all note the I enter stay selected. This does not happen in the piano roll. Does someone know if this is normal?

(I asked this question in the general discussion thread, I hope this is not considered spamming)
MajorLeo is offline   Reply With Quote
Old 05-29-2017, 07:09 AM   #1172
krahosk
Human being with feelings
 
krahosk's Avatar
 
Join Date: Jul 2009
Location: Canada
Posts: 1,515
Default

Where is the "Custom Notation" folder that holds all the symbols?
I'd like to create new ones (chord diagrams for the guitar)
and remove those I don't need.
Is that possible?
krahosk is offline   Reply With Quote
Old 05-29-2017, 08:46 AM   #1173
schwa
Administrator
 
schwa's Avatar
 
Join Date: Mar 2007
Location: NY
Posts: 9,285
Default

Quote:
Originally Posted by MajorLeo View Post
Small question, when entering note with the mouse and the shift or alt mouse modifier on Left click, Insert note, all note the I enter stay selected. This does not happen in the piano roll. Does someone know if this is normal?
From here it looks like the behavior is the same in both the piano roll and notation view. Notes stay selected when inserting new notes with shift+alt+click, but not when drawing new notes via mouse drag. A slight unintentional mouse drag when inserting via mouse click will deselect other notes.
schwa is offline   Reply With Quote
Old 05-29-2017, 08:50 AM   #1174
schwa
Administrator
 
schwa's Avatar
 
Join Date: Mar 2007
Location: NY
Posts: 9,285
Default

Quote:
Originally Posted by krahosk View Post
Where is the "Custom Notation" folder that holds all the symbols?
There is no folder. The symbols are all contained in the Reavura font that is installed in the REAPER/Plugins application directory. Reavura is a version of the open source Bravura font, renamed solely for version control, to avoid colliding with a possibly different version of Bravura that might already be installed on the user's computer.

It might be possible to create a new version of the Reavura font with custom glyphs, but REAPER might not load it properly for checksum reasons (not sure).
schwa is offline   Reply With Quote
Old 05-29-2017, 10:45 AM   #1175
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 1,176
Default

juliansader is online now   Reply With Quote
Old 05-31-2017, 08:30 AM   #1176
lowellben
Human being with feelings
 
lowellben's Avatar
 
Join Date: Aug 2010
Location: Not Lowell
Posts: 2,642
Default

I am trying to find a simple way to display velocity under each note in notation view (for exporting the score itself to print) but I can't figure it out.

Is there a way to attach the velocity number to each note in a MIDI notation Reaper editor? Scripting? Native? Thanks guys.
__________________
47.8% of statistics are made up.
lowellben is offline   Reply With Quote
Old 06-01-2017, 02:47 AM   #1177
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 1,176
Default

Quote:
Originally Posted by lowellben View Post
I am trying to find a simple way to display velocity under each note in notation view (for exporting the score itself to print) but I can't figure it out.

Is there a way to attach the velocity number to each note in a MIDI notation Reaper editor? Scripting? Native? Thanks guys.
"under" each note, like lyrics?

It should be straightforward to write a script to convert each note's velocity into a lyric.
juliansader is online now   Reply With Quote
Old 06-01-2017, 02:51 AM   #1178
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 1,176
Default

In notation view's track list, when hovering over the "Editable" button, the tooltip reads: "All items are editable in notation view".

I suggest that it would be more helpful if the tooltip reads: "All *visible* items are editable in notation view".
juliansader is online now   Reply With Quote
Old 06-01-2017, 03:06 AM   #1179
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 1,176
Default

There is a unintuitive discrepancy between the piano roll and the notation view, when it comes to copy/pasting notes (as also discussed in the thread Make Selecting Easier In Midi Editor):

- In the piano roll, copy/paste will paste notes into the active track, as expected. (The active track is, after all, defined as the one that is the "target for inserting events", according to the track list's tooltip).

- In the notation view, copied notes are not pasted into the active track, but instead into the *last-clicked* track/staff.

Is this behavior intentional?
juliansader is online now   Reply With Quote
Old 06-01-2017, 03:36 AM   #1180
schwa
Administrator
 
schwa's Avatar
 
Join Date: Mar 2007
Location: NY
Posts: 9,285
Default

Quote:
Originally Posted by juliansader View Post
gif with notes not drawn accurately with respect to ledger lines
I think this should be improved in the current prerelease (5.50pre11).
schwa is offline   Reply With Quote
Old 06-01-2017, 03:40 AM   #1181
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 425
Default

Quote:
Originally Posted by juliansader View Post
There is a unintuitive discrepancy between the piano roll and the notation view, when it comes to copy/pasting notes (as also discussed in the thread Make Selecting Easier In Midi Editor):

- In the piano roll, copy/paste will paste notes into the active track, as expected. (The active track is, after all, defined as the one that is the "target for inserting events", according to the track list's tooltip).

- In the notation view, copied notes are not pasted into the active track, but instead into the *last-clicked* track/staff.

Is this behavior intentional?
On a similar line it would be good to have the option to be able to make a track active by clicking the staff in the notation editor.
__________________
David Healey
Purveyor of fine sample libraries (and Kontakt scripting tutorials) - http://xtant-audio.com/
reddiesel41264 is offline   Reply With Quote
Old 06-01-2017, 03:58 AM   #1182
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 1,176
Default

The action "View: Move edit cursor to mouse cursor" appears not to work correctly in notation view: the edit cursor moves, but to wrong positions that are sometimes several measures away from the mouse cursor.
juliansader is online now   Reply With Quote
Old 06-01-2017, 05:39 AM   #1183
lowellben
Human being with feelings
 
lowellben's Avatar
 
Join Date: Aug 2010
Location: Not Lowell
Posts: 2,642
Default

Quote:
Originally Posted by juliansader View Post
"under" each note, like lyrics?

It should be straightforward to write a script to convert each note's velocity into a lyric.
Correct. I was hoping to get a value displayed below each note like a "lyric".

I like to print out my Reaper scores and at a quick glance look at the loudness and softness of the musical passages. It helps with notating it for the final copy I find. Thanks.
__________________
47.8% of statistics are made up.
lowellben is offline   Reply With Quote
Old 06-01-2017, 06:08 AM   #1184
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 425
Default

Quote:
Originally Posted by lowellben View Post
Correct. I was hoping to get a value displayed below each note like a "lyric".

I like to print out my Reaper scores and at a quick glance look at the loudness and softness of the musical passages. It helps with notating it for the final copy I find. Thanks.
Why not get it to display a dynamic marking based on the velocity or CC data? Wouldn't that be more useful
__________________
David Healey
Purveyor of fine sample libraries (and Kontakt scripting tutorials) - http://xtant-audio.com/
reddiesel41264 is offline   Reply With Quote
Old 06-01-2017, 11:01 AM   #1185
lowellben
Human being with feelings
 
lowellben's Avatar
 
Join Date: Aug 2010
Location: Not Lowell
Posts: 2,642
Default

Quote:
Originally Posted by reddiesel41264 View Post
Why not get it to display a dynamic marking based on the velocity or CC data? Wouldn't that be more useful
Of course I already requested that a while ago, that was my first idea.

I would love to be able to auto-assign-attach a dynamic marking depending on the velocity of a note, but no script has been created so far So, I didn't push the issue.

So, thus, I settled on at least just showing me a velocity number and I'd just do the heavy lifting

Do you think a script could be made relatively easy to auto-add dynamic markings?

Something like:
Action:
Add dynamic marking to selected MIDI notes in MIDI editor
(- based on predefined defaults, obviously, we need to decide what velocities get what mp, mf, fff, etc - that is easy though, set and forget)
(yes, every note in selection gets a marking - sure, messy and cluttered but absolutely a lifesaver when you print it out and need to quickly eyeball parts for orchestra performance in Finale or Sibelius lol)

Thanks all.
__________________
47.8% of statistics are made up.
lowellben is offline   Reply With Quote
Old 06-01-2017, 11:44 AM   #1186
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 425
Default

Quote:
Originally Posted by lowellben View Post
Do you think a script could be made relatively easy to auto-add dynamic markings?

Something like:
Action:
Add dynamic marking to selected MIDI notes in MIDI editor
(- based on predefined defaults, obviously, we need to decide what velocities get what mp, mf, fff, etc - that is easy though, set and forget)
(yes, every note in selection gets a marking - sure, messy and cluttered but absolutely a lifesaver when you print it out and need to quickly eyeball parts for orchestra performance in Finale or Sibelius lol)

Thanks all.
Yeah, I actually happen to be working on such a script at the mo, its a little different to what you describe but it will do the same thing. It works on both velocity or a CC
__________________
David Healey
Purveyor of fine sample libraries (and Kontakt scripting tutorials) - http://xtant-audio.com/
reddiesel41264 is offline   Reply With Quote
Old 06-01-2017, 12:39 PM   #1187
lowellben
Human being with feelings
 
lowellben's Avatar
 
Join Date: Aug 2010
Location: Not Lowell
Posts: 2,642
Default

Quote:
Originally Posted by reddiesel41264 View Post
Yeah, I actually happen to be working on such a script at the mo, its a little different to what you describe but it will do the same thing. It works on both velocity or a CC
Oh, wow. That would be incredible actually. Please keep me in mind when you launch it Do you have a Paypal donation or something setup for your Reaper work? Just wondering.
__________________
47.8% of statistics are made up.
lowellben is offline   Reply With Quote
Old 06-01-2017, 02:29 PM   #1188
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 1,176
Default

Quote:
Originally Posted by lowellben View Post
Of course I already requested that a while ago, that was my first idea.

I would love to be able to auto-assign-attach a dynamic marking depending on the velocity of a note, but no script has been created so far So, I didn't push the issue.
Here is a (beta version of) a script that can add either lyrics or dynamics to selected notes in all editable takes:

Code:
--[[
ReaScript name: js_Convert velocities of selected notes to dynamics or lyrics.lua
Version: 0.92
Author: juliansader
Website: http://forum.cockos.com/showthread.php?p=1851179#post1851179
Donation: https://www.paypal.me/juliansader
REAPER version: 5.30 or later
]]
 
--[[
 Changelog:
  * v0.90 (2017-06-01)
    + Initial beta release
  * v0.91 (2017-06-02)
    + Somewhat improved speed
  * v0.92 (2017-06-02)
    + Option to skip redundant dynamics
]]

-------------------------------------------------------------------
-- USER AREA
-- Settings that the user can customize

insertDynamicsOrLyrics = "Dynamics" -- Either "Dynamics" or "Lyrics"

-- In the case of dynamics, these two tables give the (lower) cut-off values and text for each dynamic
-- (The tables can be customized to any length, as long as both have the same number of entries.)
tableCutoffValues = {0, 25, 50, 75, 100} 
tableDynamics     = {"pp", "p", "mp", "f", "ff"}

-- Should redundant, repeated dynamics be skipped? If "false", each and every note will have a dynamic indication.
skipRedundantDynamics = true

-- End of USER AREA
-------------------------------------------------------------------


if not reaper.APIExists("MIDI_GetAllEvts") then
    reaper.ShowMessageBox("This script requires REAPER v5.30 or higher.", "ERROR", 0)
    return(false) 
end

local s_unpack = string.unpack
local s_pack   = string.pack


-- REAPER does not provide API functions to enumerate the editable takes in a MIDI editor.
-- This scripts uses a 'trick' to find these editable takes: apply a native Action that affect all editable takes,
--    and then check all takes' MIDI stings to find those that wer changed by the Action.

-- Find all takes' original, pre-Action MIDI data
local tableMIDIdata = {}

for i=0, reaper.CountMediaItems(0)-1 do 

    local curItem = reaper.GetMediaItem(0, i)
    if reaper.ValidatePtr2(0, curItem, "MediaItem*") then 
     
        for t=0, reaper.CountTakes(curItem)-1 do 
        
            local curTake = reaper.GetTake(curItem, t)    
            if reaper.ValidatePtr2(0, curTake, "MediaItem_Take*") and reaper.TakeIsMIDI(curTake) then 
            
                -- Should we use MIDI string or MIDI hashes to compare pre- and post-Action?  
                -- Strangely, MIDI hashes may change even if the MIDI data didn't really change.
                -- So rather use the MIDI strings.
                gotDataOK, tableMIDIdata[curTake] = reaper.MIDI_GetAllEvts(curTake, "")
                --gotDataOK, tableMIDIdata[curTake] = reaper.MIDI_GetHash(curTake, true, "")
                                            
            end -- if reaper.ValidatePtr2(0, curItem, "MediaItem_Take*") and reaper.TakeIsMIDI(curTake)
        end -- for t=0, numTakes-1
    end -- if reaper.ValidatePtr2(0, curItem, "MediaItem*")
end -- for i=0, numItems-1


---------------------------------------------------------------------------------------------------------------
-- Now apply a native Action that is guaranteed to change some MIDI in all *editable* takes with selected notes
-- The script will replace the MIDI data of all takes that are changed by the native Action, so no need to 
--    undo the Action.
-- To prevent the Action from creating an undo point, start an Undo Block before calling Action.
editor = reaper.MIDIEditor_GetActive()
reaper.Undo_BeginBlock2(0)
reaper.MIDIEditor_OnCommand(editor, 40909) -- Edit: Invert voicing downwards for selected notes (all editable)


-----------------------------------------------------------------------------------------------------------
-- Find all takes in which the MIDI data changed, by comparing their new MIDI data with the pre-Action data
for take, oldMIDIdata in pairs(tableMIDIdata) do
    local gotDataOK, newMIDIdata = reaper.MIDI_GetAllEvts(take, "")
    --local gotDataOK, newMIDIdata = reaper.MIDI_GetHash(take, true, "")
    if newMIDIdata == oldMIDIdata then
        tableMIDIdata[take] = nil
    end
end


-----------------------------------------------------------------------------------------
-- Now iterate through all editable takes, inserting lyrics or dynamics at selected notes
for take, MIDIstring in pairs(tableMIDIdata) do
    local tableMIDIevents = {} -- Each take's MIDI events will be stored one-by-one in this table, until concatenated again
    local t = 0 -- Index inside tableMIDIevents
    local MIDIlen = MIDIstring:len()
    local stringPos = 1
    local offset, flags, msg, velocityMsg -- velocityMsg will depend on whether lyrics or dynamics should be inserted
    local previousDynamic
    while stringPos < MIDIlen do
        offset, flags, msg, stringPos = s_unpack("i4Bs4", MIDIstring, stringPos)
        if msg ~= "" then
            local velocity = msg:byte(3)
            -- If note-on, insert new lyric or dynamic marker
            if msg:byte(1)>>4 == 9 and velocity ~= 0 and flags&1==1 then
            
                if insertDynamicsOrLyrics == "Dynamics" then
                    -- Code for inserting dynamics
                    for i = #tableCutoffValues, 1, -1 do
                        if velocity >= tableCutoffValues[i] then
                            if skipRedundantDynamics and i == previousDynamic then
                                velocityMsg = ""
                            else
                                velocityMsg = string.char(0xFF, 0x0F) .. "TRAC dynamic " .. tableDynamics[i]
                            end
                            previousDynamic = i
                            break
                        end
                    end
                else
                    -- Code for inserting a lyric
                    velocityMsg = string.char(0xFF, 0x05) .. tostring(msg:byte(3))
                end
                t = t + 1
                tableMIDIevents[t] = s_pack("i4Bs4", offset, 0, velocityMsg)
                t = t + 1
                tableMIDIevents[t] = s_pack("i4Bs4", 0, flags, msg)
            else
                t = t + 1
                tableMIDIevents[t] = s_pack("i4Bs4", offset, flags, msg)
            end
        end
    end -- while stringPos < MIDIlen
    reaper.MIDI_SetAllEvts(take, table.concat(tableMIDIevents))
end


-------------------------------------------------------------------------
-- Creat Undo point
-- flag=4 should limit the information that is included in the undo point 
--    to changes that were made to *items*, so the creation of the undo point is hopefully much faster. 
if insertDynamicsOrLyrics == "Dynamics" then 
    undoText = "Convert note velocities to dynamics"
else
    undoText = "Convert note velocities to lyrics"
end
reaper.Undo_EndBlock2(0, undoText, 4)
This code uses a newfangled "trick" to find all editable takes the MIDI editor, since REAPER's API does not provide this information natively. There might still be a bug in my trick, so this is just a beta version of the script.

In the script's USER AREA, you can select between lyrics or dynamics, and customize the dynamics.

EDIT: update 0.92: Option to skip redundant dynamics indications




-

Last edited by juliansader; 06-05-2017 at 10:47 AM.
juliansader is online now   Reply With Quote
Old 06-01-2017, 04:53 PM   #1189
lowellben
Human being with feelings
 
lowellben's Avatar
 
Join Date: Aug 2010
Location: Not Lowell
Posts: 2,642
Default

This looks incredible. Testing now!!! THANK YOU

Quote:
Originally Posted by juliansader View Post
Here is a (beta version of) a script that can add either lyrics or dynamics to selected notes in all editable takes:

Code:
--[[
ReaScript name: js_Convert velocties of selected notes to dynamics or lyrics.lua
Version: 0.91
Author: juliansader
Website: http://forum.cockos.com/showthread.php?p=1851179#post1851179
Donation: https://www.paypal.me/juliansader
REAPER version: 5.30 or later
]]
 
--[[
 Changelog:
  * v0.90 (2017-06-01)
    + Initial beta release
  * v.091 (2017-06-02)
    + Somewhat improved speed
]]

-------------------------------------------------------------------
-- USER AREA
-- Settings that the user can customize

insertDynamicsOrLyrics = "Dynamics" -- Either "Dynamics" or "Lyrics"

-- In the case of dynamics, these two tables give the cut-off values and text for each dynamic
tableCutoffValues = {0, 25, 50, 75, 100} 
tableDynamics     = {"pp", "p", "mp", "f", "ff"}

-- End of USER AREA
-------------------------------------------------------------------


if not reaper.APIExists("MIDI_GetAllEvts") then
    reaper.ShowMessageBox("This script requires REAPER v5.30 or higher.", "ERROR", 0)
    return(false) 
end

local s_unpack = string.unpack
local s_pack   = string.pack


-- REAPER does not provide API functions to enumerate the editable takes in a MIDI editor.
-- This scripts uses a 'trick' to find these editable takes: apply a native Action that affect all editable takes,
--    and then check all takes' MIDI stings to find those that wer changed by the Action.

-- Find all takes' original, pre-Action MIDI data
local tableMIDIdata = {}

for i=0, reaper.CountMediaItems(0)-1 do 

    local curItem = reaper.GetMediaItem(0, i)
    if reaper.ValidatePtr2(0, curItem, "MediaItem*") then 
     
        for t=0, reaper.CountTakes(curItem)-1 do 
        
            local curTake = reaper.GetTake(curItem, t)    
            if reaper.ValidatePtr2(0, curTake, "MediaItem_Take*") and reaper.TakeIsMIDI(curTake) then 
            
                -- Should we use MIDI string or MIDI hashes to compare pre- and post-Action?  
                -- Strangely, MIDI hashes may change even if the MIDI data didn't really change.
                -- So rather use the MIDI strings.
                gotDataOK, tableMIDIdata[curTake] = reaper.MIDI_GetAllEvts(curTake, "")
                --gotDataOK, tableMIDIdata[curTake] = reaper.MIDI_GetHash(curTake, true, "")
                                            
            end -- if reaper.ValidatePtr2(0, curItem, "MediaItem_Take*") and reaper.TakeIsMIDI(curTake)
        end -- for t=0, numTakes-1
    end -- if reaper.ValidatePtr2(0, curItem, "MediaItem*")
end -- for i=0, numItems-1


---------------------------------------------------------------------------------------------------------------
-- Now apply a native Action that is guaranteed to change some MIDI in all *editable* takes with selected notes
-- The script will replace the MIDI data of all takes that are changed by the native Action, so no need to 
--    undo the Action.
-- To prevent the Action from creating an undo point, start an Undo Block before calling Action.
editor = reaper.MIDIEditor_GetActive()
reaper.Undo_BeginBlock2(0)
reaper.MIDIEditor_OnCommand(editor, 40909) -- Edit: Invert voicing downwards for selected notes (all editable)


-----------------------------------------------------------------------------------------------------------
-- Find all takes in which the MIDI data changed, by comparing their new MIDI data with the pre-Action data
for take, oldMIDIdata in pairs(tableMIDIdata) do
    local gotDataOK, newMIDIdata = reaper.MIDI_GetAllEvts(take, "")
    --local gotDataOK, newMIDIdata = reaper.MIDI_GetHash(curTake, true, "")
    if newMIDIdata == oldMIDIdata then
        tableMIDIdata[take] = nil
    end
end


-----------------------------------------------------------------------------------------
-- Now iterate through all editable takes, inserting lyrics or dynamics at selected notes
for take, MIDIstring in pairs(tableMIDIdata) do
    local tableMIDIevents = {} -- Each take's MIDI events will be stored one-by-one in this table, until concatenated again
    local t = 0 -- Index inside tableMIDIevents
    local MIDIlen = MIDIstring:len()
    local stringPos = 1
    local offset, flags, msg, velocityMsg -- velocityMsg will depend on whether lyrics or dynamics should be inserted
    while stringPos < MIDIlen do
        offset, flags, msg, stringPos = s_unpack("i4Bs4", MIDIstring, stringPos)
        if msg ~= "" then
            local velocity = msg:byte(3)
            -- If note-on, insert new lyric or dynamic marker
            if msg:byte(1)>>4 == 9 and velocity ~= 0 and flags&1==1 then
            
                if insertDynamicsOrLyrics == "Dynamics" then
                    -- Code for inserting dynamics
                    for i = #tableCutoffValues, 1, -1 do
                        if velocity >= tableCutoffValues[i] then
                            velocityMsg = string.char(0xFF, 0x0F) .. "TRAC dynamic " .. tableDynamics[i]
                            break
                        end
                    end
                else
                    -- Code for inserting a lyric
                    velocityMsg = string.char(0xFF, 0x05) .. tostring(msg:byte(3))
                end
                t = t + 1
                tableMIDIevents[t] = s_pack("i4Bs4", offset, 0, velocityMsg)
                t = t + 1
                tableMIDIevents[t] = s_pack("i4Bs4", 0, flags, msg)
            else
                t = t + 1
                tableMIDIevents[t] = s_pack("i4Bs4", offset, flags, msg)
            end
        end
    end -- while stringPos < MIDIlen
    reaper.MIDI_SetAllEvts(take, table.concat(tableMIDIevents))
end


-------------------------------------------------------------------------
-- Creat Undo point
-- flag=4 should limit the information that is included in the undo point 
--    to changes that were made to *items*, so the creation of the undo point is hopefully much faster. 
if insertDynamicsOrLyrics == "Dynamics" then 
    undoText = "Convert note velocities to dynamics"
else
    undoText = "Convert note velocities to lyrics"
end
reaper.Undo_EndBlock2(0, undoText, 4)
This code uses a newfangled "trick" to find all editable takes the MIDI editor, since REAPER's API does not provide this information natively. There might still be a bug in my trick, so this is just a beta version of the script.

In the script's USER AREA, you can select between lyrics or dynamics, and customize the dynamics.
__________________
47.8% of statistics are made up.
lowellben is offline   Reply With Quote
Old 06-02-2017, 03:34 AM   #1190
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 425
Default

Here's my version - thanks to Julian for help with notation events. My script only works on the selected notes in a selected take, it doesn't work across multiple ones.

There are some variables at the top that you can edit. The numbers in DYNAMICS are for each velocity range, so as I have set it up, anything below 15 is ppp, anything below 30 but above 15 is pp etc. You can adjust these thresholds to suit you but I think they are a pretty good starting point and I've taken accented notes into account which will have a higher velocity than the surrounding notes of the same dynamic.

If you want the range of dynamics to go from pppp to ffff then you need to comment out the first DYNAMICS line and uncomment the second one, same for the MARKINGS.

Code:
--[[ 
* ReaScript Name: MIDI Add Velocity Based Dynamics To Selected Notes
* Version: 01/06/2017
* Author: David Healey.
--]] 

--USER SETTINGS
DYNAMICS = {15, 30, 45, 60, 75, 90, 105, 127} --ppp to fff
--DYNAMICS = {8, 20, 31, 42, 53, 64, 80, 96, 112, 127} --pppp to ffff
MARKINGS = {"ppp", "pp", "p", "mp", "mf", "f", "ff", "fff"} --ppp to fff
--MARKINGS = {"pppp", "ppp", "pp", "p", "mp", "mf", "f", "ff", "fff", "ffff"} --pppp to ffff
---------------------------

function main()

	e = reaper.MIDIEditor_GetActive() --Get active editor
	take = reaper.MIDIEditor_GetTake(e) --Get active take

	if take ~= nil then

		reaper.Undo_BeginBlock();

		retval, notes, ccs, sysex = reaper.MIDI_CountEvts(take) --Count note and cc events

		for n = 0, notes, 1 do 
			retval, selected, muted, ppq, endppq, chan, pitch, vel = reaper.MIDI_GetNote(take, n) --Get note data

			--Find which dynamic range the velocity value fits to determine which dynamic marking to use
			if selected == true then
				reaper.MIDIEditor_OnCommand(e, 42173) --Remove any existing note text

				for i in pairs(DYNAMICS) do
					if vel <= DYNAMICS[i] then
						reaper.MIDI_InsertTextSysexEvt(take, true, false, ppq, 0xF, "TRAC dynamic " .. MARKINGS[i] .. " ypos 2.000")
						break;
					end
				end
			end
		end

		reaper.MIDI_Sort(take)
		reaper.Undo_EndBlock("MIDI Add Velocity Based Dynamics To Selected Notes",-1);
		reaper.UpdateArrange();
	end
end

main()
__________________
David Healey
Purveyor of fine sample libraries (and Kontakt scripting tutorials) - http://xtant-audio.com/
reddiesel41264 is offline   Reply With Quote
Old 06-04-2017, 04:56 AM   #1191
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 425
Default

Selecting notes in the notation editor does not select the CC data connected to those notes, this is a very big problem when copying and pasting notes between staves.
__________________
David Healey
Purveyor of fine sample libraries (and Kontakt scripting tutorials) - http://xtant-audio.com/
reddiesel41264 is offline   Reply With Quote
Old 06-04-2017, 05:50 AM   #1192
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 425
Default

Quote:
Originally Posted by reddiesel41264 View Post
Selecting notes in the notation editor does not select the CC data connected to those notes, this is a very big problem when copying and pasting notes between staves.
I've come up with a temporary solution for this which will solve the issue for copying and pasting and maybe some other scenarios. Make a custom action and include the lua script below, followed by the standard edit->copy action. Then assign it ctrl+c as a shortcut (or whatever you want).

Code:
--[[ 
* ReaScript Name: MIDI Select All CC Events Under Selected Notes
* Version: 04/06/2017
* Author: David Healey.
--]] 

take = reaper.MIDIEditor_GetTake(reaper.MIDIEditor_GetActive()) --Get active take

if take ~= nil then
	
	reaper.Undo_BeginBlock();

	retval, notes, ccs, sysex = reaper.MIDI_CountEvts(take) --Count note and cc evens

	for n = 0, notes, 1 do --Each note event

		retval, n_selected, n_muted, n_ppq, n_endppq, n_chan, pitch, vel = reaper.MIDI_GetNote(take, n); --Get note data

		if n_selected == true then --If this note is selected

			for c = 0, ccs, 1 do --Each CC event
				retval, c_selected, c_muted, c_ppq, c_chanmsg, c_chan, msg2, msg3 = reaper.MIDI_GetCC(take, c) --Get CC data

				--If the CC ppq is within the note's start and end ppq
				if c_ppq >= n_ppq and c_ppq < n_endppq then
					reaper.MIDI_SetCC(take, c, true, NULL, NULL, NULL, NULL, NULL, NULL, true); --Set CC as selected
				end
			end

		end

	end
end

reaper.MIDI_Sort(take)
reaper.Undo_EndBlock("MIDI Select All CC Events Under Selected Notes",-1);
reaper.UpdateArrange();
__________________
David Healey
Purveyor of fine sample libraries (and Kontakt scripting tutorials) - http://xtant-audio.com/
reddiesel41264 is offline   Reply With Quote
Old 06-04-2017, 05:53 AM   #1193
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 1,176
Default

Quote:
Originally Posted by reddiesel41264 View Post
Selecting notes in the notation editor does not select the CC data connected to those notes, this is a very big problem when copying and pasting notes between staves.
Indeed. Left-clicking to select notes one-by-one correctly activates "CC selection follows not selection", but right-dragging to select multiple notes does not.
juliansader is online now   Reply With Quote
Old 06-04-2017, 05:56 AM   #1194
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 1,176
Default

Quote:
Originally Posted by reddiesel41264 View Post
I've come up with a temporary solution for this which will solve the issue for copying and pasting and maybe some other scenarios.
The native action "Edit: Select all CC events under selected notes" might also be handy.
juliansader is online now   Reply With Quote
Old 06-04-2017, 09:59 AM   #1195
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 425
Default

Quote:
Originally Posted by juliansader View Post
The native action "Edit: Select all CC events under selected notes" might also be handy.
Haha indeed. I didn't see that one!
__________________
David Healey
Purveyor of fine sample libraries (and Kontakt scripting tutorials) - http://xtant-audio.com/
reddiesel41264 is offline   Reply With Quote
Old 06-05-2017, 06:38 AM   #1196
lowellben
Human being with feelings
 
lowellben's Avatar
 
Join Date: Aug 2010
Location: Not Lowell
Posts: 2,642
Default

Quote:
Originally Posted by reddiesel41264 View Post
Haha indeed. I didn't see that one!
How can I incorporate your action David and native "Edit: Select all CC events under selected notes" action? that seems like the perfect combo
__________________
47.8% of statistics are made up.
lowellben is offline   Reply With Quote
Old 06-05-2017, 07:34 AM   #1197
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 1,176
Default

Quote:
Originally Posted by lowellben View Post
How can I incorporate your action David and native "Edit: Select all CC events under selected notes" action? that seems like the perfect combo
It depends: what exactly would you like to do?

For example, if you press Ctrl-C in notation view, would you prefer to ALWAYS also select ALL the accompanying CCs?
juliansader is online now   Reply With Quote
Old 06-05-2017, 08:00 AM   #1198
lowellben
Human being with feelings
 
lowellben's Avatar
 
Join Date: Aug 2010
Location: Not Lowell
Posts: 2,642
Default

Quote:
Originally Posted by juliansader View Post
It depends: what exactly would you like to do?

For example, if you press Ctrl-C in notation view, would you prefer to ALWAYS also select ALL the accompanying CCs?
Oh, sorry. I thought David was saying his display-velocity-script under each selected MIDI note was not working correctly due to the CC data not being copyable or something - did I goof? Sorry!
__________________
47.8% of statistics are made up.
lowellben is offline   Reply With Quote
Old 06-05-2017, 08:07 AM   #1199
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 1,176
Default

Quote:
Originally Posted by lowellben View Post
Oh, sorry. I thought David was saying his display-velocity-script under each selected MIDI note was not working correctly due to the CC data not being copyable or something - did I goof? Sorry!
The previous posts were actually not related to the velocity/dynamics scripts.

(BTW, did you grab the updated v0.92 of the script?)
juliansader is online now   Reply With Quote
Old 06-05-2017, 09:53 AM   #1200
lowellben
Human being with feelings
 
lowellben's Avatar
 
Join Date: Aug 2010
Location: Not Lowell
Posts: 2,642
Default

Quote:
Originally Posted by juliansader View Post
The previous posts were actually not related to the velocity/dynamics scripts.

(BTW, did you grab the updated v0.92 of the script?)
Of which script? I can't find in Reapack.
__________________
47.8% of statistics are made up.
lowellben 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 12:26 AM.


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