Old 05-23-2011, 05:43 AM   #1
akademie
Human being with feelings
 
Join Date: Mar 2007
Posts: 549
Default visual plugin, please (something like a modified "bigState" JS plugin)

Hello,
I would like to ask any experienced JS programmer (or "zorn" directly ?), if could help me (or better write it for me, and maybo others too) with a JS plugin, that would be like a BigState (which displays set of Transport images in context to actual "play_state"), but this plugin would display set (lets say 20..?) of pictures, that are shown dependant on position of play cursor in timeline = "play_position".

It would display picture 1 when play_position is in the range A to B (e.g. A=0 sec, B=195 sec), picture 2 when play_position is in the range of C to D (C= 196 sec, D= 325 sec) etc. Times (play_position) would be entered in seconds (typed (preferably) or slidered), pictures could be assigned directly in JS code (for example file1=playstate_01.png ... file20=playstate_20.png.

Thank you very much
akademie
akademie is offline   Reply With Quote
Old 05-23-2011, 06:39 AM   #2
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 5,450
Default

OK, see if this does what you want it to

Code:
desc: big play state
filename:0,stop.png
filename:1,play.png
filename:2,pause.png
filename:3,record.png
filename:4,recordpaused.png
filename:5,pause.png
filename:6,play.png
// and so on...

slider1:5<0,20,1>First pic
slider2:10<10,30,1>Second pic
slider3:15<15,35,1>Third pic
slider4:20<20,40,1>Fourth pic
slider5:25<25,45,1>Fifth pic
// and so on...

in_pin:none
out_pin:none

@init
gfx_a = 1;

@block
(play_state == 1) || (play-state == 5) ? // only change pic while playing or recording
(
	(play_position < slider1) ?
	(
		rstate = 0;
	):(
	(play_position < slider2) ?
	(
		rstate = 1;
	):(
	(play_position < slider3) ?
	(
		rstate = 2;
	):(
	(play_position < slider4) ?
	(
		rstate = 3;
	):(
	(play_position < slider5) ?
	(
		rstate = 4;
	);	
	);  // and so on... make sure the ending parentheses match up.
	);  // there has to be one ");" for each alternative
	);
	);
);

@gfx 100 100
rstate >= 0 ? (
  gfx_file = rstate;
  rstate >= 5 ? gfx_file-= 2;
  gfx_x = gfx_y = 0;
  gfx_blit(gfx_file, gfx_w/200, 0);
);
It's crafted after Zorn's code from http://forum.cockos.com/showthread.php?t=56399. I only implemented for five pics, but you can edit the rest to suit your own needs. By default it uses Zorn's png's from that other thread, but you can of course replace them with any pics you like.

JS code leaves a lot to desire when it comes to file handling and doing repetitive code like that, and I'm sure someone can figure out an "better" (in the sense of "nicer code") way of determining which pic to load, but I took the quic'n'dirty road here.

The resolution depends on your asio buffer setting, since the code determines in the @block which pic to load,and this is called once at the beginning of each asio buffer fill-up (IIUC)
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
Fabian is offline   Reply With Quote
Old 05-23-2011, 07:01 AM   #3
musicbynumbers
Human being with feelings
 
musicbynumbers's Avatar
 
Join Date: Jun 2009
Location: brighton, uk
Posts: 12,745
Default

Also reaper 4 has just added rudimentary (probably get better in next few builds) ability to drop an image on the arrange page time line (nothing new) but now it shows up on the video display window for as long as the item is

That might be helpful to you unless I misunderstood
musicbynumbers is offline   Reply With Quote
Old 05-26-2011, 07:19 AM   #4
akademie
Human being with feelings
 
Join Date: Mar 2007
Posts: 549
Default

Wow,
Big thanks and then once again :-)
This is absolutely perfect, just what I needed...
Thank you very much, Fabian, for the code.
(I edited it a bit, I wanted it to update all the time, not only on playing/recording, so great to have your comments in code)

Just one question on another topic, is there some limitation in "@gfx 100 100"?
I have picture which is "portrait orientation" (200x400 pixels) and it seems I cannot make it display only the picture part without black backround on the right side of picture, no matter what numbers i put instead of 100 and 100. Looks like it has some limit or what that the shown picture cannot be less than something like 400pix ??

musicbynumbers, thanks for the tip about v4, I didn't know that it shows picture clips in video window now, that is great. But I would stick with V3, because of stability (I hope) as I need it for live gig, so here I prefer no alphabetas, you know ;-)


Sorry for delay, I was away for 2 days...

akademie
akademie is offline   Reply With Quote
Old 05-26-2011, 07:31 PM   #5
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 5,450
Default

I'm glad it works. And thanks to Zorn who crafted the original code that this is based on.

Of course, go ahead, edit to your hearts content. It's a great way of learning JS.

As for the gfx issue, I have no idea, maybe Zorn or someone else knows... or maybe there's something in the JS programming guide http://www.cockos.com/reaper/sdk/js/js.php, but I guess you've looked there already...
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
Fabian is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 11:24 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.