Old 02-17-2017, 06:18 AM   #1
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Germany
Posts: 33
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, 81 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: 70
Default

Very interesting idea...
kkostovas is offline   Reply With Quote
Old 02-18-2017, 09:53 PM   #3
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 1,302
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; 02-18-2017 at 10:01 PM.
mpl is online now   Reply With Quote
Old 02-19-2017, 04:59 AM   #4
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 1,302
Default

Of course it doesn't since Dragonetti didn't ask for that
__________________
SoundCloud | MPL Scripts / ReaPack | Donate
mpl is online now   Reply With Quote
Old 02-19-2017, 04:59 PM   #5
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Germany
Posts: 33
Default

It is brilliant.
I need a little time to check it out with my touchscreen.
Can I still want other functions?
My first impression are.
The fades are to short; the fader for fade out have to operate in the other direction ; and the start point is the wrong term. I mean to decrease the item with the left fader while the item stays on the spot.

sorry for my bad English

Markus
Dragonetti is offline   Reply With Quote
Old 02-20-2017, 12:14 AM   #6
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 1,302
Default

https://github.com/MichaelPilyavskiy...ted%20item.lua
__________________
SoundCloud | MPL Scripts / ReaPack | Donate
mpl is online now   Reply With Quote
Old 02-21-2017, 01:18 AM   #7
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Germany
Posts: 33
Default

Very good, but the starpoint pushes the complete music to the right.
The start offset doesen`t change.

Thank you
Markus
Attached Images
File Type: jpg edit-item3.jpg (26.1 KB, 34 views)
Dragonetti is offline   Reply With Quote
Old 02-22-2017, 01:37 AM   #8
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Germany
Posts: 33
Default

Hello Michael,
can you please fix for me the startpoint improvement.
The faders for the other functions are very good.
When you have time can you integrate a few shortcutsbuttons on the top.
Thank you
Markus
I will donate!
Attached Images
File Type: jpg item4.jpg (13.3 KB, 42 views)

Last edited by Dragonetti; 02-23-2017 at 01:01 AM.
Dragonetti is offline   Reply With Quote
Old 02-25-2017, 08:40 AM   #9
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Germany
Posts: 33
Default

a little video
Attached Images
File Type: gif ezgif.com-optimize.gif (51.8 KB, 29 views)
Dragonetti 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 12:16 AM.


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