MIDI Effects Scripter Editor

The Editor

I’ll leave to Apple’s documentation an overview of the Scripter Editor and just dive into the undocumented and undesirable behaviors.

The editor itself, as a Javascript editor is barebones and has none of the features a developer would expect. There is no autocomplete, and formatting is wonky where indentation is inconsistently applied between tabs as 2 and 4 character widths.

Also (and probably worst of all), there are times when the editor will stop compiling to the UI. I was able to jumpstart the editor with a major code change, completely shutting off and reloading of the Scripter plug-in and desired script, and even having to escalate restarting Logic Pro X. The escalation seemed to be necessary more often when I doing a lot of Run Script actions to parse the code, but this wasn’t consistent enough to be hard fact.

There are a few keyboard shortcuts that are specific to the editor. The usual Cut, Copy, and Paste are all supported, but you must be careful you have the correct focus or else you will mistakenly make changes in your project. Beyond that, all other keyboard shortcuts are reserved for the Project window, and the Editor has only these left specific to it:

  • Increase text size: Shift+Option+”+”
  • Decrease text size: Control+Option+”-“

To save a script update, you must go back to the Scripter plug-in menu for that script and select “Save” in the main pulldown menu. Pressing Cmd+S will only save the Project, and that save will not include the Script.

My Development Process for Scripter

Because the Editor is so wonky, most of my development is done in another editor—my preferred editors are BBEdit or Microsoft Visual Studio Code depending on my mood for the day. I keep my code changes small to minimize the need for relying on the Editor for everything. Essentially, it works out to something like this, using BBEdit as the example:

  1. Make changes in BBEdit.
  2. Copy-paste the entire script from BBEdit to Scripter Editor. This has the benefit of avoiding the compilation problems noted above.
  3. Click “Run Script” in case there are any weird syntax issues according to Editor. (Usually these are my fault.)
  4. Save the script via the Scripter pulldown menu.
  5. Play the tracks, and test the code.
  6. Any required changes are made in BBEdit, and the process starts from the top.

Do that about a dozen times and it’s not nearly as bad as it sounds. If there was a way to hook Xcode or MVSC into Scripter’s JavascriptCore instance would be immensely helpful. (There may be a way to do this, but as of this writing, I haven’t tried.)

Recording Scripter’s MIDI Output

This details how to record the MIDI output of Scripter. Essentially, this method allows recording non-destructively to the source MIDI data by creating a track that has the MIDI effects but points to another track with the patch via the IAC Driver. The caveat to non-destructive recording is looping will cause the previous loop’s data to be written over, which is important when working with randomization.

  1. Open /Applications/Audio MIDI Setup
  2. Go to Window>MIDI Studio
  3. In the window, double-click the “IAC Driver” to view its properties.
  4. Check “Device is online”
  5. Go to the project in LPX
  6. Duplicate the track to be recorded (called SRC and DUPE, respectively)
  7. In the SRC track, change the instrument plug-in to /Utility/External Instrument/Stereo
  8. In the window that appears, change the MIDI Destination pulldown to “IAC Driver Bus 1”
  9. Move the music region(s) in SRC to DUPE
  10. In DUPE, turn off the “R” button
  11. In SRC, turn off the MIDI FX
  12. In DUPE, turn on the “R” button
  13. Make sure the DUPE track is selected and highlighted
  14. In the toolbar, hit Record

Source: youtube.com: iamamusicmogul