Last active
September 2, 2015 21:15
-
-
Save TheBlackParrot/433ae0cda00c280f8118 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$notes = explode(" ", "NC NCS ND NDS NE NF NFS NG NGS NA NAS NB"); | |
$inst = "SteelDrum"; | |
$start_octave = 2; | |
$preview = 1; | |
$location = "/tmp"; | |
$dir = new DirectoryIterator($location); | |
foreach ($dir as $fileinfo) { | |
if($fileinfo->isDot()) { | |
continue; | |
} | |
if($fileinfo->getExtension() == "wav") { | |
$fullname = $fileinfo->getFilename(); | |
$filename = substr($fullname, 0, stripos($fullname, ".")); | |
$channel = substr($filename, stripos($filename, "-")+1); | |
//str_replace(search, replace, subject) | |
$note = str_replace("N", ceil($channel / 12)+($start_octave-1), $notes[($channel-1) % 12]); | |
echo "$filename --> {$inst}_{$note}\n"; | |
if(!$preview) { | |
exec("mv $location/$fullname $location/{$inst}_{$note}.wav"); | |
} | |
echo("mv $location/$fullname $location/{$inst}_{$note}.wav\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment