Old 02-17-2017, 06:18 AM   #1
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Posts: 2
Default script for touchscreen

I want to edit items with my acer 23 Zoll touchscreen.
The original catchers are to small.
Is there a script to edit volume , fades , lenght of a selected item?

Thank you
Markus
Attached Images
File Type: jpg Edit-Item--Touchscreen.jpg (34.2 KB, 41 views)
Dragonetti is offline   Reply With Quote
Old 02-17-2017, 09:57 AM   #2
kkostovas
Human being with feelings
 
Join Date: Sep 2015
Posts: 66
Default

Very interesting idea...
kkostovas is online now   Reply With Quote
Old Yesterday, 09:53 PM   #3
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 1,118
Default

very quick test

Code:
  function Run()
    item = reaper.GetSelectedMediaItem(0,0)
    DEFINE_obj()
    GUI_draw() 
    MOUSE_get()
    gfx.update()
    local char = gfx.getchar() 
    if char == 32 then reaper.Main_OnCommandEx(40044, 0,0) end
    if char == 27 then gfx.quit() end     
    if char ~= -1 then reaper.defer(Run) else gfx.quit() end   
  end
  ---------------------------------------  
  function GUI_slider(obj_t, noval)
    if not obj_t then return end
    local x,y,w,h, val = obj_t.x,obj_t.y,obj_t.w,obj_t.h,obj_t.val
    gfx.set(1,1,1,1)
    gfx.rect(x,y,w,h,0)
    gfx.a = 0.2
    if not noval then gfx.rect(x,y,w*val,h,1) end
    gfx.a = 1
    local txt_offs = 5
    gfx.x, gfx.y = x+txt_offs,y+txt_offs
    txt = obj_t.name..':'..math.floor(val*100)/100
    gfx.drawstr(txt)
  end
  ---------------------------------------
  function GUI_draw()
    if item then 
      tk = reaper.GetActiveTake(item)
      _, tk_name = reaper.GetSetMediaItemTakeInfo_String( tk, 'P_NAME', '', 0 )
      gfx.x, gfx.y = 5,5 gfx.drawstr(tk_name)
      GUI_slider(obj.fader_vol)
      GUI_slider(obj.fader_f_in)
      GUI_slider(obj.fader_f_out)
      GUI_slider(obj.fader_point_st, true)
      GUI_slider(obj.fader_point_end, true)
    end
    
    gfx.update()
  end
  ------------------------------------------------------------------ 
  function MOUSE_match(b)
    if b and b.x then
      local mouse_y_match = b.y
      local mouse_h_match = b.y+b.h
      if mouse.mx > b.x 
          and mouse.mx < b.x+b.w 
          and mouse.my > mouse_y_match 
          and mouse.my < mouse_h_match 
          then return true 
      end 
    end
  end 
  function MOUSE_slider(obj_t, nolim)
    if mouse.LMB_state 
      and not mouse.last_LMB_state 
      and MOUSE_match(obj_t) then
          mouse.last_obj_val =obj_t.val
          mouse.last_obj = obj_t.name
        end
        if mouse.LMB_state and mouse.last_obj == obj_t.name then
          if not nolim then new_val = F_limit(mouse.last_obj_val + mouse.dx*0.005,0,1)
            else           new_val =         mouse.last_obj_val + mouse.dx*0.005,0,1
          end
          obj_t.func(new_val)
        end    
  end
  ---------------------------------------
  function MOUSE_get()
    mouse.abs_x, mouse.abs_y = reaper.GetMousePosition()
    mouse.mx = gfx.mouse_x
    mouse.my = gfx.mouse_y
    mouse.LMB_state = gfx.mouse_cap&1 == 1 
    
    -- dx/dy
      if not mouse.last_LMB_state and mouse.LMB_state then 
        mouse.LMB_stamp_x = mouse.mx
        mouse.LMB_stamp_y = mouse.my
      end    
      if mouse.LMB_state then 
        mouse.dx = mouse.mx - mouse.LMB_stamp_x
        mouse.dy = mouse.my - mouse.LMB_stamp_y
      end
    
    if item then 
      MOUSE_slider(obj.fader_vol)
      MOUSE_slider(obj.fader_f_in)
      MOUSE_slider(obj.fader_f_out)
      MOUSE_slider(obj.fader_point_st, true)
      MOUSE_slider(obj.fader_point_end, true)
    end
    
    -- reset mouse context/doundo
      if mouse.last_LMB_state and not mouse.LMB_state then 
        mouse.last_obj = nil
        mouse.last_obj_val = nil
        mouse.dx = 0
        mouse.dy = 0
      end
  
    -- mouse release
      mouse.last_LMB_state = mouse.LMB_state  
      mouse.last_mx = mouse.mx
      mouse.last_my = mouse.my
  end
  --------------------------------------------
  function F_limit(val,min,max)
      if val == nil then return end
      local val_out = val
      if min and val < min then val_out = min end
      if max and val > max then val_out = max end
      return val_out
    end
  --------------------------------------------
  function DEFINE_obj()
    obj = {}
    if item then 
      local offs = 10
      local name_offs = 20
      local h_sl = 30
      obj.fader_vol = {x = offs,
                       y = offs+name_offs,
                       w =  gfx.w - offs *2,
                       h = h_sl,
                       name = 'Gain',
                       val = reaper.GetMediaItemInfo_Value( item, 'D_VOL' ),
                       func = function(v) 
                                reaper.SetMediaItemInfo_Value( item, 'D_VOL', v ) 
                                reaper.UpdateItemInProject(item)
                              end 
                       }
      obj.fader_f_in = {x = offs,
                       y = offs*2+h_sl+name_offs,
                       w =  gfx.w/2 - offs *2,
                       h = h_sl,
                       name = 'FadeIn',
                       val = reaper.GetMediaItemInfo_Value( item, 'D_FADEINLEN' ),
                       func = function(v) 
                                reaper.SetMediaItemInfo_Value( item, 'D_FADEINLEN', v ) 
                                reaper.UpdateItemInProject(item)
                              end 
                       }  
      obj.fader_f_out = {x = offs*3 + obj.fader_f_in.w,
                       y = offs*2+h_sl+name_offs,
                       w =  obj.fader_f_in.w,
                       h = h_sl,
                       name = 'FadeOut',
                       val = reaper.GetMediaItemInfo_Value( item, 'D_FADEOUTLEN' ),
                       func = function(v) 
                                reaper.SetMediaItemInfo_Value( item, 'D_FADEOUTLEN', v ) 
                                reaper.UpdateItemInProject(item)
                              end 
                       }  
      obj.fader_point_st = {x = offs,
                       y = offs*3+h_sl*2+name_offs,
                       w =  obj.fader_f_in.w,
                       h = h_sl,
                       name = 'StartPoint',
                       val = reaper.GetMediaItemInfo_Value( item, 'D_POSITION' ),         
                       func = function(v) 
                                reaper.SetMediaItemInfo_Value( item, 'D_POSITION', v ) 
                                reaper.UpdateItemInProject(item)
                              end 
                       }       
      obj.fader_point_end = {x =  offs*3 + obj.fader_f_in.w,
                       y = offs*3+h_sl*2+name_offs,
                       w =  obj.fader_f_in.w,
                       h = h_sl,
                       name = 'EndPoint',
                       val = reaper.GetMediaItemInfo_Value( item, 'D_LENGTH' ),         
                       func = function(v) 
                                reaper.SetMediaItemInfo_Value( item, 'D_LENGTH', v ) 
                                reaper.UpdateItemInProject(item)
                              end 
                       }                                                                                    
    end
  end
  --------------------------------------------
  mouse = {}
  MOUSE_get()
  gfx.init('test',300, 300,0,mouse.abs_x, mouse.abs_y)
  Run()
__________________
SoundCloud | MPL Scripts / ReaPack | Donate

Last edited by mpl; Yesterday at 10:01 PM.
mpl is offline   Reply With Quote
Old Today, 04:29 AM   #4
TonE
Human being with feelings
 
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 1,356
Default

mpl, does this work only with mouse drags but also mouseover + mousewheel (without any mouse click)?
TonE is online now   Reply With Quote
Old Today, 04:59 AM   #5
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 1,118
Default

Of course it doesn't since Dragonetti didn't ask for that
__________________
SoundCloud | MPL Scripts / ReaPack | Donate
mpl is offline   Reply With Quote
Old Today, 05:05 AM   #6
TonE
Human being with feelings
 
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 1,356
Default

Ok, thanks, but theoretically, mouseover + mousewheel is possible in the same way, right? That would be great news, how to put multiple parameters for mouseover control into a single interface. Like a custom control cockpit. A bit like LBX Stripper, I think. But here in simplest form.
TonE is online now   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 04:19 PM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.