Source language: Translate to:

Visual effect in a Rectangle with NeoBookDX

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Visual effect in a Rectangle with NeoBookDX

Postby UltraVox » Mon Mar 22, 2010 5:12 am

Hello all,

How to automatically increase the length of a Rectangle from playing an audio file with NeoBookDX ?

I try to create a visual effect, on reading a audio file.

More audio file advance over the length of the rectangle increases.

Thank you for your help!
UltraVox
 
Posts: 419
Joined: Sat Jul 28, 2007 11:14 am
Location: France

Postby Gaev » Mon Mar 22, 2010 6:16 am

UltraVox:

I haven't done it myself ... but you might consider setting up a Timer object ... where you use ...
[PlayerID.Length] The length of the currently loaded media file in milliseconds.
[PlayerID.Position] The media player's current position in milliseconds.
... for example, the code in the TimerInterval section could be something like ...
Code: Select all
Math "([PlayerID.Position]/[PlayerID.Length])*[RectangleMaxWidth]" "0" "[NewRectangleWidth]"
SizeObject "Rectangle45" "[NewRectangleWidth]" "10"
... where [RectangleMaxWidth] is the size when file is played 100%.
User avatar
Gaev
 
Posts: 3737
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby UltraVox » Mon Mar 22, 2010 7:33 am

Thank you Gaev !

I can not integrate the two commands lines in the "TimerInterval" option. It allows the first line, but not the second.

Do not ask me to create a second timer for the second line. The first timer is already generating slowdowns program. What a pity to confuse the program for a simple visual effect of type "rectangle trackbar".

To your knowledge, is there another method ?

In fact, I would like to create a track bar, that looks like a rectangle...

Sincerely
UltraVox
 
Posts: 419
Joined: Sat Jul 28, 2007 11:14 am
Location: France

Postby Neosoft Support » Mon Mar 22, 2010 10:24 am

If the timer is actually slowing down your application, then try increasing the interval. The timer interval is specified in milliseconds, so it doesn't need to be very low to produce the results you desire. An interval of 250 or 500 milliseconds is usually sufficient and shouldn't slow down your application.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5605
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Postby UltraVox » Tue Mar 23, 2010 3:54 am

Neosoft, Gaev

Thank you for your reply :)

I'll work with a Timer(s), but I can not use the command of Gaev.

Could you be so kind as to explain clearly the procedure ?

A .Pub demonstration would be very appreciated...

Please!

Sincerely,
UltraVox
 
Posts: 419
Joined: Sat Jul 28, 2007 11:14 am
Location: France

Postby Gaev » Tue Mar 23, 2010 5:59 am

UltraVox:
Could you be so kind as to explain clearly the procedure ?

a) The TimerInterval section must be coded something LIKE this ...
Code: Select all
Math "([PlayerID.Position]/[PlayerID.Length])*[RectangleMaxWidth]" "0" "[NewRectangleWidth]"
SizeObject "Rectangle45" "[NewRectangleWidth]" "10"
... note that ...

- you MUST replace PlayerID with the value you use in your dxCreate command

- [RectangleMaxWidth] is the size when file is played 100% ... so if you want the width to be 600 pixels when 100% of the song is played ... do a SetVar "[RectangleMaxWidth]" "600" ... BEFORE you start playing the song

- you MUST replace Rectangle45 with the name of the Rectangle Object you will be using as a Trackbar ... NOT the Rectangle Object specified in your dxCreate command

b) As Dave mentioned, specifying an Interval of about 1000 (milliSeconds) is sufficient
A .Pub demonstration would be very appreciated...
If you are still having problems after following the above instructions ...

a) copy/paste your code for the TimerInterval section here

b) tell us details of the behaviour at run time ... i.e. do you see (in your Debug Window) the values for all of the variables change as expected ? ... if not provide detailed descriptions of the descrepancies
User avatar
Gaev
 
Posts: 3737
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby UltraVox » Tue Mar 23, 2010 1:09 pm

Gaev,

Thank you for your explanation!
It works well with you and it is much more aesthetic than trackbar...

I try to find the remaining time of the song (in real-time) using this command :
Code: Select all
Math "([OnLineTitle.Position]-[OnLineTitle.Length])" "0" "[RemainingTime]"

I get a 6-digit number, for example :
Code: Select all
-217684

The variable is a count until the end of the song.
But, do you know how to convert this variable in HMS format ?

Unfortunately, this command does not exist in NeoBookDX (Dave, add it here please :) )

Thank you for all the help you brought me.
Sincerely.
UltraVox
 
Posts: 419
Joined: Sat Jul 28, 2007 11:14 am
Location: France

Postby Gaev » Tue Mar 23, 2010 1:30 pm

UltraVox:

PlayerID.Position and PlayerID..Length are expressed in milliSeconds.

So -217684 means that there are 217684 milliSeconds left to play ... or about 217 seconds.

If you divide this by 60, you will get the Minutes ... in your case 3.6166 etc.

You can do the calculation to get whole Minutes and Seconds too ... trick is to use trunc() function in the Math command to get whole Minutes ... 3 in your case.

Then multiply this whole Minutes value by 60 ... in your case 180

And subtract this result (180) from the whole seconds (217) to get the remaining whole seconds ... 37 in your case


If you write a generic NeoBook Function to convert Seconds to (whole) Hours, Minutes and Seconds ... you can use it for ever afterwards in all your Applications.
User avatar
Gaev
 
Posts: 3737
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby UltraVox » Wed Mar 24, 2010 4:16 am

Gaev,

Very interesting!

Thank you for all your advice.
I have much trouble with my questions!

I can send you (privately) a screenshot of my application, although it is far from over...

Thank you again for your help :) :) :)

Sincerely,
UltraVox
 
Posts: 419
Joined: Sat Jul 28, 2007 11:14 am
Location: France


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 1 guest