# Any recommendations for a tool to....



## Lindon (Aug 25, 2012)

OK, a bit off topic but as I'm doing this to eventually end up in Kontakt...

Anyone know of a good (batch preferably) tool to split audio. Specifically I need to split a few hundred audio files of variable lengths. I need to split each file into 32 separate files each 1/32nd of the original file. 

Normally I'd just do this in Kontakt but there are so many and I need them external to Kontakt to do some pre-processing on them.

I cant get this to work in SoundForge or WaveLab...:-(

L


----------



## Daryl (Aug 25, 2012)

I'm not clear exactly what you want to do. It sounds like:

1) One long audio file
2) Split it up into various lengths. This can't be automatic, unless you know in advance what these lengths are.

I didn't understand the rest of it. If you could give a slightly more full explanation, it might be easy to come up with a solution. For example with a bit of preparation, you could use hitpoints and slice in Cubase.

D


----------



## mk282 (Aug 25, 2012)

Try Reaper. It has a lot of options for splitting items, and batch renderer with wildcards.


----------



## Ozymandias (Aug 25, 2012)

Reaper can probably do most of this, but I suspect you would have to write a bit of Python, or else modify someone else's script. Here's one which does something similar: 

http://forum.cockos.com/showthread.php?p=987314

The only thing I'm not sure about is matching your 32 segment grid (for splitting) to audio files of an arbitrary length. I've no idea how you would automate something like that.

It would be cool to see a solution, though, as it's an interesting problem.


----------



## Daryl (Aug 25, 2012)

The splitting is easy. It's the arbitrary length that will cause the problem. There are ways round this, but it requires a bit of prep whilst recording the samples.

D


----------



## Ozymandias (Aug 25, 2012)

Here are a few useful Reaper actions for the arbitrary length part of this problem:







Here they are in action:

http://i.imgur.com/Mp3Na.gif

You need to input a time signature, so that part would need automating to use this in a batch process.


----------



## Lindon (Aug 25, 2012)

OK, sorry let me clarify.

I have 500 files, all are 4-bars long, some are 120 bpm (about 200 files are in this tempo) some are 128 bpm (100), some are 140 bpm etc. etc..

I want to take each file and divide it into 32 separate files each division would be 1/32nd (essentially a 1/8th beat) of the existing file length.

So some fiddling about would be fine


----------



## Tod (Aug 25, 2012)

Lindon @ Sat Aug 25 said:


> OK, sorry let me clarify.
> 
> I have 500 files, all are 4-bars long, some are 120 bpm (about 200 files are in this tempo) some are 128 bpm (100), some are 140 bpm etc. etc..
> 
> ...



I agree that Reaper would suit this fairly well. I just ran a test with a 4 bar audio file and it took less than two minutes to split and render 32 audio files from it all numbered 01, 02, 03,.......to.......32. That included renaming them. 

Actually that was the second try, the first try it took about 15 minutes because I had to find the action to do it with and setup the items.

However, the second try actually took less thatn 1.5 minutes.  

If you want to give Reaper a try check into the Reaper forum and post what you want to do, there are a lot of knowledgeable people there that would be glad to help you out. 

http://forum.cockos.com/forumdisplay.php?f=20


----------



## Mike Greene (Aug 25, 2012)

Rather than trying to automate this, I think I would just put all the 120bpm files onto their own tracks, select all of them (so they line up,) then scissors tool them all on the 16th notes, 32 times. Pretty fast and easy.

For the next step of making each of these into their own audio files on disk, in ProTools, there a key-command for consolidating regions. (Option-shift-3 or something like that.) The autonaming method this command uses is perfect. It just takes the track name, then adds 1, 2, 3, etc each time you select the next region on that particular track. Granted, this is a lot of regions that each have to be done one at a time, but the key command is all that's involved, so it's mindless and easy.

I think it would be reasonably quick. Not elegant, and this doesn't answer your question (and I don't have Reaper,) but I find I often spend more time trying to get fancy, rather than just plowing through manually. Just a thought.


----------



## rgames (Aug 25, 2012)

Probably not helpful but you can do what you want in Matlab...

Find an engineering/science student - he'll have access to Matlab - and give him $50 to do it. It's pretty simple to read in the files and split them up like you want in Matlab. You can even get smart and make the algorithm search for zero crossings in the vicinity of your precise split.

rgames


----------



## Tod (Aug 25, 2012)

I made some LICEcaps to show how easy it can be using Reaper's regions. Forgive me, I'm not real good at making these but I think you'll get the picture. Notice that I used the menu for much of it but ordinarily I would have used shortcut keys.

In this first one I show setting up to make the regions using empty midi items or clips.
http://dl.dropbox.com/u/63198126/00%20Public%20Folders%202/05%20Split-Rename%20Samples%20using%20Regions%201/01%20Set%20up%20for%208th%20note%201.gif (http://dl.dropbox.com/u/63198126/00%20P ... te%201.gif)

