Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added sample-editor scripting feature #282

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

coderofsalvation
Copy link
Contributor

@coderofsalvation coderofsalvation commented Aug 26, 2022

image

A simple scripting-bridge for MilkyTracker SampleEditor
Instead of bloating milkytracker with more effects/plugins, the burden of maintenance is reversed: external
applications & scripts can 'hook' into the sample-editor using the 'Script'-contextmenu.

DEMO video

https://drive.google.com/file/d/1dG_vmeCFSbmhLlnlHpgcLNB6zScXXTng/view?usp=sharing

Usecases

  • generate samples using puredata/csound or your favorite wave-editor etc
  • dump gig/sf2-soundfont wave-files into directory
  • write custom SAMPLERS: sample ANY SYNTH/APP/INPUT into milkytracker
  • apply a complex effect to a sample
  • automate tedious tasks
  • use your favorite scripting language to automate things
  • Create script-pipelines between different tools / commands, pick random samples from folders etc.

example scripting: https://gitlab.com/coderofsalvation/milkytracker-scripts

@Claytone
Copy link
Contributor

This is actually insanely cool, thanks for sharing!

@coderofsalvation coderofsalvation force-pushed the feat/sampleditor-scripting branch from 15a3185 to ffa6b5b Compare August 31, 2022 09:23
@coderofsalvation coderofsalvation force-pushed the feat/sampleditor-scripting branch 4 times, most recently from 7cd97c9 to 12cb5a3 Compare September 15, 2022 14:44
@coderofsalvation coderofsalvation force-pushed the feat/sampleditor-scripting branch from 12cb5a3 to cd6e10f Compare September 15, 2022 16:03
@minidcon7
Copy link

Why is pull request not accepted?.

@coderofsalvation
Copy link
Contributor Author

coderofsalvation commented Dec 5, 2024

we had a big release blocking this feature (we wanted to take things step by step) but this might soon get some attention again

@coderofsalvation
Copy link
Contributor Author

coderofsalvation commented Jan 8, 2025

I've been thinking about the following:

Embedding lua is something I've played with (and discussed with others).
However, I've noticed that a lua api is easy to put in, but makes things hard to maintain and/or change (changing an api-call will break all previous scripts, requires versioning and much more testing for all platforms.).
Therefore, I still think the polyglot 'script-out' approach (of this PR) might be more lightweight, without ballooning the lightweight-ness of milkytracker (which runs on haiku, amiga etc).

perhaps broadening this feature, would allow for more generic and powerful polyglot integrations/plugins:

pattern editor

~/$CONFIGPATH/scripts.pattern.txt

generate pattern; generateXPpattern.sh %s
import midi; midi2xp %s %s |.mid
export midi; xp2midi %s

Note: |.mid will make milkytracker popup a filepicker (which filters on .mid files) before calling midi2xp <midifile> /tmp/pattern.xp

rightclick > Script > generate pattern         
                      import midi
                      export midi
                      ------------
                      scripts config                        # calls linux/mac: $EDITOR ~/$CONFIGPATH/scripts.pattern.txt
                                                                          mac:  open  ~/$CONFIGPATH/scripts.pattern.txt
                                                                          win: start ~/$CONFIGPATH/scripts.pattern.txt      

sample editor

~/$CONFIGPATH/scripts.sample.txt

sox chorus;sox %s -D %s chorus 0.7 0.9 55 0.4 0.25 2 -t
sox contrast;sox %s -D %s contrast 0.2
AI generate trumpet;apicall_to_LLM %s

see example: https://gitlab.com/coderofsalvation/milkytracker-scripts/-/blob/master/scripts.txt?ref_type=heads

rightclick > Script > sox chorus         
                      sox contrast
                      AI generate trumpet
                      ------------
                      scripts config                       # calls linux: $EDITOR ~/$CONFIGPATH/scripts.sample.txt
                                                                          mac:  open  ~/$CONFIGPATH/scripts.sample.txt
                                                                          win: start ~/$CONFIGPATH/scripts.sample.txt        

Any feedback appreciated

@coderofsalvation
Copy link
Contributor Author

There have been ideas in the milkytracker chat about a controlling the cursor with a script:

<raina> this sounds like a thing for some external accessibility automator, it would just need the cursor position and editstep from milky. like when you hit a special key combo, IF you're on the note column, insert note 1, tab, insert note 2, tab, insert note 3 and shift-tab back to the original column. it would need to know how many rows to step back too between each note

Idea: instead of pattern editor script (shell/py/lua/bat/ps1) just exiting with code 0.
When it returns a string starting with MTKB: then all ascii/controlcharacters can be parsed by milkytracker as keyboard input.
SInce the first argument of a pattern script (%s) is the pattern (.xp file), any script can optionally analyze the current pattern-state as well.
Perhaps 3 extra arguments should be passed: cursor-row, cursor-channel, cursor-column

$ ./mypatternscript.py currentpattern.xp 23 1 7
MTKB: ^[[tab..... 

this hypothetical script would receive (and optionally mutate) currentpattern.xp, receive cursor on row 23, channel 1, last effect column (7) and return keystrokes as a response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants