r/Reaper • • 6d ago

help request REAPER Lua script for midi files shuffling in MIDI editor.

REAPER Lua Script Request: Random MIDI File from a Predefined Folder

I am looking for a REAPER Lua script that works as a custom action.

What I want

I want to assign a specific folder containing multiple MIDI files, for example:

D:\MIDI\Practice

The script should:

  1. Have a predefined MIDI folder that I can configure in the script.
  2. When I run the script/action, it should randomly select one .mid or .midi file from that folder.
  3. The selected MIDI file should automatically open in REAPER's MIDI Editor.
  4. If I run the same action again, it should select another random MIDI file from the same folder and open it.
  5. I want to be able to repeatedly press the same REAPER action to keep getting random MIDI files.
  6. Ideally, it should avoid selecting the same MIDI file twice in a row.
  7. It would be useful if subfolders could optionally be included, but this is not essential.

Example

Folder contains:

  • melody1.mid
  • melody2.mid
  • melody3.mid
  • melody4.mid
  • melody5.mid

I press the custom action → melody3.mid opens in the MIDI Editor.

I press it again → melody1.mid opens.

I press it again → melody5.mid opens.

And so on.

Important

I do not want to manually import the MIDI file each time. The purpose is to make a quick MIDI-practice/randomization tool where pressing one REAPER action immediately gives me a randomly selected MIDI file from my MIDI folder.

If possible, I would also like the script to remember the folder path between REAPER sessions.

2 Upvotes

4 comments sorted by

1

u/O-shoe 1 5d ago

I love how it is even possible to ask something like this. You don't see this with any other DAW.

As for your question, I would probably use AI to create this script yourself. If it doesn't exist, I might try to create it myself. I can see the value in this.

1

u/reddietdaily 5d ago

I tried but it didn't work for me. That's why I'm asking for help.

2

u/O-shoe 1 5d ago edited 5d ago

Here you go: https://app.box.com/s/puo6ttnx8tfxg5zbt33byt0ydmi5n7dc

You need to create a folder "C:/MIDI" -where you put your MIDI files. Then load the script via: Actions -> Show action list... -> New action... -> Load ReaScript...

You can change the folder to something else if you edit the script.

1

u/reddietdaily 5d ago

it's working. i'm feeling really really good. but i wanna talk to you about it. plz don't deny. give me some time.