Extracting data from filename (help me optimize this small chunk of code)

Jul 7, 2012 at 4:39pm

Extracting data from filename (help me optimize this small chunk of code)

Rather than using some fancy msp ways to detect the bpm of some of my loops, I chose to include the exact bpm in the filename and now I am extracting it when I load the file to my buffer. However, I am wondering if there’s a way to do it with less objects.

I know the bpm is written in the 5th, 6th and 7th character from the right, so after converting my filename into a list, I revert it and select these 3 characters. If the filename has no bpm, these characters won’t be number so in the end I get 0, I will make sure receiving a 0 there will turn off the bpm sync.

So yeah, I think this patch works fine but I am wondering if I could make it shorter / more efficient.

Thanks.

– Pasted Max Patch, click to expand. –
#37952
Jul 7, 2012 at 5:08pm

Hello,

may be improved by regular expression guru ;-)

– Pasted Max Patch, click to expand. –
#131443
Jul 7, 2012 at 5:53pm

Wow!

This is incredible. I see that you find the underscore and the .wav and just output what’s inbetween.

I gotta learn how to do that haha! thanks.. I’ll get started with regexp!

#131444

You must be logged in to reply to this topic.