PDA

View Full Version : how to use a file to animate keys on synthesizer ?


Dmaxer
05-12-2005, 07:02 PM
I have a model of a synthesizer I have made with 71 keys on it , I need to animate all the keys with a midi file , so far I have found a small program that will convert the midi data to a txt file and this gives the output format you can see below





25 On ch=1 n=37 v=14

so this means 25= frame number , On = note , ch=1 = channel number , n=37 = note number , v=14 = volume




I need to make a script to read the file and do some thing like this



A; get frame number and set 3dmax time slider to same frame number and turn on animate



B; is it on Ch= 1 ? if no then don’t use ,move to next line go back to A , if yes then read rest of line



C; read n= and select same number Key object in scene



D; read volume if 0 then move key object back up to start angle , if >0 then move key to down angle

Any help with this would be great as I dont know where to start
could someone show me a bit of script to read a txt file in this format ?
or do you know of a good script tutorial I could use online that will cover some thing like this , so far I have not found anything :(

Thanks for Reading

Dmaxer
05-13-2005, 10:56 AM
is there no one that can help me make a start on this ? I think I will be ok once I got the script reading the file , so far Ive readup on "FileStream" am I right in saying this is the command I need to use , what I dont understand is where are my varables will be stored from the file once Ive read the file ? .and how do I get it to read the next line ? could some one show me a bit of code I could use to text the reading of a txt file ? ..
Thanks for reading guys

Dmaxer
05-13-2005, 12:12 PM
rot_keyd = eulerangles 0 30 0
rot_keyu = eulerangles 0 -30 0
rotate mybox rot_keyu

this will work but Im not sure how to put in into this Example script , Im goin to keep at it .and see what I come up with ..

ok I found this script in \scripts\Examples\Examples . could someone show me how I would change this so it just rotates and object ,, I tried using this ;

pos = [0.0,0.0,0.0]
f = openfile ("ascii.dat")

if f == undefined do

(

local fname

MessageBox "Could not find ascii.dat. Please point locate the file"

fname = getOpenFileName caption:"Locate ascii.dat" filename:"ascii.dat"

if fname != undefined then

f = openFile fname

)

if f != undefined then

(

while (not eof f) do

(

pos.x = readvalue f; pos.y = readvalue f; pos.z = readvalue f;

format "%\t%\t%\n" pos.x pos.y pos.z

tea = cylinder radius:10 height:40 pos:pos

)

close f

max tool zoomextents all

)
I will work this out in the end .. I hope :)

CGTalk Moderation
05-13-2005, 12:12 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.