Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER for Video Editing/Mangling

Reply
 
Thread Tools Display Modes
Old 03-24-2022, 02:58 PM   #1
ashcat_lt
Human being with feelings
 
Join Date: Dec 2012
Posts: 7,272
Default Decorative Oscilloscope with Connected Dots

This one is probably less interesting, but I figure somebody could find a use for it.

Mode 2 (the lissajous-type thing) is a little weird because the two ends of the dot count are discontinuous from one another, and I couldn't think of a good way around it. If anybody's got a suggestion, I'm open to look at it.

Replaced the "blitter filter" with "blitter blend mode". 0 is normal, 1 is subtract, 2 is difference.

Let me know what you think.


Code:
//Decorative Oscilloscope with Connected Dots (requires JSFX video sample peeker)
//@gmem=jsfx_to_video
//@param 1:mode "mode" 0 0 4 0 1
//@param 2:dotcount "point count" 1200 10 5000 400 10
//@param 3:dotsize "point size" 4 2 40 20 1
//@param 4:lsize "line size (x point size)" 0.9 0.1 4 1 0.1
//@param 5:gain_db "gain (dB)" -6 -80 12 -12 1
//@param 6:zoom_amt "blitter zoom" .27 -.5 1 .1 0.01
//@param 7:fadespeed "blitter persist" .8 0 1 .1 0.01
//@param 8:blend_mode "blitter blend mode" 0 0 2 1 1
//@param 9:fg_r "foreground R" 1 0 1 .5 .02
//@param 10:fg_g "foreground G" 1 0 1 .5 .02
//@param 11:fg_b "foreground B" 1 0 1 .5 .02
//@param 12:bg_r "background R" 0 0 1 .5 .02
//@param 13:bg_g "background G" 0 0 1 .5 .02
//@param 14:bg_b "background B" 0 0 1 .5 .02
//@param 15:cx "center X" .5 0 1 .5 .01
//@param 16:cy "center Y" .5 0 1 .5 .01
//@param 17:radius "radius (mode 3)" .5 0 1 .5 .01

function gfx_line(x,y,x2,y2,t) local(i,n,dx,dy,dxn,dyn) (
  dx=(x2-x); dy=(y2-y);
  n=abs(dx)+abs(dy);
  dxn=dx/n; dyn=dy/n;
  i=0;
  loop(n,
    gfx_fillrect(x+i*dxn,y+i*dyn,t,t);
    i+=1;
  );
  gfx_fillrect(x2,y2,1,1);
);

oldCS=colorspace;
colorspace='YV12';

last_frame && fadespeed > 0 ? (
  xo = project_w*zoom_amt*.25;
  yo = project_h*zoom_amt*.25;
  blend_mode == 0 ? gfx_mode = 0;
  blend_mode == 1 ? (gfx_a *= -1; gfx_mode = 1;);
  blend_mode == 2 ? gfx_mode = 19;
  
  xo < 0 ? gfx_blit(last_frame,0);
  gfx_blit(last_frame,0,0,0,project_w,project_h,xo,yo,project_w-xo*2,project_h-yo*2);
);
blend_mode == 1 ? gfx_a *= -1;
colorspace=oldCS;
gfx_set(bg_r,bg_g,bg_b,last_frame ? (1-fadespeed) : 1);
gfx_a>.001 ? gfx_fillrect(0,0,project_w,project_h);

bufplaypos = gmem[0];
bufwritecursor = gmem[1];
bufsrate = gmem[2];
bufstart = gmem[3];
bufend = gmem[4];
nch = gmem[5];
gain = 10^(gain_db*(1/20));

dt=max(bufplaypos - project_time,0);
dt*bufsrate < dotcount ? underrun_cnt+=1;
rdpos = bufwritecursor - ((dt*bufsrate - dotcount)|0)*nch;
rdpos < bufstart ? rdpos += bufend-bufstart;

two_pi = 2 * $pi;

edge = 32;
first_edge = dotcount / edge;
last_edge = dotcount - first_edge;

gfx_set(fg_r,fg_g,fg_b,1);

linesize = dotsize * lsize;

function getpt()
(
  l = gmem[rdpos]; r = gmem[rdpos+1];
  (rdpos += nch)>=bufend ? rdpos=bufstart;
);
i=0;


