Old 07-18-2023, 10:18 AM   #1
Petey-B
Human being with feelings
 
Petey-B's Avatar
 
Join Date: Jan 2023
Location: Kent Island, MD USA
Posts: 20
Default TouchOSC Widgets for Reaper

What you'll find here:
  • This is an ongoing collection of widgets that can be ncorporated into TouchOSC control surfaces.
  • Each widget is in a self-contained group that can be copied and pasted and customized to your liking.
  • A few are autonomous, but most require a support structure added to Reaper by way of scripts and OSC shortcuts.
  • They've been built and tested under Windows 64bit, but will most likely run on other platforms.
  • Keep in mind I'm pretty new to all this GitHub and forum posting stuff, ...
Conventions:
  • Custom OSC messages are usually named after the Lua files they trigger.
  • I use locally referenced Reaper API calls in my scripts, they run faster and are easier to type.
  • Scripts have been optimized and benchmarked, so they may not be the easiest to follow.
  • I've tried to keep the scripts as implementation neutral as possible, but since everyone's device ID's etc. are different the need to modify some of the scripts and control surfaces is unavoidable. I will do my best to keep the README files on GitHub comprehensive.
  • I'm open to suggestions, if they intrigue or challenge me I might implement them.
You can find all the widgets and support code on GitHub at Petey-B's /TouchOSC Widgets

As of this post I'm using Reaper 6.81 and TouchOSC 1.2.2.175.
__________________
Windows is your punishment for wanting a Macintosh...

Last edited by Petey-B; 07-18-2023 at 11:45 AM.
Petey-B is offline   Reply With Quote
Old 07-18-2023, 11:33 AM   #2
Petey-B
Human being with feelings
 
Petey-B's Avatar
 
Join Date: Jan 2023
Location: Kent Island, MD USA
Posts: 20
Default Quick Markers

Starting off with a simple one:

  • A basic widget that manipulates markers 1 to 8.
  • Tap a numbered button to go to that marker.
  • Tap Set and then a numbered button to set/move that marker.
  • Tap Del and then a numbered button to delete that marker.
  • Use the arrow buttons to go to the next/prev marker.
Aailable on GitHub at Petey-B's /TouchOSC Widgets - Quick Markers

As of this post I'm using Reaper 6.81 and TouchOSC 1.2.2.175.
Attached Images
File Type: png QM.png (24.4 KB, 1120 views)
__________________
Windows is your punishment for wanting a Macintosh...
Petey-B is offline   Reply With Quote
Old 07-18-2023, 01:34 PM   #3
Petey-B
Human being with feelings
 
Petey-B's Avatar
 
Join Date: Jan 2023
Location: Kent Island, MD USA
Posts: 20
Default Current Project Monitor

This one takes a bit of set up:



A defer loop widget that monitors the current project file and cursor position and updates it when changed. Since Reaper has no way to send custom OSC messages the script uses MIDI to send information to TouchOSC. It requires two script files OSCcurrentProject.lua and OSCexit.lue both of which need to be loaded into the Action List and triggered by OSC messages of the same names.

OSCcurrentProject.lua will have to be modified as follows:
Code:
-- 16 + the MIDI device ID that TouchOSC is receiving messages from
local ID = 36

-- 0xB0 + channel# -1, the channel that the gProj group is listening to
local CH = 0xBF

-- checks every 10 calls (≈ 1/3 sec) delays the first call by 16 cycles
-- these can be tweaked to reduce processor impact
local Freq, DeferCt = 10, -6

-- these are commented out, but if you're running TouchOSC on a touchscreen
--    monitor, they may be necessary when tapping the power button changes
--    the active application
r.midi_init(ID-16,-1)
How It Works:.
  • Tapping the power button sends an OSC msg /OSCcurrentProject with the MIDI CC# to use as its argument.
  • A defer loop is started. The update code is run every 10 loops.
  • The code first checks to see it the OSCcurrentProject section exists as an external state, if it does it is deleted and the loop ends.
  • Otherwise it checks to see if anything has changed, if it has, the new data is sent to TouchOSC one char at a time via the MIDI CC.
  • The first char indicates which data is being sent (can be 1 to 31, but only 3 are defined).
  • TouchOSC reassembles the string using a table; when it receives char 127 it concats the table and sets the data.
  • When the power button is pressed again it sends /OSCexit with argument OSCcurrentProject which creates that ExtState
  • The next defer loop shuts everything down.
