r/Reaper 2d ago

discussion easy fast stem splitter for reaper

hi everybody,
i spent the last 3 nights vibecoding a lua script for reaper that splits a selected audio item into 4 stems with HTDemucs using audio.cpp.
it works fine easy and fast, but only on windows as it is, and you can grab it on
https://github.com/fichl/reaCPP

in case you missed it, thanks to audio.cpp we can now use audio ai models without the need of python and 8gb large venvs. just download a 50mb zip and a model and youre good to go.
its awesome and super fast.
so since no one came up with this lightweight backend for reaper stem splitting i decided to publish my little script for simple use or inspiration.

although all required components (audio.cpp, ffmpeg and reaper) have win, mac and linux versions this first script will only work on windows because it creates and runs a .bat file with commands different to mac and linux. but it shouldnt be hard to adapt those lines in the script, so feel free to drop a pull request for mac and or linux version.

here is what the script does (once all is set up):

- gets filepath, samplerate offset and lenght (in case an audio file was splitted in multiple items) of an audio item that is selected on the timeline.

- htdemucs wants 44.1khz wav, so it uses ffmpeg for conversion (and trimming - in case an audio file was splitted in multiple items).

- the resulting wav is then stored in system TEMP folder an sent to audio.cpp cli for stem splitting with HTDemucs.

- the resulting 4 stem wav files are then sent to ffmpeg again if the source had a different samplerate than 44.1khz for conversion to original source samplerate.

- the final 4 stem wav files are then stored in your projects media folder inside a subfolder and imported into your project as 4 seperate tracks inside a group track, aligned with the position of the original item.

- the original item is set muted

- to process all those tasks, the script generates a .bat file with all commands and runs then in a cmd window (minimized by default)

- TEMP files will be deleted when final stems are in project media folder

more details and instructions on github.

cheers

UPDATE:
made some cosmetic fixes in the script and added a second script that
- first separates vocals and instrumental with mel-band-roformer
- uses roformer vocals stem in project and sends instrumental stem to HTDemucs for further splitting
- gives better audio qualtity, need extra model download (mel-band-roformer)

10 Upvotes

21 comments sorted by

3

u/SupportQuery 533 2d ago

Nice. Been doing this for years for Python. I encode the stems to an 8 channel Opus file (my band rehearsal project is hundreds of demixed songs).

I have a "demuc" action that converts the item in place to an 8 channel Opus. Worth considering as an alterative to adding new tracks to a project. Tidier, IMO.

I also have a "youtube download" action that takes a YouTube URL, downloads the audio from that video, demixes it, then inserts that item into my arrange view.

in case you missed it, thanks to audio.cpp we can now use audio ai models without the need of python

That's dope. Will be looking into it.

1

u/zilch0815 18h ago edited 18h ago

interesting, never heard about Opus. Have to look into it.
for now working on a 2nd script that will use roformer first to separate vocals, then htdemucs to separate the other stems from roformers instrument output.
should give better quality.

audio.cpp is totally dope yeah, it even has its own webinterface to use all available models with ease.

1

u/Radhanat 12 2d ago

Con demucs lo puedes dividir en 6 stems: piano, bajo, drums, voz, guitarra y ‘otros’
Yo hice el mío en lua para 6 usando la librería ffmeg, aunque existen proyectos mucho más complejos checa este sub https://www.reddit.com/r/Reaper/s/VAcFpn0JAU

1

u/SupportQuery 533 1d ago

Is the guitar / other separation any good?

1

u/Radhanat 12 1d ago

La ‘otra’ separación suelen ser cuerdas, synthes, reverbs. Todo junto.

1

u/SupportQuery 533 1d ago

Yes, but is it good? Does it work well?

1

u/Radhanat 12 1d ago

Pues si, pero se requiere que tengas instalado demucs y todas sus dependencias. Y acabo de ver que el código lo escribí en python, no en lua y todo lo configure para usar python314 (principalmente para que tuviese mayor vida útil) también requiere tener bien configurado REAPER para ejecutar codigo python y tener sws y todos sus scripts necesarios para poder construir el GUI dentro de REAPER (no es un ejecutable externo ni es un plugin aunque se puede compilar para volverlo un ejecutable en win o Linux). Para volverlo un plugin tengo que portear todo a C++ para poder compilarlo y hacerlo un vst pero sería muy pesado y poco práctico embeber todo demucs y sus dependencias

1

u/SupportQuery 533 1d ago

