Scripting transposition

Hi all. I am trying to find a way to script transposing up or down a major second (and other intervals eventually, depending on the context). When I try to record a macro of doing this from the Write > Transpose menu, the recorded macro doesn’t seem to contain anything about the distance of the transposition:

local app=DoApp.DoApp()
app:doCommand([[Edit.TransposeSelection]])

I’m aware that ⇧⌥ up/down will transpose by half-step, but I’d like to be able to do specific intervals at once, and the half-step transposition never seems to do what I expect for enharmonics. Is there a way to pass an option to Edit.TransposeSelection that can change the amount? At the moment, this macro just brings up the Transpose dialog.

Unfortunately you can’t currently access anything that happens inside this (or indeed any) dialog. A better approach would probably be to capture the command used for the Shift+I popover, since you can transpose by any interval via that popover, e.g. t2 will transpose up by a diatonic second, and t-p4 will transpose down by a perfect fourth.

1 Like

Thanks Daniel. I’ll look forward to some more scriptable down the line, and this popover method will be a perfect solution in the meanwhile. Looking forward to playing around with it tonight! (I’ve always thought of the popover system as practical, clever, and powerful, but this is the first time I’ve thought of it as fun!)