The CC value in the widget is 90, on channel 16. If you change it, it will have to be changed in the MIDI message that the gProj control listens for.

How to Set It Up:
  • Make any necessary changes to the OSCcurrentProject.lua script, and the widget.
  • Load the two scripts into Reaper's Action List.
  • Select OSCcurrentProject, click Add... and tap the power button.
  • Select OSCexit, click Add... and tap the power button again.
  • The two scripts should be set to trigger by their OSC namesakes.
Things That Can Go Wrong:
  • There is no exit strategy if TouchOSC is closed without turning the power off, so the defer loop will keep running.
  • If this happens just double click on the script and select Terminate Instance.
Aailable on GitHub at Petey-B's /TouchOSC Widgets - Current Project Monitor

As of this post I'm using Reaper 6.81 and TouchOSC 1.2.2.175.
__________________
Windows is your punishment for wanting a Macintosh...

Last edited by Petey-B; 07-31-2023 at 03:01 PM. Reason: typo
Petey-B is offline   Reply With Quote
Old 07-28-2023, 01:30 PM   #4
Petey-B
Human being with feelings
 
Petey-B's Avatar
 
Join Date: Jan 2023
Location: Kent Island, MD USA
Posts: 20
Default MIDI Editor Cursor Mover

Moves the cursor around in the MIDI Editor. I also have Jog and View Scroll/Zoom widgets that will eventually make it up here.



How It Works:
  • Sends the OSC message /MECmove which triggers the script MECmove.lua, passing a string argument to direct execution.
  • The top cemter radio control sets whether the prev/next arrows move the cursor by a Measure, Quarter note or Grid unit.
  • The diamond shaped controls snap the cursor to the prev/next unit set by the aforementioned radio.
  • The bottom center radio determines whether the flanking arrows move to the prev/next start or end of note.