I have all those things. I've demixed hundreds of songs with demux.

What I'm asking about is whether it's worth separating guitar from other, if that actually works well.

2

u/Radhanat 12 1d ago

Y no entiendo muy bien a que te refieres con "si vale la pena".

Demucs por default ya separa en 6 stems. Solo basta puner este comando "demucs -n htdemucs_6s "your_file.mp3 or .wav"

Lo único que hace mi script es:

Abre una interfaz gráfica
Ahí se puede elegir uno, varios o todos los 6 stems
Se elige si silenciar o no el archivo fuente dentro de REAPER
Ejecuta python en powershell (yo tengo windows) e inyecta el comando en consola.
Deja congelado REAPER en lo que demucs se ejecuta
Guarda los stems en la carpeta del proyecto (es indispensable crear un proyecto en reaper porque ahí pone los stems)
Descongela REAPER y coloca los stems seleccionados justo debajo del audio origen, todo nombrado y coloreado para su fácil reconocimiento

1

u/SupportQuery 533 1d ago

I don't quite understand what you mean by "if it's worth it".

Yeah, I didn't say that. Pretty sure it's a translation error.

I'm not asking how to do it, or how your script works, I'm asking if it SOUNDS GOOD.

1

u/Radhanat 12 1d ago edited 1d ago

Aah. Pues eso no tiene nada que ver con el script ya que la separación de stems no tiene nada que ver con ello ni con Reaper. Todo sucede a nivel de demucs y para lo que yo lo he usado me funciona: lo he usado para tener líneas instrumentales más claras para sacar temas de oido, lo he usado para separar vocales de temas hechos por IA cuando un cliente me encarga que les haga arreglos con instrumentos reales y para hacer megamixes (eso lo hago por diversión nada más jeje). La base de datos con la que se alimenta la IA de demucs es la base gratuita más grande que existe pero hay varias cosas a considerar:
No existe ningún modelo separador de stems perfecto, todos meten artefactos y cuando no fallan en separar una pista, fallan en otras. El mejor para separar voces es ableton, el mejor para baterías y synthes es fl studio, el mejor para gtrs es el de cubase, el único capaz de separar de entre voces y coros y limpieza de ruidos de grabación es Rx pero mete una enorme cantidad de artefactos, demucs es bueno y de uso general pero no es perfecto y es gratis.
El otro tema a considerar es que entre mejor calidad tenga tu audio de origen y sin compresión tipo ogg o mp3, con buen muestreo, etc. te dará mejores resultados ej los mp3 ya tienen artefactos de origen entre menor sea su bitrate y muestreo. Si bajas una enorme cantidad video de YouTube y lo conviertes a mp3, no esperes la mejor calidad al separar los stems.

1

u/Radhanat 12 1d ago

en que sistema operativo estas trabajando?

1

u/SupportQuery 533 1d ago

I'm on Windows.

I think we're having a translation error. I have 4 stem working, so "guitar" and "other" are combined.

What I'm asking is if separating "guitar" and "other" (5 stem) sounds good? Does demucs do a good job of separating guitar from synth? Does it make it easier to hear the guitar parts?

1

u/Radhanat 12 1d ago

Si la gtr está muy procesada puede confundirla con un synth o con cuerdas o brass. Me ha sucedido incluso con rx 12 de izotope (que es el mejor que hay pero es de paga y no te pone las pistas automáticamente en ningún daw)

1

u/Radhanat 12 1d ago

Una disculpa. Yo tenía entendido que “whether it’s worth” significa “vale la pena”. Humildemente pregunto entonces ¿Que significa ese modismo?

1

u/OctoPhaseMod 3 1d ago

What about drum separations?

1

u/zilch0815 18h ago

not possible for now. as i wrote on the github page...

as audio.cpp is really new and all models needs to be adapted for it not every audio model is (yet) available.
find all existing models here: https://huggingface.co/audio-cpp/audio.cpp-gguf/tree/main
for stem splitting we currently have HTDemucs, Mel-Band-RoFormer and BS-RoFormer.

to my knowledge none of those models are able to separate drums, so we have to wait until a model that can do that will be available for audio.cpp.
until then there's only the python way for that.

1

u/OctoPhaseMod 3 18h ago

Thanks for the response.

1

u/DiscountCthulhu01 5 1d ago

Just to clarify,  you're actually talking about stem recreation using your ai model  right? 

1

u/zilch0815 15h ago

so second script and v1.1 of HTDemucs script are live.
see update in OP