This one shows rendering all 32 split items so they end up in a folder of my choosing in sequential order. 
http://dl.dropbox.com/u/63198126/00%20Public%20Folders%202/05%20Split-Rename%20Samples%20using%20Regions%201/02%20Split%20and%20Save%20Files%201.gif (http://dl.dropbox.com/u/63198126/00%20P ... es%201.gif)

This last one shows renaming the split files using a free little program called Rename Master.
http://dl.dropbox.com/u/63198126/00%20Public%20Folders%202/05%20Split-Rename%20Samples%20using%20Regions%201/03%20Rename%20Files%201.gif (http://dl.dropbox.com/u/63198126/00%20P ... es%201.gif)




Mike Greene @ Sat Aug 25 said:


> Rather than trying to automate this, I think I would just put all the 120bpm files onto their own tracks, select all of them (so they line up,) then scissors tool them all on the 16th notes, 32 times. Pretty fast and easy.



That could be done using the regions the way I showed it in Reaper too. Just stack the samples on several tracks so they line up. You'ld have to add another wild card for track numbers but it should work


----------



## mk282 (Aug 26, 2012)

rgames @ 26.8.2012 said:


> Probably not helpful but you can do what you want in Matlab...
> 
> Find an engineering/science student - he'll have access to Matlab - and give him $50 to do it. It's pretty simple to read in the files and split them up like you want in Matlab. You can even get smart and make the algorithm search for zero crossings in the vicinity of your precise split.
> 
> rgames




No need to pay someone $50 when this can be done in minutes in free Reaper trial.


1. New project
2. Set tempo to 120
3. Import files with BPM 120 in the project, each file in new track (before that, set *Properties->Media->When importing multiple media items: [Insert across tracks]*)
4. Set grid to 1/32
5. Select all items and run action "Item: Split items at timeline grid"
6. With all items selected, now you can batch export them with wildcards (File->Batch file/item converter).


Repeat procedure with files in other tempos the same way.


----------



## Tod (Aug 27, 2012)

mk282 @ Sun Aug 26 said:


> No need to pay someone $50 when this can be done in minutes in free Reaper trial.



I might add, the trial doesn't run out and there's no restrictions of any kind. All you get is a little nag screen when you open Reaper.



> 1. New project
> 2. Set tempo to 120
> 3. Import files with BPM 120 in the project, each file in new track (before that, set *Properties->Media->When importing multiple media items: [Insert across tracks]*)
> 4. Set grid to 1/32
> ...



Yes that also works pretty well mk282, however don't you mean "Set grid to 1/8"? If you set it to 1/32 you'll get 128 files over the 4 bars. 

Also the split items end up a little longer front/back and have crossfades. At least that's what happens for me, maybe there's some settings somewhere? 

One thing about using regions is the ability to adjust the front and back midi items. For instance it might help to adjust the front to catch the attack a little better, or adjust for the back if it's a little long or short.


----------



## mk282 (Aug 28, 2012)

Tod @ 27.8.2012 said:


> Yes that also works pretty well mk282, however don't you mean "Set grid to 1/8"? If you set it to 1/32 you'll get 128 files over the 4 bars.




Right, right. Correct! Brainfart moment over here 



Tod @ 27.8.2012 said:


> Also the split items end up a little longer front/back and have crossfades. At least that's what happens for me, maybe there's some settings somewhere?



Yes, disable the settings *Properties->Project->Media item defaults->Create automatic fade in/out for new items*, and *Overlap and crossfade items when splitting*


----------



## Lindon (Aug 28, 2012)

OK, great thanks guys looks like I should get a copy of Reaper as a first step ...thanks for all your efforts.
Lindon


----------



## kotori (Aug 31, 2012)

Hi Lindon,

I wrote a little python script for you to achieve this:


```
import glob, wave, os.path

num_split_parts = 4

for path in glob.glob(os.path.join('input', '*.wav')):    
    f_in = wave.open(path, 'r')    
    for i in range(num_split_parts):
        filename_in = os.path.basename(path)
        filename_out = '%s_%d.wav' % (os.path.splitext(filename_in)[0], i)
        print '%s -> %s' % (filename_in, filename_out)
        data = f_in.readframes(f_in.getnframes() / num_split_parts)                
        f_out = wave.open(os.path.join('output', filename_out), 'w')
        f_out.setparams(f_in.getparams())
        f_out.setnframes(0)
        f_out.writeframes(data)
```

Usage:
1) place the samples inside a folder called "input"
2) create an empty folder next to it and call it "output" (the new files will be saved here)
3) save the python code above to a file called "splitwav.py" next to the other two folders
4) run the script by typing "python splitwav.py" on the command line

If you want to make a dry run first you can comment out the last four lines of the python script by prefixing them with a # character.

Cheers,
Nils


----------



## Big Bob (Aug 31, 2012)

Hey Nils,

Great to see you 'coming up for air' again :lol: 

Does this mean that the KSE V152 Find/Replace options will be working again soon? Sure miss those. Every thing else seems to be working fine and I've given it some pretty serious use. 8) 

Rejoice,

Bob


----------



## Lindon (Sep 3, 2012)

Hey Nils,

Good to hear from you again, thanks for the python script...I'll give it a go. Looks like I'll have to get into python scripting too...

L


----------

