r/PowerShell 4h ago

Script Sharing Remixing Music with RoughDraft and PowerShell

This weekend I figured out how to remix music with PowerShell, RoughDraft, and ffmpeg.

Sample + Filter.

Rinse & Repeat.

RoughDraft + ffmpeg makes this all pretty easy.

Step 1 - Get Your Sample Source

RoughDraft includes an extension for yt-dlp. This can download media from almost anywhere. Just browse to a site with a song, set a $SongUrl variable, and download

Get-Media -MediaUrl $MediaUrl

Step 2 - Sample a Section

You can sample a section of audio or video with the -AudioTrim and -Trim filters. If we want the first few seconds of a song, we can use the AudioTrim filter, like so:

$sample = Edit-Media $song -AudioTrim -TrimStart "00:00:00" -TrimEnd "00:00:05"

Step 3 - Filter

ffmpeg is full of filters. There are hundreds of them, and RoughDraft supports a fair number.

Suppose we want to make our sample Vibrato. We can just use Edit-Media -Vibrato

$sample | Edit-Media -Vibrato

Or we could change the -PitchFactor, making it sound slower or faster while keeping the tempo intact.

$sample | Edit-Media -PitchFactor 0.81

Or we could use an Audio Compressor, with a short attack and release and a makeup to make the sounds louder

$sample | Edit-Media -Compressor -CompressorAttack 5 -CompressorRelease 10 -CompressorMakeup 2.5

Rinse and Repeat

The possibilities are endless. ffmpeg is an audio/video production tool of truly unparalleled capability.

All of that power is in your shell, in a format that's far easier to read and understand than direct filtergraph syntax. Edit-Media currently has a whopping 682 parameters to mix and match, all supporting tab completion.

This makes it easy to iterate and innovate. It took just about an hour after figuring this out to make my first little remix, just by sampling/filtering/rinsing/repeating.

The latest RoughDraft release includes a bunch of new audio filters to help assist and more will keep on coming with every release.

Hope this helps & Have Fun!

4 Upvotes

6 comments sorted by

2

u/David2667 4h ago

This is insane lmaoo im going to try this

1

u/StartAutomating 4h ago

Yeah it kinda is.

I was listening to a track and only wanted the "epic" part, and then the lightning bolt of inspiration hit.

"This is what a Remix is"

About an hour later and the concept had been proven. It might not be a good remix, but it is indeed a remix. Produced entirely from the command line. With a tool I first wrote 14 years ago.

🤔 Could have had a whole music catalog by now... 😔

2

u/stihlmental 3h ago

Noice... but can I remove the singers voice from a song?!

1

u/StartAutomating 3h ago

Honestly I'm sure there are ways to do this with ffmpeg but I haven't yet found the perfect sweet spot.

Believe me, once I do, I'll put it into the module.

Using dynamic equalizers gets you some of the way there, and I'm pretty sure you could make an advanced audio expression to do it.

So: no, not as reliably as I'd like, not yet. But when I do, it goes into toolbox. If you have any combination of open-source CLI tools that do the trick, I'll write an extension for it (or you can open a PR)

1

u/liquidcloud9 3h ago edited 1h ago

It may not be what you're looking for, but the Koala app on iOS and Android is like $5 and is a really fun and capable sampler. I think it may be another $5 for the Samurai expansion, which lets you do the stem separation, and isolate drums, bass, vocals, etc.