mode==4 ? (
  loop(dotcount,
    do = 1;
    getpt();
    ang = $pi * i/dotcount;
    cos_ = cos(ang);
    sin_ = sin (ang);
    dist = max(0, (l+r) * gain * 0.25 + radius);
    xp = (cos_ * dist + cx) * project_w;
    yp_1 = (-sin_ * dist + cy) * project_h;
    yp_2 = (sin_ * dist + cy) * project_h;
    i == 0 ? 
      (o_xp = xp ; 
       o_y_1 = y_1; 
       o_y_2 = y_2;
       do = 0;);
    do == 1 ?
      (gfx_line(o_x, o_y_1, xp, yp_1, dotsize);
       gfx_line(o_x, o_y_2, xp, yp_2, dotsize););
    i == dotcount - 1 ? gfx_line(xp, yp_1, xp, yp_2, dotsize);
      
    o_x = xp;
    o_y_1 = yp_1;
    o_y_2 = yp_2;
   i += 1;
  );
) : mode==3 ? (
  loop(dotcount,
    getpt();
   
    ang = two_pi * i/dotcount;
    cos_ = cos(ang);
    sin_ = sin (ang);
    dist = max(0, (l+r) * gain * 0.25 + radius);
    xp = (cos_ * dist + cx) * project_w;
    yp = (sin_ * dist + cy) * project_h;
    gfx_line(o_x, o_y, xp, yp, dotsize);
    o_x = xp;
    o_y = yp;
   i += 1;
  );
) : mode==2 ? (
  loop(dotcount,
    getpt();
    ang = atan2(l,r); dist = sqrt(sqr(l)+sqr(r));
    xp = cx*project_w + ((cos(ang)*dist*gain)*project_h-dotsize)*.5;
    yp = ((cy*2+sin(ang)*dist*gain)*project_h-dotsize)*.5;
    gfx_fillrect(xp,yp, dotsize,dotsize);
    mode == old_mode ? gfx_line (o_xp, o_yp, xp, yp, linesize);
    o_xp = xp; o_yp = yp;
  );
) : mode == 1 ? (
  loop(dotcount,
    getpt();
    yp = project_h * (cy - .5 + i / dotcount);
    xp = project_w * (cx + (l+r)*.25*gain);
    gfx_fillrect(xp-dotsize*.5,yp-dotsize*.5, dotsize,dotsize);
    do = mode == old_mode;
    do *= i;
    do > 0 ? gfx_line (o_xp-linesize*.5, o_yp-linesize*.5, xp-linesize*.5, yp-linesize*.5, linesize);
    o_xp = xp; o_yp = yp;
    i+=1;
  );

) : (
  loop(dotcount,
    getpt();
    xp = project_w * (cx - 0.5 + i / dotcount);
    yp = project_h * (cy + (l+r)*.25*gain);
    gfx_fillrect(xp-dotsize*.5,yp-dotsize*.5, dotsize,dotsize);
    do = mode == old_mode;
    do *= i;
    do > 0 ? gfx_line (o_xp-linesize*.5, o_yp-linesize*.5, xp-linesize*.5, yp-linesize*.5, linesize);
    o_xp = xp; o_yp = yp;
    i+=1;
  );
);
old_mode = mode;
gfx_img_free(last_frame);
last_frame=gfx_img_hold(-1);

Last edited by ashcat_lt; 03-29-2022 at 11:21 AM. Reason: Added radial mode (3), and mirrored radial (4)
ashcat_lt is offline   Reply With Quote
Old 03-29-2022, 04:21 AM   #2
vitalker
Human being with feelings
 
vitalker's Avatar
 
Join Date: Dec 2012
Posts: 13,333
Default

Pretty winampish.
Do you think you could modify this preset to eliminate that ugly thing on the edges?
https://forum.cockos.com/showthread.php?t=237528

You can see the thing here (on the bottom):

vitalker is offline   Reply With Quote
Old 03-29-2022, 11:19 AM   #3
ashcat_lt
Human being with feelings
 
Join Date: Dec 2012
Posts: 7,272
Default

I mean, kinda no. As mentioned in that other thread, what you're seeing is the visual equivalent of the audio click we get in poorly aligned audio loops. There's no good reason those two samples should be the same except by accident. The way you're doing the thing there, it can't really work.


I have, however, updated the code above to include mode 3 which basically does the same thing you're doing with two presets atm and mode 4 which gets around the glitch by actually mirroring the full wave form vertically. That will cause the patterns to be symmetrical, of course, which may not always be the best option either, but it definitely is smoother.



I'm going to look into some sort of crossfade action, but that's going to take a minute and I kind of have to move on right now.


Hope this helps some.
ashcat_lt 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 10:13 PM.


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