Skip to content

Instantly share code, notes, and snippets.

@dustractor
Created August 11, 2023 03:20
Show Gist options
  • Save dustractor/ed558b7f6479cf76840fdf7672fd3f8e to your computer and use it in GitHub Desktop.
Save dustractor/ed558b7f6479cf76840fdf7672fd3f8e to your computer and use it in GitHub Desktop.
from flpianoroll import *
note_ct = score.noteCount
def createDialog():
form = ScriptDialog("Select every nth note","")
form.AddInputKnobInt("nth",2,2,64)
return form
def apply(form):
nth = form.GetInputValue("nth")
times = set()
for n in range(note_ct):
xnote = score.getNote(n)
times.add(xnote.time)
goodtimes = list()
for n,t in enumerate(sorted(list(times))):
if (n % nth) == 0:
goodtimes.append(t)
goodnotes = list()
for n in range(note_ct):
xnote = score.getNote(n)
if xnote.time in goodtimes:
goodnotes.append(n)
for n in goodnotes:
xnote = score.getNote(n)
xnote.selected = True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment