Not long ago I released a new and unconventional Imphenzia track named "Time Travel" - check out the video of the track:
This track rocketed to the #1 chart at soundclick.com and it also received great feedback on facebook. It is, however, a very different style compared to most other Imphenzia tracks released in the past.
The track, the feedback, and some recent expansion pack purchases for Nexus got me inspired to create more music.
I've decided to publish the scripts that I use to watermark and encode music audio files into MP3 and OGG files with meta tags. I hope this will help someone out there who needs to frequently watermark and/or encode audio files into WAV, MP3 and OGG files at different bit rates.
Maybe the simplest way to start off is to demonstrate how the scripts work with this video:
This is a VBScript that will loop through a directory full of WAV audio files and mix them with watermark audio files. The script uses the free application Sound eXchange (SoX) to achieve this.
The script is also designed to take the duration of the audio file to be watermarked and apply a watermark with a suitable frequency.
Shorter audio files will be watermarked frequently and longer audio files will have less frequent watermarks to make it less annoying.
You can customize the watermark files to contain anything you want. If you want to change the name or format of them you'll have to modify the script appropriately.
You can download the entire script package and demo files at the top of this post, but if you wish to have a look at the script itself, here it is:
' This VB script uses Sound eXchange (SoX) (http://sox.sourceforge.net) to ' create watermarked WAV files.
' Based on the duration of the WAV files you wish to watermark, the script ' will select a suitable frequency of the watermark. By default the following ' logic is applied: ' 0-5 second music file: watermark occurs every 2.5 seconds ' 5-15 second music file: watermark occurs every 5 seconds ' 15-30 second music file: watermark occurs every 10 seconds ' 30-1200 second music file: watermark occurs every 30 seconds ' > 20 minutes files are not supported - change the script if necessary.
' 1. Put your original WAV files that you wish to watermarked in the ' subfolder "input-wav-originals"
' 2. Execute this script and it will create watermarked WAV files in the ' subfolder "output-wav-watermarked"
' ## CHANGING THE WATERMARK ###################################################
' The default watermark says the word "preview" at different intervals ' depending on the duration of the WAV file. You can change the watermark ' audio files but I recommend that you keep the name and ogg format of the ' watermark files so you don't have to modify the script.
' To change the watermark, replace the audio in the watermark files. Use ' trial and error to find a suitable volume (I recommend peaks at around ' -8 dB) and frequency of the watermark.
' ## LICENSE ################################################################## ' You're free to use this script and the watermark OGG files free of charge. ' If this script saves you a lot of time, a donation to [email protected] ' is very welcome =)
' SoX is a free application available at the URL in the description. This ' script is very dependent on the exact output SoX generates to read ' information so a version of SoX is included in the archive.
' (You may not sell the script or any of the files)
Dim source_folder, destination_folder Dim watermark_folder, watermark_file, log_filename
' ## CUSTOMIZABLE VARIABLES ################################################### source_folder = "input-wav-originals" destination_folder = "output-wav-watermarked" watermark_folder = "input-watermarks" log_filename = "watermark-log.txt" ' Filename for log file (overwritten) use_volume = true ' Watermark volume based on original
' You shouldn't need to edit any of the below script ' -----------------------------------------------------------------------------
Dim wshshell, filesys, folder, files_collection, filecount, filename Dim outputfile, logoutput, duration, volume, volumedecimal, n
' ## Create Filesystem Objects Set wshshell = WScript.CreateObject("WScript.Shell") Set filesys = CreateObject("Scripting.FileSystemObject") Set folder = filesys.GetFolder(source_folder & "\.") Set files_collection = folder.Files Set logoutput = filesys.OpenTextFile(log_filename, 2, True)
' ## Ensure that the output directory exists, if not then create it if not filesys.FolderExists( destination_folder ) then _ filesys.CreateFolder destination_folder
' ## Loop through all original wav files filecount = files_collection.Count for each file in files_collection filename = file.name if lcase(right(filename,4))=".wav" then
' ## If a watermarked version does not exists, create one if not filesys.FileExists( destination_folder & "\" & filename ) then
' ## Select appropriate watermarked file based on duration of source file duration = CLng(runCMD("sox --info -s """ & _ source_folder & "\" & filename & """"))
if duration <= 220500 then _ watermark_file = watermark_folder & "\preview-0-5sec.ogg" if duration > 220500 and duration <= 661500 then _ watermark_file = watermark_folder & "\preview-5-15sec.ogg" if duration > 661500 and duration <= 1323000 then _ watermark_file = watermark_folder & "\preview-15-30sec.ogg" if duration > 1323000 then _ watermark_file = watermark_folder & "\preview-30-1200sec.ogg"
' ## If volume is used, set volume based on amplitude of source wav file if use_volume then volume = runCMDAlt("sox """ & source_folder & "\" & filename & _ """ -n stat") volume = mid(volume,123,8) volumedecimal = CDbl(replace(volume, ".", ",")) else volumedecimal = 1.0 end if
if n=0 then wscript.echo "No Files Created " & vbCrLf & _ "If watermarked files already exist they are not recreated" else wscript.echo "Done! " & vbCrLf & n & " Watermarked File(s) Created " end if
' Supporting function to capture the output of command line function runCMD(strRunCmd) Set objExec = wshshell.Exec(strRunCmd) strOut = "" Do While Not objExec.StdOut.AtEndOfStream strOut = strOut & objExec.StdOut.ReadLine() Loop runCMD = strOut End Function
' Supporting function to capture error output (workaround) Function runCMDAlt(strRunCmd) Set objExec = wshshell.Exec(strRunCmd) strOut = "" strOut = objExec.StdErr.ReadAll() runCMDAlt = strOut End Function
Encode_files.vbs Explained
This is a script that will loop through two directories, one full of original WAV audio/music files and one full of watermarked WAV files (if you previously ran the Create_watermarks.vbs script). As the script loops through all the available WAV files it will encode them into MP3 and OGG files and also update the meta tags containing information such as title, artist, publisher, copyright info, comments, URL, etc.
The script is designed so that you can enter meta tags and customize bit rate that you wish to encode your files with. Once you've got this running you can quickly re-encode your files into any bitrate or modify the meta tags without having to do it all manually.
You can download the entire script package and demo files at the top of this post, but if you wish to have a look at the script itself, here it is:
' 1. Ensure that the WAV files in the "input-wav-originals" folder and the ' "output-wav-watermarked" folders contain files named according to the ' following naming standard: ' Arist Name_Song Name_Music Genre_Year ' Example: ' Imphenzia Soundtrack_Fog of War (Main Part Loop)_Orchestral_2011.wav
' 2. Customize the encoding bitrates for the original and watermarked MP3 ' and OGG files (see CUSTOMIZABLE ENCODING BITRATES)
' 3. Customize the MP3 and OGG meta tags (see CUSTOMIZABLE MP3 and OGG TAGS)
' 4. Double click on the script to begin the encoding process. The script ' will create MP3 and OGG files in the appropriately named output folders.
' You're free to use this script and the watermark OGG files free of charge. ' If this script saves you a lot of time, a donation to [email protected] ' is very welcome =)
' This script uses the following freeware and/or open source applications: ' lame.exe - http://www.mp3dev.org ' metamp3.exe - http://www.hydrogenaudio.org/forums/index.php?showtopic=49751 ' oggenc.exe - http://www.rarewares.org/ogg-oggenc.php ' tag.exe - http://wiki.hydrogenaudio.org/index.php?title=Tag_(tagger)
' (You may not sell the script or any of the files)
Dim source_folder, source_watermarked_folder Dim destination_mp3_original, destination_mp3_watermarked Dim destination_ogg_original, destination_ogg_watermarked Dim mp3_original_bitrate, mp3_watermarked_bitrate Dim ogg_original_bitrate, ogg_watermarked_bitrate Dim tag_encoder_name, tag_publisher_name, tag_copyright_name, tag_url Dim tag_composer_name, tag_comment, tag_album, tag_watermarked_prefix
' ## CUSTOMIZABLE ENCODING BITRATES ########################################### mp3_original_bitrate = "160" ' Bitrate in kbps mp3_watermarked_bitrate = "96" ' Bitrate in kbps ogg_original_bitrate = "128" ' Bitrate in kbps ogg_watermarked_bitrate = "64" ' Bitrate in kbps
' ## CUSTOMIZABLE MP3 and OGG TAGS############################################# tag_encoder_name = "ENCODER NAME HERE" tag_publisher_name = "PUBLISHER NAME HERE" tag_copyright_name = "COPYRIGHT HOLDER NAME HERE" tag_url = "http://YOUR URL HERE" tag_composer_name = "COMPOSER NAME HERE" tag_comment = "Encoded using script by http://soundtrack.imphenzia.com" tag_album = "TEXT FOR ALBUM FIELD HERE" tag_watermarked_prefix = "Preview: "
' You shouldn't need to edit any of the below script ' -----------------------------------------------------------------------------
' Ensure that cscript is executed instead of wscript - otherwise status ' messages will appear in popups instead of console window.
If LCase(Right(Wscript.FullName, 11)) = "wscript.exe" Then strPath = Wscript.ScriptFullName strCommand = "%comspec% /k cscript """ & strPath & """" Set objShell = CreateObject("Wscript.Shell") objShell.Run(strCommand), 1, True Wscript.Quit End If
Dim wshshell, filesys, folder, files_collection, filecount, filename Dim mp3counter, oggcounter, outputfile Dim tag_artist, tag_title, tag_genre, tag_year oggcounter = 0 mp3counter = 0
wscript.echo "Begin encoding process."
Set wshshell = WScript.CreateObject("WScript.Shell") Set filesys = CreateObject("Scripting.FileSystemObject")
' ## Ensure that the output directories exists, if not then create them if not filesys.FolderExists( destination_mp3_original ) then _ filesys.CreateFolder destination_mp3_original if not filesys.FolderExists( destination_ogg_original ) then _ filesys.CreateFolder destination_ogg_original if not filesys.FolderExists( destination_mp3_watermarked ) then _ filesys.CreateFolder destination_mp3_watermarked if not filesys.FolderExists( destination_ogg_watermarked ) then _ filesys.CreateFolder destination_ogg_watermarked
' ## Encode Original (non-watermarked) files ################################## Set folder = filesys.GetFolder(source_folder & "\.") Set files_collection = folder.Files filecount = files_collection.Count
for each file in files_collection ' ## Only process WAV files filename = file.name if lcase(right(filename,4))=".wav" then
' ## Set tags based on the filename ' ## Source File Name Format: Artist Name_Song Name_Music Genre_Year tag_artist = GetParam(filename,0) tag_title = GetParam(filename,1) tag_genre = GetParam(filename,2) tag_year = GetParam(filename,3)
' ## Create web friendly name for output file (artist-name-song-name) outputfile = WebFriendlyName(GetParam(filename,0) & " - " & _ GetParam(filename,1) ,0,0)
' ## Use Tag to create the ogg tag wshshell.Run "Tag.exe " & optstr & " """ & _ destination_ogg_watermarked & _ "\" & outputfile & ".ogg""",0,true
oggcounter = oggcounter + 1 end if end if next
' ## Finished - echo how many files were encoded if mp3counter + oggcounter = 0 then wscript.echo "No files were encoded." wscript.echo "If the output files already exist they are not overwritten." wscript.echo "Delete them first if you wish re-encode them." else wscript.echo "Encoding script reporting that all is done!" wscript.echo mp3counter & " mp3 files and " & oggcounter & " ogg files encoded" end if
' Supporting function that gets a parameter from a file name using the ' character _ as a delimiter Function GetParam(thestring, theparam) dim returnstring, currentparam for i=1 to len(thestring) if mid(thestring,i,1) = "_" then currentparam=currentparam+1 else if theparam = currentparam then returnstring=returnstring + mid(thestring,i,1) end if end if next if lcase(right(returnstring,4)) = ".wav" then _ returnstring=left(returnstring,len(returnstring)-4) GetParam = trim(returnstring) end function
' Ugly supporting function that washes the file name to a "web friendly" file ' name... I would use regexp for this but VBScript is quite limited by default. Function WebFriendlyName(filename, prefixlength, extlength) WebFriendlyName = lcase(filename) WebFriendlyName = right(WebFriendlyName , len(WebFriendlyName )-prefixlength) WebFriendlyName = left(WebFriendlyName , len(WebFriendlyName )-extlength) WebFriendlyName = replace(WebFriendlyName , " - ", "-") WebFriendlyName = replace(WebFriendlyName , "[", "") WebFriendlyName = replace(WebFriendlyName , "]", "") WebFriendlyName = replace(WebFriendlyName , "(", "") WebFriendlyName = replace(WebFriendlyName , ")", "") WebFriendlyName = replace(WebFriendlyName , ".", "") WebFriendlyName = replace(WebFriendlyName , " ", " ") WebFriendlyName = replace(WebFriendlyName , " ", " ") WebFriendlyName = replace(WebFriendlyName , " ", " ") WebFriendlyName = replace(WebFriendlyName , " ", "-") End Function
So far this week I have spent most of my hours awake either in traffic on my way to or back from work, or in work. The few hours I've had to spare at home I've put on composing exclusive music for the three game developers that have contacted me. I've also uploaded some more stuff to the Unity Asset Store and played some Modern Warfare 2. Today I reactivated my Eve Online account (free for 5 days) and the game is truly looking awesome but I simply won't have time to play it unfortunately.
First week of "normal" work following my paternity leave is now in the past and I am enjoying a very welcome weekend.
Motocross practice at Uringe
Today I spent a few hours at Uringe, a great sand track south of Stockholm, where I tried to improve my motocross skills. It went fairly well with only one minor crash but plenty of fun. Bike collected some sand as you can see in the picture below - quite easy to clean with the pressure washer though....
Making Exlusive Music for Three Games
I've also recently had requests to create exclusive music for three different games. Two games for the mobile platform (Android + iPhone) and one game is aimed at computers and consoles.
Quite exciting because the music needed is of very different genres and it's a lot of fun to let the creativity take over and see where it leads.
Astrofighter.Net
As for Astrofighter.Net I've managed to make slight progress here as well. I've imported the low poly ship versions into Unity and I'm currently placing all the thruster and weapon mount points. Next will be texture mapping the ships and adding script code for the remaining weapon types.
Today was my first day back in my "normal" job as an IT Security Consultant and I'm coming back from a 7 month long paternity leave. It is with mixed emotions that I return because I've really enjoyed spending the time with my family and it has also enabled me to focus a lot on Imphenzia Music/Soundtrack/Games. But then again, you have to earn a living...
Anyway, I've finished creating the 8 types of spaceships to be featured in the game ranging from a light scout to a heavily armored and well equiped beast. The 7 weapon types I'm considering for the game is Blaster, Cannon (Gatling Gun), Plasma Gun, Rail Gun, Laser, Missile Launcher, and Mortar. Here is a preview video:
Today I modeled the 8th spaceship and all the weapons. I created a low poly and a high poly version of each weapon so I can render "Normal" maps (bump maps) making the weapons appear to have a lot more polygons than they really do. I'll be doing the same for the spaceships as well.
Of course, the ships won't look like this in the game. These are just colored wireframe renders of all the prototype ships in low detail.
Top down view as they will be seen in the game (click for high res picture)
Here is a perspective view of the spaceships as well:
Finally, here is a detailed look at the weapons I created today:
Texturemapping these objects will take a lot longer than it took to model them. Each ship only took about 15-20 minutes each and the weapons took about the same amount of time. I can imagine it will take me a few hours to make the texture maps for each object though, ugh.