[Closed] Gathering names and creating files
Here is what I want to script out.
- Take the names of each sound track (I will manually load up and arrange sound files using BoomerLabs SoundTrax plugin) and create a batch render list.
- Each sound file would name the renders and the length of the sound file would determine how many frames are rendered.
- The renders need to be saved into their own renders folder, and each set of renders needs to be saved in its own folder and that folder needs to be named the same as the sound file.
Would this be too complex for a first project? I’m fairly new to writting MaxScripts from scratch. In the past I have altered scripts to add functions I needed and I think I’m ready to tackle my first project from scratch and what better way then to fill a need I have?
Mark D.
That would depend on how this SoundTrax plugin works. I took a look at the plugin website, and it looks like they have a good number of maxscript methods implemented in the plugin. Provided that they have enabled the ability to get the information from the plugin, then parsing that into renders and files and directories would not be too difficult, though it would require that you learn the file IO methods in Maxscript as well as some basic rendering methods.
It would probably take me a day or so to do, providing that the SoundTrax plugin reveils enough to maxscript. So if I didn’t know much maxscript, if any at all, it might take about a week to develope it. If you post your questions here, it could go much faster too.
Here’s some things to look into:
In the Maxscript help file, look up the topics labeled :
External File Methods
Controlling the Renderer
The plugin is likely to use some of the information in the topic labeled:
Trackviews
When it comes down to it, there are a series of problems. I will tell you that the ability to control the renderer, and create the files and directories will be failry easy. It’s pretty straight forward. The other problem is larger, in that it is an unknown. It’s possible that the plugin has easy methods for getting the needed data, but if it doesn’t, then it could involve alot of string parsing using format and stringstreams and such, but in the end the tool seems to be very doable and with help from the community could be a neat first maxscript project.
-Dave
Excellent post, it couldn’t come at a better time, I was just about to start on creating external files. I spent yesterday figuring out a way to pull the needed info out of the plug-in from the max side I almost gave up, all it would ever retrieve was the first sound file. As it turns out this is pretty easy to do and something BoomerLabs documented well at the end of their help file, naturally the last place I thought to look for help. heh =)
Now I just need to research what you talked about, and parse the info into a useable format. Thanks for the nudge in the right direction. =)
Posting my modest progress.
Updated Script Below
It won’t do too many people any good right now. The most useful thing it does it check for sound files and prompts you to launch SoundTrax if none are loaded. I have it printing the sound file names and the number of frames. I think I need to figure out how to get that into an array so I can use that info later. I also have to figure out how to strip the path and extention from the file name. That’s tomorrows project =)
If you see anything that can be done better, easier or different please speak up. Any pointers on how to arrange the chunks of code using tabs would be helpful. I kind of made it up as I went because I couldn't find a "standard" way to indent, I'm not sure if there is one?
Quick post:
getFileNamePath
getFileNameFile
getFileNameType
They each take a path string and return the portion you want. Easy! Look them up in the ref for more info.
For instance:
thePath = "c:\ est\\poop.dds"
getFileNamePath thePath --returns "c: est\"
getFileNameFile thePath --returns "poop"
getFileNameType thePath --returns ".dds"
-Dave
Thanks again for the help =) I have a few issues =/
The function used to call the track path/name is soundtrax.name(#). # = track number. It recalls the full path, I want just the name in an array. If I try to pharse the file name using
getfilenamefile soundtrax.name(1)
I get
Argument count error: getFilenameFile wanted 1, got 2
It has a problem with the “(1)” which is needed by SoundTrax so it knows what track to get.
If I create a loop like this;
tracks = soundtrax.numtracks()
trackframes = for i = 1 to tracks do
(
frange = soundtrax.filelength(i)
if (frange != “”)
then print frange
)
I get an array “trackframes” but all it returns is [color=Blue]OK[color=#fffffe]. I guess it’s not an array?
Is there something I’m missing, is there another way to create the loop?
If anyone is interested in giving the plug-in a try. BoomerLabs has a Demo of the plug-in available. It will allow up to 4 tracks. The full version allows 100.
http://www.boomerlabs.com/cart/product.php?productid=4&cat=2&page=1
click the “download demo” link on the upper right side of the page.
[/color][/color]
Try:
getfilenamefile (soundtrax.name(1))
And get back to me. If that doesn’t work, simply do this:
stxName = soundtrax.name(1)
getfilenamefile stxName
-Dave
Try :
getfilenamefile (soundtrax.name 1)
I think you’ve missed collect keyword :
tracks = soundtrax.numtracks()
trackframes=for i=1 to tracks do collect (soundtrax.filelength i)
Well that explained quite a bit, thanks for the help guys! That part is fixed.
EDIT: A good nights sleep and I saw my previous problem. As well as some useless code I was using.
I have 60% of the script functional, the portion using soundtrax is complete, but there might be an easier less code heavy way to handle it. Right now I have a block of code for each track. And it creates an array for every track. I’m pretty sure that I can condense it down to 1 block using an if/then. Since the only thing that changes from block to block is the track number. But right now it works, and I’m pleased with it even if I only have 4 tracks working, and its a bit fugly, but it works! If I can clean it up I will.
Any pointers on cleaning this up and getting one block of code to spit out arrays would be greatly appreciated since I would have to enter in 96 more blocks so I can use all 100 tracks.
--StxTrack1
(
t1name = getfilenamefile (soundtrax.name(1)) --Gathers sound file name
t1leg = soundtrax.filelength(1)as integer/320 --Gathers track length
( --Resets the track to frame 0
t1f = soundtrax.filelength(1)as integer/320
soundtrax.setstart 1 0
soundtrax.setend 1 (t1f)
)
t1startf = soundtrax.start(1)as integer/320 --Regathers the new start frame
t1endf = soundtrax.end(1) as integer/320 --Regathers the new end frame
StxTrack1 = #(t1name, t1leg, t1startf, t1endf) --Track array to be used later.
)
--StxTrack2
(
t2name = getfilenamefile (soundtrax.name(2)) --Gathers sound file name
t2leg = soundtrax.filelength(2)as integer/320 --Gathers track length
( --Resets the track to frame 0
t2f = soundtrax.filelength(2)as integer/320
soundtrax.setstart 2 0
soundtrax.setend 2 (t2f)
(-- Shift track 5 frames after previous track
soundtrax.shift 2 (StxTrack1[4] +5)
)
)
t2startf = soundtrax.start(2)as integer/320 --Regathers the new start frame
t2endf = soundtrax.end(2) as integer/320 --Regathers the new end frame
StxTrack2 = #(t2name, t2leg, t2startf, t2endf) --Track array to be used later.
)
--StxTrack3
(
t3name = getfilenamefile (soundtrax.name(3)) --Gathers sound file name
t3leg = soundtrax.filelength(3)as integer/320 --Gathers track length
( --Resets the track to frame 0
t3f = soundtrax.filelength(3)as integer/320
soundtrax.setstart 3 0
soundtrax.setend 3 (t3f)
(-- Shift track 5 frames after previous track
soundtrax.shift 3 (StxTrack2[4] +5)
)
)
t3startf = soundtrax.start(3)as integer/320 --Regathers the new start frame
t3endf = soundtrax.end(3) as integer/320 --Regathers the new end frame
StxTrack3 = #(t3name, t3leg, t3startf, t3endf) --Track array to be used later.
)
--StxTrack4
(
t4name = getfilenamefile (soundtrax.name(4)) --Gathers sound file name
t4leg = soundtrax.filelength(4)as integer/320 --Gathers track length
( --Resets the track to frame 0
t4f = soundtrax.filelength(4)as integer/320
soundtrax.setstart 4 0
soundtrax.setend 4 (t4f)
(-- Shift track 5 frames after previous track
soundtrax.shift 4 (StxTrack3[4] +5)
)
)
t4startf = soundtrax.start(4)as integer/320 --Regathers the new start frame
t4endf = soundtrax.end(4) as integer/320 --Regathers the new end frame
StxTrack4 = #(t4name, t4leg, t4startf, t4endf) --Track array to be used later.
)
What this script does:
I’m writting this script to help lip sync many sound tracks to a character.
It sequences the sound files one after another, giving each file a 5frame buffer. It then creates an array with the (track name, #of frames, start frame, end frame). It will later use that array to: create folders, create or append an excel doc, create a project folder structure and lastly render out the scene saving each track to its corisponding folder.
In short it does the administrative things of my job that keep me from the fun stuff, animating body poses and facial expressions.
What’s left to do:
- Finish writing the project folder creation code
- Start and finish the rendering code
- Create a UI
Plans to grow the script:
- I plan to grow the UI with another rollout, this would have a listbox that lists each track and when the track is clicked it sets the active time segment to the length of the track.
- I want to be able to let the user set the track padding, as well as set the length of each track so animations can have some wind up/down time when returning to a root pose.
- I would like it to paste a bi-ped root pose and clear morph target data at the start and beginning of each track. Once Max2008 gets here bi-peds will store “Xtra” bones attached to it in the copy/paste pose info and I might be able to use bones as a facial rig instead of making morphs. The advantage of bones would be I can transfer the animations from character to charcter, with morphs I can not.
Anywho back to work… =)