How To Use It:
  • The setup is the same for all my single script widgets (SSW's).
  • Load the script MECmove.lua into the Reaper's Action List.
  • Select it and,click Add... then tap any non-radio button on the control.
  • The script should now be triggered by the /MECmove OSC message.
Caveats:
  • If there is no MIDI Editor window open you'll get an error message; while some of the functionality doesn't use an active MIDI Editor take, most require it.
Aailable on GitHub at Petey-B's /TouchOSC Widgets - MIDI editor Cursor
__________________
Windows is your punishment for wanting a Macintosh...
Petey-B is offline   Reply With Quote
Old 07-31-2023, 02:46 PM   #5
Petey-B
Human being with feelings
 
Petey-B's Avatar
 
Join Date: Jan 2023
Location: Kent Island, MD USA
Posts: 20
Default MIDI Editor View Scroll/Zoom

Scrolling and Zooming in the MIDI Editor - Updated !



How It Works:
  • Tap the button in the middle of the encoder to toggle between scroll and zoom modes.
  • The encoder controls the horizontal view, the fader controls the vertical.
  • The encoder uses an inertial algorithm so that the faster you move it the more it will scroll; it works but could use some tweaking.
  • The control OSC messages trigger scripts that send MIDI messages on channel 16 CC#'s 10 - 13.
  • The TouchOSC file includes buttons to facilitate assigning the MIDI shortcuts.
  • The pads below the encoder scroll view left/right; in zoom mode they zoom to time selection/content
How To Use It:
  • Load the two scripts MEV_scroll.lua and MEV_zoom.lua into Reaper's Action List.
  • Assign the OSC shortcuts to them.
  • Assign the MIDI triggers to the native scroll/zoom actions in the MIDI Editor section of the Action List.
  • See the README file on GitHub for detailed instructions.
Caveats:
  • My setup runs TouchOSC locally on a touchscreen monitor.
    The scripts can be modified if you'll only be running it from a phone, tablet or anything else not running on the same computer. Details are in the README file.
  • The zooming is a little aggressive, I'm working on smoothing it out a little.
  • The SN_FocusMIDIEditor() API function call requires the SWS extensions, which you should already have anyway if you're using custom scripts.
  • If these widgets don't seem to work exactly as advertised, it may be that your Editor prefs are set up differently.
    Here's a good post on how to
    Set up MIDI Editor for a Better Workflow

    This is how mine is configured, it's more intuitive than Reaper's default setup.
Available on GitHub at Petey-B's /TouchOSC Widgets - MIDI Editor Scroll Zoom
__________________
Windows is your punishment for wanting a Macintosh...

Last edited by Petey-B; 08-02-2023 at 08:04 AM. Reason: Updated
Petey-B is offline   Reply With Quote
Old 08-01-2023, 08:15 PM   #6
Petey-B
Human being with feelings
 
Petey-B's Avatar
 
Join Date: Jan 2023
Location: Kent Island, MD USA
Posts: 20
Default MIDI Editor Note Selector (by time span)

This is the first of several note selection widgets (NSWs).
While the buttons and radios may seem redundant, they allow one tap selection, deselection and inversion of various spans around the edit cursor's current position.



How It Works:
  • Tapping any of the green buttons will execute the selection of notes.
  • The blue radio controls modify how the selection is made:
    • The top radio pertains to the buttons above it
    • The bottom radio controls the buttons below it
  • The round toggle buttons on the right modify what gets included/excluded
    • + - determines whether this is a new selection or extends/modifies an existing selection
    • ⊏♪ - includes only notes that start within the selection span
    • ♪⊐ - includes only notes that end within the selection span
    • If neither start nor end is on, notes are selected if any part of them falls within the selection span
    • The start/end buttons have no effect when selecting notes @ the edit cursor
    • None of these modifiers apply when working on all notes in the current take
How To Use It:
  • Load the script ME_selSpan.lua into Reaper's Action List.
  • Assign the OSC shortcut /ME_selSpan by tapping any of the green buttons.
  • The script should now be triggered by its namesake.
  • See the README file on GitHub for detailed instructions pretty much the same thing.
Notes:
  • The toggles change their default values and are persistent only if the file is explicitly saved.
    The changes do not flag the file as dirty, so it can be closed without prompting.
    This actually has advantages; if you want it to start up a certain way, just save it.
    TouchOSC needs an onExit() callback.
  • The selection algorithm uses exact PPQ values to determine inclusion.
    As a result, boundary conditions may result in unintended selections.
    If this turns out to be overly annoying I'll add a few more "if" blocks.
  • I went to great lengths to implement the "extend existing selectiion" toggle.
    It required iterating over every note regardless of the span size; but even
    with all that code the entire script runs in under 12ms for a 250 note take.

Aailable on GitHub at Petey-B's /TouchOSC Widgets - MIDI Editor Span Selector

A Note About Visual Representation Paradigms:
I've seen some TouchOSC control surfaces out there that have gone to great lengths to achieve a sense of photo-realism with the knobs and faders. This requires a glut of static objects that take time to load and render. I strive for simple functionality and put most of my efforts into the underlying code. Eventually TouchOSC will support images, when that happens I'll fire up Photoshop and make slicker looking controls; for now I'll settle for visually inoffensive and functionally effective.
__________________
Windows is your punishment for wanting a Macintosh...
Petey-B is offline   Reply With Quote
Old 08-10-2023, 05:56 PM   #7
Petey-B
Human being with feelings
 
Petey-B's Avatar
 
Join Date: Jan 2023
Location: Kent Island, MD USA
Posts: 20
Default Another MIDI Editor Note Selector

An intelligent MIDI note selector with a lot of options.
See the README file on GitHub for a complete explanation; it's pretty long and I don't want to repeat the whole thing here.



How It Works:
  • The Select Matching buttons selects notes by their pitch, channel or velocity.
    • At least one note must be selected or these do nothing.
    • If more than one note is selected, multiple values will be matched.
  • The PPQ section selects notes by their start times.
    • The ◁ ▷ buttons select the prev/next note(s) with the same PPQ.
    • The toggle lets you specify a PPQ range for recorded or humanized MIDI.
    • The + toggle starts a new selection or adds to an existing one.
    • The 🔁 toggle wraps the selection to the end/start of the take.
  • The Trim section removes the first or last notes from an existing selection.
  • The IDX section selects notes one at a time by their index in the MIDI stream.
    • The + and 🔁 toggles work the same as the PPQ section.
    • The =♪ toggle limits the selection to notes of the same pitch.
    • The =Ch toggle limits the selection to notes of the same channel.
    • The =V toggle limits the selection to notes of the same velocity.
  • The By Offset button selects notes that occur at the same offset in the specified span.
    • This is useful, for example, if you want to select all the off-beats in a percussion take.
    • Select the notes you want to match first, if nothing is selected then this does nothing.
    • Multiple notes can be selected.
    • The =♪ toggle works with this, but not the other two toggles, I may add them.
    • The Span radio determines the measure block that the offset is measured from.
      The easiest way to figure our how this works is to play with it.
How To Install It:
  • Load the three scripts:
    • ME_selByIDX.lua - triggered by the purple IDX triangle buttons
    • ME_selByPPQ.lua - triggered by the green PPQ triangle buttons
    • ME_selByOffset.lua - triggered by the By Offset button
    into Reaper's Action List.
  • Assign the OSC triggers by clicking Add... and tapping the appropriate buttons.
  • The scripts should now be triggered by their namesakes.
  • See the README file on GitHub for detailed instructions.
Notes:
  • See the previous post for notes about toggle button persistence.
  • I'm thinking about providing compiled versions of the scripts to improve load times.
    Compiled scripts are not noticeably smaller, but saves Reaper the trouble of compiling them.
    Unfortunately they can't be given an indicative extension (.luc); Reaper's fussy about that.
    In lieu of that I'll just start the name with an underscore.
  • The code can be hard to follow and deliberately under-commented (keeping scripts as small as possible).
    If you need to modify it, be careful.

Aailable on GitHub at Petey-B's /TouchOSC Widgets - MIDI Editor Note Selector
__________________
Windows is your punishment for wanting a Macintosh...
Petey-B is offline   Reply With Quote
Old 08-10-2023, 06:30 PM   #8
Petey-B
Human being with feelings
 
Petey-B's Avatar
 
Join Date: Jan 2023
Location: Kent Island, MD USA
Posts: 20
Default Wide Version of Span Selector & bug fix

This is a wide version of the Span Selector; the functionality is identical.



Notes:
  • I fixed a boundary condition bug in ME_selSpan.lua.
  • When the edit cursor is at the exact start of a measure MIDI_GetPPQPos_StartOfMeasure
    and MIDI_GetPPQPos_EndOfMeasure both return the same value.
  • This version of the widget is the file ME_gSelSpan-Wide.tosc.

Aailable on GitHub at Petey-B's /TouchOSC Widgets - MIDI Editor Note Selector
__________________
Windows is your punishment for wanting a Macintosh...

Last edited by Petey-B; 08-14-2023 at 12:40 PM.
Petey-B is offline   Reply With Quote
Old 08-14-2023, 07:32 AM   #9
Petey-B
Human being with feelings
 
Petey-B's Avatar
 
Join Date: Jan 2023
Location: Kent Island, MD USA
Posts: 20
Default MIDI Editor Note Length Widget

A MIDI note length setter/adjuster for selected notes.



How It Works:
  • The top row of buttons doubles, halves or dots the selected note lengths.
  • The buttons in the left column set, add or subtract the length selected in the grid.
    • There is a minimum length of a 256th note.
    • This is the shortest note that can be accurately represeneted by an integer PPQ value
      using Reaper's default of 960 PPQs.
  • The grid buttons are toggles, they are basically a 2-D radio control.
    • The last button uses the current MIDI editor grid value for the length.
How To Install It:
  • Load the script MEN_Length.lua into Reaper's Action List.
  • Assign the OSC trigger by clicking Add... and tapping any of the non-grid buttons.
  • The script should now be triggered by /MEN_Length.
Notes:
  • If nothing is selected, nothing happens.
  • Minimum note length is only checked for the +/- buttons, you can halve a note to a shorter length.
  • A 256th note at 960 PPQs is 15 ticks long, if you halve it and then double it, the length will be off.

Aailable on GitHub at Petey-B's /TouchOSC Widgets - MIDI Editor Note Length
__________________
Windows is your punishment for wanting a Macintosh...

Last edited by Petey-B; 08-20-2023 at 04:41 AM. Reason: Fixed typo
Petey-B is offline   Reply With Quote
Old 08-18-2023, 08:57 PM   #10
Petey-B
Human being with feelings
 
Petey-B's Avatar
 
Join Date: Jan 2023
Location: Kent Island, MD USA
Posts: 20
Default Edit Cursor Jog Wheel

A Jog encoder with adjustable resolution and scrub options. It works with both the Track List and the MIDI Editor.



How It Works:
  • The button pads at the corners move the edit cursor as follows.
    • |◀ / ▶| - start/end of project (or take if a MIDI Editor is open).
    • ◀ / ▶ - back/fwd by the selected interval.
  • The outer circle is a radial control that works like a radio to select the jog interval.
    • G - uses the current Track List grid (or MIDI Editor grid if it's open).
    • The others set the interval to Measure, Half, Quarter, 8th, etc.
  • The inner violet ring is the encoder that does the actual jogging.
    • To slow down the triggering, it was very touchy, a sensitivuty interval of 0.005 is
      built in to the jog wheel. This can be adjusted by changing the thresh variable
      int the eJog control script.
    • The jog wheel and the ◀/▶ buttons do not snap to interval boundaries.
  • The innermost circle contains two half circle buttons that use Reaper's native scrub actions.
    • The actions are triggered by MIDI CC's 14 and 15 on channel 16.
    • These can be changed in the script; they are not used by the TouchOSC widget.
    • Tapping one of these buttons deactivates the interval ring; tapping it again or
      tapping the ring reactivates it.
    • See the Notes below for issues with this.
How To Install It:
  • Buttons are included in the widget file to make setup easier; after assigning
    the shortcuts, all that is needed is the gECjog control group.
  • Load the script EC_jog.lua into Reaper's Action List.
  • Assign the OSC trigger by clicking Add... and tapping the bottom Send OSC button.
  • Select the appropriate actions indicated by the top two buttons and tap them to send the MIDI CC's.
Notes:
  • SCRUBBING: Once again the MIDI issue arises if you're running TouchOSC on a local display.
    • The scrub messages don't get through if Reaper does not have focus.
    • This is commented out in the script:
      Code:
      local hWnd = r.GetMainHwnd()
      r.BR_Win32_SetFocus(hWnd)
      I need these to get scrubbing to work on my local touchscreen display.
    • Alternatively, arming a track for MIDI recording also solves this problem.

  • SCALING: While TouchOSC does a decent job, pixels aren't fractional.
    • The controls in this widget are packed in pretty tight and uneven scaling might result
      in unintentional overlap and/or clipping. This will wreck my art.
    • Try to match the size of your TOSC surface to the exact dimensions of the screen it will run on.

  • Version 2 will likely include a toggle to create/extend the time selection. I may also tweak the color scheme, it's a little garish.

Aailable on GitHub at Petey-B's /TouchOSC Widgets - Edit Cursor Jog Wheel
__________________
Windows is your punishment for wanting a Macintosh...
Petey-B 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 09:38 AM.


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