[x3d-public] audio and timesensor synchronization

Michalis Kamburelis michalis.kambi at gmail.com
Mon Sep 4 14:56:03 PDT 2023


I understand that by "Reopen" you refer to view3dscene "File ->
Reopen"? To be clear, all it does is

- save the current camera (position, direction, up)
- save the navigation type
- open the file just like opening it using "File -> Open" would do
- sets the camera to saved position, direction, up
- sets the navigation type to saved type.

Reopening doesn't do anything special with regards to animations or time.

If you believe it does have a bug, please submit a simple testcase to
show the problem -- a complete X3D file that I can load in view3dscene
and see the problem will be appreciated.

Note that VRML and X3D internally use absolute time (seconds since
January 1, 1970) in SFTime. See "8.2.2 Time origin" of X3D spec. It
may make some things weird, but following the spec -- for good or bad.
But I speculate, I don't know exactly how you run your animation, I
need more information than above.

A proper usage is certainly possible, such that each opening of the
file runs the animation correctly from start. If you ROUTE to
TimeSensor.startTime values e.g. from ProximitySensor.enterTime or
TouchSensor.touchTime, it will behave as expected.

Regards,
Michalis

pon., 4 wrz 2023 o 22:01 Joe D Williams <joedwil at earthlink.net> napisał(a):
>
> Hi All,
> I have a scene with AudioClip and TimeSensor animations.When Open, if same file then, same as Reopen, the audio restarts, but the animation time sensor (after instantaneous reset to 0) restarts where it left off, rather than actually restarting. This leaves the sound and animations out of synch and so useless. Really appears like my timer is running with WorldTime when it is turned off then gets reset using relative to World Time when reopen or open.
>
> I thought I should have the  answer to this by starting the animation timers under control of the audio startTime. Just don't start animation timers until audio starts then all should synch.
>
> So, I can understand some caretaking like this when the author is reloading to fix some stuff and just wants to proceed rather than start an animation over from the beginning, but it seems to me that the author also ought to have the keys to get a complete restart from the beginning.
>
> So, in this case, I really do want to be able to keep this audio in sync with the animation. When I do tell the animation timer to start with the audio, I want to be able to depend on that rather than the tool taking over and deciding what to do with regard to the TimeSensor timing depending upon the last time I did Open or Reopen with the same or similar file. In this case the Audio startTime sent to the animation timer is not being honored.
>
> This is how it is coded:
>
>     <TimeSensor DEF='GBTimer' cycleInterval='100'
>       enabled='false' loop='true'/>
>
>     <Sound DEF='SceneMusic' >
>       <AudioClip DEF='Melodies'
>          loop='true' enabled='true'
>          url='"wrv2_103seconds.wav"'/>
>     </Sound>
>
>
>
>
>     <ROUTE fromField='startTime' fromNode='Melodies'
>                    toField='set_startTime' toNode='GBTimer'/>
>     <ROUTE fromField='isActive' fromNode='Melodies'
>                     toField='set_enabled' toNode='GrampsBoxTimer'/>
>
> Is the basics. When the audio starts, then the animation timer starts. But I also want to stop the animation at the last frame when it ends, instead of repeating the animation. There must be a better way, but I am using:
>
>     <BooleanSequencer DEF='GBTimerLoopControl'
>       key='0 0.9 1' keyValue='true false false'/>
>     <ROUTE fromField='fraction_changed' fromNode='GrampsBoxTimer'
>        toField='set_fraction' toNode='GBTimerLoopControl'/>
>     <ROUTE fromField='value_changed' fromNode='GBTimerLoopControl'
>       toField='loop' toNode='GBTimer'/>
>
> Which turns off the animation timer after one cycle.
>
> Sending the loop false twice seems necessary since if sent only at fraction time 1 it lets animation timer move to start and actually send 0 fraction instead of ending at last frame. I think the loop true/false should be evaluated before start is set, not set start then check loop, Loop false at tic fraction 1 should not allow the timer to proceed to 0. If loop is false at load,then start is not sent.
>
> And I also want the AudioClip to stop after one play with no repeat so I did this:
>
> <ROUTE fromField='value_changed' fromNode='GrampsBoxTimerLoopControl' toField='loop' toNode='Melodies'/>
>
> Since the animation timer ends its cycle a few seconds before the audioclip, (100 seconds vs 103 seconds) this should also keep the audioclip from looping. Unfortunately,it does not and the audio continues until it is stopped by unknown, Seems like loop false recognized some time later than needed to stop the audio at its end. as the audio plays.  By changing the animation timer cycletime I see the loop false is recognized at some time which seems related to when I send the audio loop false and that I might be able to with luck pick a lucky time that matches the stop time I need.
>
> So, please help me figure out how to control this thing the way I need to.
>
> Thanks All,
> Joe
>
>
>
>
>
>
>
>
>
>
>
> .
>
>
>
> _______________________________________________
> x3d-public mailing list
> x3d-public at web3d.org
> http://web3d.org/mailman/listinfo/x3d-public_web3d.org



More information about the x3d-public mailing list