Jump to content

Sign in to follow this  
mrittman

Sound Track - Start Time

Recommended Posts

I'm guessing that although the time user data shows frames, it's converting that value into a c4d base time unit - similar to when you dial in degrees but XP converts them to radians.

 

If you want to use frames as time, make an integer user data and convert it to time as per 1st file

 

delay_secs = delay_frames / doc.GetFps()

 

you could just type in the fps, but beware integer division

 

10 / 30 = 0

10 / 30.0 = 0.333

 

etc

 

in 1st file, input port was real, so integer frames input was converted to float.

Share this post


Link to post
  • Topic Author
  • I think I got it using the Time data type!
     

    time = control[c4d.ID_USERDATA,1] # Time data type
    
    time_sec = c4d.BaseTime.Get(time) # Convert time into seconds

     

    Found this in the documentation: BaseTime.Get()

    Share this post


    Link to post

    you can also replace the RHS of

     

    t[c4d.CID_SOUND_START] = c4d.BaseTime(delay)

     

    with the time user data value

     

     

    Share this post


    Link to post
  • Topic Author
  • How would I write the python if Track Name was set to None? I want them all to be disabled if it's on none.

     

    I defined None as 0;None in my data type.

    none.png

    Share this post


    Link to post

    What data type is the track name ?

    Share this post


    Link to post
  • Topic Author
  • Oh sorry, it's set to Integer, then used Cycle for the Interface.

    Share this post


    Link to post

    I think this does it

     

    def main():
        control = doc.SearchObject('control')
        top = doc.SearchObject('top')
        text = doc.SearchObject('MoText')
    
        delay = control[c4d.ID_USERDATA,1]
        track = control[c4d.ID_USERDATA,4]
        track -= 1
        
        sn = top.GetChildren()
        count = len(sn)
    
        titles = ['No Track', 'Albertos - Kill', 'Ottawan - DISCO', 'Police - Roxanne']
        
        for a in range(count):
            t = sn[a].GetFirstCTrack()
            if a == track:
                t[c4d.CID_SOUND_ONOFF] = 1
                t[c4d.CID_SOUND_START] = c4d.BaseTime(delay)
            else:
                t[c4d.CID_SOUND_ONOFF] = 0
                t[c4d.CID_SOUND_START] = c4d.BaseTime(0)
    
        text[c4d.PRIM_TEXT_TEXT] = titles[track + 1]

    userdata.png.d17015574e4df381e1c2763f4e587f7b.png

     

    I couldn't seem to get the int cycle to accept -1 as NONE, so I subtract 1 from track. The 'if a == track' misses it because range starts at 0, so sets all tracks to disable.

     

    Then added 1 to track for text readout.

    Share this post


    Link to post
  • Topic Author
  • Oh nice! Thanks man this works great!

    Share this post


    Link to post

    Alberto y Lost Trios Paranoias - Kill, on YouTube here

     

    70's comedy punk band...

    Share this post


    Link to post

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Reply to this topic...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    Sign in to follow this  

    • Recently Browsing   0 members

      No registered users viewing this page.

    ×
    ×
    • Create New...