Old 05-06-2016, 06:00 AM   #41
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 1,980
Default

So from whom can we get some concrete information which would allow us to move forward?
__________________
Dax Liniere
London's newest premium studio complex! (Facebook)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia GT710, UAD2-OCTO, FireFaceUFX, REAPER x64]
daxliniere is offline   Reply With Quote
Old 05-06-2016, 06:03 AM   #42
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 1,980
Default

If any scripters have time/interest to contribute, this is the current wish/to-do list:

-Allow all keystrokes to pass through Take Commenter GUI.
-Remove all markers written in record mode when record mode finishes (or instantly?). (user option, default to remove=1)
-Adjust undo points (or remove completely) so undo of record also removes markers.
-Write markers to source WAV files' Cue chunk.
-Reformat headers, etc for ReaPack compatibility
__________________
Dax Liniere
London's newest premium studio complex! (Facebook)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia GT710, UAD2-OCTO, FireFaceUFX, REAPER x64]
daxliniere is offline   Reply With Quote
Old 05-06-2016, 10:24 AM   #43
Edufighter
Human being with feelings
 
Join Date: Feb 2012
Location: Canada
Posts: 35
Default

Amazing tool indeed, congratulations to the people that brought this idea to life! I've been looking for something like this for a while

Now the annoying question... is there a way to avoid the app "steal the focus" from the main timeline? e.g. if I'm recording and dropping markers then to stop the recording I have to click out of the window to regain control of the spacebar.
Other cool improvement cuold be to being able to "map" the buttons to keys in the keyboard "G" for good, "B" for bad... or any others.
Edufighter is offline   Reply With Quote
Old 05-06-2016, 10:48 AM   #44
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 5,826
Default

modified to allow spacebar to play/stop and * in numpad to record.
And numbers 1 to 9 in numpad for the first 9 buttons.

add this after char = gfx.getchar()

Code:
char = gfx.getchar() 
  if char>=49 and char <=57 then -- numkeys
	Button_TB[char-48].onClick()
  end
  if char == 32 then  -- spacebar
      reaper.Main_OnCommand("40044",0) -- play stop
  end
  if char == 42 then  -- * in numpad
	reaper.Main_OnCommand("1013",0) -- record
  end

Last edited by heda; 05-06-2016 at 02:13 PM. Reason: blue color instead of red
heda is offline   Reply With Quote
Old 05-06-2016, 11:52 AM   #45
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Here's another way to "pass" keys to the main window (not perfect - the gui window flashes, but at least all the shortkeys should work):

(add the blue code to "onClick" -function)
Code:
-- Add "on click function" for each button
for i=1, #Button_TB do
  local curr_btn = Button_TB[i]
  curr_btn.onClick =
                      function()
                        add_marker_to_play_pos(curr_btn.lbl, curr_btn.r, curr_btn.g, curr_btn.b)
                        -- Set focus to arrange view when button is released
                        reaper.Main_OnCommand(reaper.NamedCommandLookup("_BR_FOCUS_ARRANGE_WND"),0)
                      end
end
spk77 is offline   Reply With Quote
Old 05-06-2016, 02:10 PM   #46
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 5,826
Default

@spk77: oh wow _BR_FOCUS_ARRANGE_WND ? Is that new? I didn't know! But does it create undo point?
I used reaper.SetCursorContext(0, env)
But I don't know why that funciton needs an envelope as argument.
heda is offline   Reply With Quote
Old 05-06-2016, 02:22 PM   #47
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 1,980
Default

Thank you HeDa and spk77!

So, can we make some decisions on functionality?
I thought about capturing keystrokes to trigger the buttons, but wasn't sure if it would interfere with workflow in an actual recording situation.
Is there a way we can combine both to have this functionality which is switchable via user option?

NumberPadButtons = 0
All keys are passed through

NumberPadNuttons = 1
NumPad 1-9 trigger buttons, all other keys passed through
__________________
Dax Liniere
London's newest premium studio complex! (Facebook)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia GT710, UAD2-OCTO, FireFaceUFX, REAPER x64]
daxliniere is offline   Reply With Quote
Old 05-06-2016, 03:22 PM   #48
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 5,826
Default

@daxliniere
You can combine both.
it is not that all keys are passed, what spk77 did is to focus in arrange after clicking on a button, but if you don't click on a button and use the numpad keys, you can keep pressing numpad keys to keep adding markers. Of course you can always make it as an option
heda is offline   Reply With Quote
Old 05-06-2016, 04:37 PM   #49
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 1,980
Default

Okay, I see. Great! I'll make the updates in the morning.

Any thoughts on how to remove the inserted markers as soon as they're added? (Only in rec mode, of course)

Delay time: I was also thinking there could be an offset for placement of markers. Most people have at least 250ms 'latency' between hearing a sound, recognising it as a mistake, then putting their muscles into action.
__________________
Dax Liniere
London's newest premium studio complex! (Facebook)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia GT710, UAD2-OCTO, FireFaceUFX, REAPER x64]

Last edited by daxliniere; 05-07-2016 at 01:49 AM. Reason: "Rain time"? WTF did I type?? XD
daxliniere is offline   Reply With Quote
Old 05-07-2016, 02:18 AM   #50
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 1,980
Default

I've made the changes, but am reluctant to post until one little issue is sorted out.

If numpad 1-9, spacebar or * are pressed, _BR_FOCUS_ARRANGE_WND should not be executed.
I tried to code it myself, but it only half works. I got it to exclude the focus to arrange window with those keys (yay!), but it has stopped shifting focus altogether now.(boo)

Code:
                        add_marker_to_play_pos(curr_btn.lbl, curr_btn.r, curr_btn.g, curr_btn.b)
						if hotkey<49 and hotkey >57 and hotkey ~= 32 and hotkey ~= 42 then -- not numkeys, spacebar or * in numpad
                        reaper.Main_OnCommand(reaper.NamedCommandLookup("_BR_FOCUS_ARRANGE_WND"),0)	-- Set focus to arrange view
						end

Also, I changed the variable 'char' to 'hotkey' as it seems like a taken word in LUA, even thought it worked.

Question: does anyone want the GUI layout changed from 4x3 to 3x4 to match a keyboard's number pad layout?

Code:
--------------------------------------------------------------------------------
---   Live Take Commenter   ----------------------------------------------------
---   GUI code by Eugen2777  ---------------------------------------------------
---   Marker writing code by spk77  --------------------------------------------
---   Operate during stop-mode code by HeDa  -----------------------------------
---   Hotkey code by HeDa   ----------------------------------------------------
---   Return focus to Arrange Window (pass keystrokes through) by spk77/Dax  ---
---   Writing cue to WAV code by ????? -----------------------------------------
---   Concept by Dax Liniere  --------------------------------------------------

local Element = {}
function Element:new(x,y,w,h, r,g,b,a, lbl,fnt,fnt_sz, norm_val)
    local elm = {}
    elm.def_xywh = {x,y,w,h,fnt_sz} -- its default coord,used for Zoom etc
    elm.x, elm.y, elm.w, elm.h = x, y, w, h
    elm.r, elm.g, elm.b, elm.a = r, g, b, a
    elm.lbl, elm.fnt, elm.fnt_sz  = lbl, fnt, fnt_sz
    elm.norm_val = norm_val
    ------
    setmetatable(elm, self)
    self.__index = self 
    return elm
end
--------------------------------------------------------------
--- Function for Child Classes(args = Child,Parent Class) ----

function extended(Child, Parent)
  setmetatable(Child,{__index = Parent}) 
end
--------------------------------------------------------------
---   Element Class Methods(Main Methods)   ------------------

function Element:update_xywh()
  if not Z_w or not Z_h then return end -- return if zoom not defined
  if Z_w>0.5 and Z_w<3 then  
   self.x, self.w = math.ceil(self.def_xywh[1]* Z_w) , math.ceil(self.def_xywh[3]* Z_w) --upd x,w
  end
  if Z_h>0.5 and Z_h<3 then
   self.y, self.h = math.ceil(self.def_xywh[2]* Z_h) , math.ceil(self.def_xywh[4]* Z_h) --upd y,h
  end
  if Z_w>0.5 or Z_h>0.5  then --fix it!--
     self.fnt_sz = math.max(9,self.def_xywh[5]* (Z_w+Z_h)/2)
     self.fnt_sz = math.min(22,self.fnt_sz)
  end       
end
--------
function Element:pointIN(p_x, p_y)
  return p_x >= self.x and p_x <= self.x + self.w and p_y >= self.y and p_y <= self.y + self.h
end
--------
function Element:mouseIN()
  return gfx.mouse_cap&1==0 and self:pointIN(gfx.mouse_x,gfx.mouse_y)
end
--------
function Element:mouseDown()
  return gfx.mouse_cap&1==1 and self:pointIN(mouse_ox,mouse_oy)
end
--------
function Element:mouseClick()
  return gfx.mouse_cap&1==0 and last_mouse_cap&1==1 and
  self:pointIN(gfx.mouse_x,gfx.mouse_y) and self:pointIN(mouse_ox,mouse_oy)         
end
--------
function Element:draw_frame()
  local x,y,w,h  = self.x,self.y,self.w,self.h
  gfx.rect(x, y, w, h, 0)--frame1
  gfx.roundrect(x, y, w-1, h-1, 3, true)--frame2         
end
--------------------------------------------------------------------------------
---   Create Element Child Classes(Button,Slider,Knob)   -----------------------

local Button ={}; local Knob ={}; local Slider ={}; 
  extended(Button, Element)
  extended(Knob,   Element)
  extended(Slider, Element)
---Create Slider Child Classes(V_Slider,H_Slider)----
local H_Slider ={}; local V_Slider ={};
  extended(H_Slider, Slider)
  extended(V_Slider, Slider)

--------------------------------------------------------------------------------
---   Button Class Methods   ---------------------------------------------------

function Button:draw_lbl()
    local x,y,w,h  = self.x,self.y,self.w,self.h
    local fnt,fnt_sz = self.fnt, self.fnt_sz
    --Draw btn lbl(text)--
      gfx.set(0.7, 1, 0, 1)--set label color
      gfx.setfont(1, fnt, fnt_sz);--set label fnt
        local lbl_w, lbl_h = gfx.measurestr(self.lbl)
        gfx.x = x+(w-lbl_w)/2; gfx.y = y+(h-lbl_h)/2
        gfx.drawstr(self.lbl)
end
---------------------
function Button:draw()
    self:update_xywh()--Update xywh(if wind changed)
    local x,y,w,h  = self.x,self.y,self.w,self.h
    local r,g,b,a  = self.r,self.g,self.b,self.a
    ---Get L_mouse state--
          --in element--
          if self:mouseIN() then a=a+0.1 end
          --in elm L_down--
          if self:mouseDown() then a=a+0.2 end
          --in elm L_up(released and was previously pressed)--
          if self:mouseClick() then self.onClick() end
    --Draw btn(body,frame)--
    gfx.set(r,g,b,a)--set btn color
    gfx.rect(x,y,w,h,true)--body
    self:draw_frame()
    ------------------------
    self:draw_lbl()
end

----------------------------------------------------------------------------------------------------
---   START   --------------------------------------------------------------------------------------

local btn1 = Button:new(10,10,70,70, 0.2,0.2,1.0,0.5, "PERFECT","Arial",15, 0 )
local btn2 = Button:new(90,10,70,70, 0.0,1.0,0.0,0.5, "good","Arial",15, 0 )
local btn3 = Button:new(170,10,70,70, 0.0,1.0,0.0,0.5, "not bad","Arial",15, 0 )
local btn4 = Button:new(250,10,70,70, 0.0,1.0,0.0,0.5, "okay","Arial",15, 0 )
local btn5 = Button:new(10,90,70,70, 1.0,0.0,0.0,0.5, "sharp","Arial",15, 0 )
local btn6 = Button:new(90,90,70,70, 1.0,0.0,0.0,0.5, "flat","Arial",15, 0 )
local btn7 = Button:new(170,90,70,70, 1.0,0.0,0.0,0.5, "early","Arial",15, 0 )
local btn8 = Button:new(250,90,70,70, 1.0,0.0,0.0,0.5, "late","Arial",15, 0 )
local btn9 = Button:new(10,170,70,70, 1.0,0.0,0.0,0.5, "lumpy","Arial",15, 0 )
local btn10 = Button:new(90,170,70,70, 1.0,0.0,0.0,0.5, "no energy","Arial",15, 0 )
local btn11 = Button:new(170,170,70,70, 1.0,0.0,0.0,0.5, "squirrels?","Arial",15, 0 )
local btn12 = Button:new(250,170,70,70, 0.5,0.3,0.4,1.0, "double\n check","Arial",15, 0 )

local Button_TB = {btn1,btn2,btn3,btn4,btn5,btn6,btn7,btn8,btn9,btn10,btn11,btn12}


add_marker_to_play_pos =  function(name, r,g,b)
                            local play_state = reaper.GetPlayState()
                            local floor = math.floor
                            r = floor(r*255+0.5)
                            g = floor(g*255+0.5)
                            b = floor(b*255+0.5)                            
                            local int_col=reaper.ColorToNative(r, g, b)|0x1000000
                            reaper.Undo_BeginBlock()
							if play_state == 0 or play_state&2 == 2 then position=reaper.GetCursorPosition() else position=reaper.GetPlayPosition() end
                            reaper.AddProjectMarker2(0, false, position, 0, name, -1, int_col)
                            reaper.Undo_EndBlock("Live Take Commenter - add marker", -1)
                          end 
                          
-- Add "on click function" for each button
for i=1, #Button_TB do
  local curr_btn = Button_TB[i]
  curr_btn.onClick =
                      function()
                        add_marker_to_play_pos(curr_btn.lbl, curr_btn.r, curr_btn.g, curr_btn.b)
						if hotkey<49 and hotkey >57 and hotkey ~= 32 and hotkey ~= 42 then -- not numkeys, spacebar or * in numpad
                        reaper.Main_OnCommand(reaper.NamedCommandLookup("_BR_FOCUS_ARRANGE_WND"),0)	-- Set focus to arrange view
						end
                      end
end
----------------------------------------------------------------------------------------------------
---   Main DRAW function   -------------------------------------------------------------------------

function DRAW()
    for key,btn  in pairs(Button_TB) do btn:draw()  end 
end

--------------------------------------------------------------------------------
--   INIT   --------------------------------------------------------------------

function Init()
    --Some gfx Wnd Default Values--------------
    local R,G,B = 20,20,20        --0..255 form
    Wnd_bgd = R + G*256 + B*65536 --red+green*256+blue*65536  
    Wnd_Title,Wnd_W,Wnd_H,Wnd_Dock,Wnd_X,Wnd_Y = "Live Take Commenter", 330,250, 0,100,320
    --Init window------------------------------
    gfx.clear = Wnd_bgd         
    gfx.init( Wnd_Title, Wnd_W,Wnd_H, Wnd_Dock, Wnd_X,Wnd_Y )
    --Mouse--------------
    last_mouse_cap = 0
    last_x, last_y = 0, 0
end
----------------------------------------
--   Mainloop   ------------------------

function mainloop()
    Z_w,Z_h = gfx.w/Wnd_W, gfx.h/Wnd_H
    if gfx.mouse_cap&1==1 and last_mouse_cap&1==0 then 
       mouse_ox, mouse_oy = gfx.mouse_x, gfx.mouse_y 
    end
    Ctrl  = gfx.mouse_cap&4==4
    Shift = gfx.mouse_cap&8==8
    -----------------------
    --DRAW,MAIN functions--
      DRAW()--Main() 
    -----------------------
    -----------------------
    last_mouse_cap = gfx.mouse_cap
    last_x, last_y = gfx.mouse_x, gfx.mouse_y
    hotkey = gfx.getchar()
	if hotkey>=49 and hotkey <=57 then -- numkeys
		Button_TB[hotkey-48].onClick()
	end
	if hotkey == 32 then  -- spacebar
		reaper.Main_OnCommand("40044",0) -- play stop
	end
	if hotkey == 42 then  -- * in numpad
		reaper.Main_OnCommand("1013",0) -- record
	end
    if hotkey~=-1 then reaper.defer(mainloop) end --defer
    -----------  
    gfx.update()
    -----------
end
Init()
mainloop()
__________________
Dax Liniere
London's newest premium studio complex! (Facebook)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia GT710, UAD2-OCTO, FireFaceUFX, REAPER x64]

Last edited by daxliniere; 05-07-2016 at 02:25 AM.
daxliniere is offline   Reply With Quote
Old 05-07-2016, 02:33 AM   #51
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 5,826
Default

ah ok. sorry I commented without testing. of course focus is changed too pressing numpad keys because it calls the same onclick function. it could be easilly changed to a new function for example onClick for clicking with the mouse and onClickKey for numpads

Code:
  curr_btn.onClick = function()
                        add_marker_to_play_pos(curr_btn.lbl, curr_btn.r, curr_btn.g, curr_btn.b)
						-- Set focus to arrange view when button is released
                        reaper.Main_OnCommand(reaper.NamedCommandLookup("_BR_FOCUS_ARRANGE_WND"),0)
                      
                      end
curr_btn.onClickKey =
                      function()
                        add_marker_to_play_pos(curr_btn.lbl, curr_btn.r, curr_btn.g, curr_btn.b)
                      
                      end	
then
Code:
if char>=49 and char <=57 then -- numkeys
	Button_TB[char-48].onClickKey()
  end
Yes I think 9 buttons should be enough
heda is offline   Reply With Quote
Old 05-07-2016, 04:30 AM   #52
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 1,980
Default

Quote:
Originally Posted by heda View Post
ah ok. sorry I commented without testing. of course focus is changed too pressing numpad keys because it calls the same onclick function. it could be easilly changed to a new function for example onClick for clicking with the mouse and onClickKey for numpads
Which code is this applied to? The code from my post #50 or the current release version? (before I played around with the if hotkey<49 and hotkey >57 and hotkey ~= 32 and hotkey ~= 42 then -- not numkeys, spacebar or * in numpad line)

Quote:
Originally Posted by heda View Post
Yes I think 9 buttons should be enough
What do you mean by this? Are you saying Numpad* and spacebar 'pass-through' are not required? But what if the floating window is in focus? Won't that block spacebar/Numpad* ?
__________________
Dax Liniere
London's newest premium studio complex! (Facebook)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia GT710, UAD2-OCTO, FireFaceUFX, REAPER x64]
daxliniere is offline   Reply With Quote
Old 05-07-2016, 05:46 AM   #53
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 5,826
Default

applied to current release

I mean 9 buttons to match the number pad keys is good. I could remove lumpy, squirrels and double check.
heda is offline   Reply With Quote
Old 05-07-2016, 10:36 AM   #54
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by heda View Post
@spk77: oh wow _BR_FOCUS_ARRANGE_WND ? Is that new? I didn't know! But does it create undo point?
I used reaper.SetCursorContext(0, env)
But I don't know why that funciton needs an envelope as argument.
It doesn't create undo points (quickly tested).
I've also been wondering why there has to be the "env" parameter in SetCursorContext.
spk77 is offline   Reply With Quote
Old 05-08-2016, 08:27 AM   #55
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 1,980
Default

Quote:
Originally Posted by heda View Post
I mean 9 buttons to match the number pad keys is good. I could remove lumpy, squirrels and double check.
Squirrels was just a bit of a joke because 11 comments came to mind and it's an uneven number. (I did consider leaving it blank, but that's not funny. )
__________________
Dax Liniere
London's newest premium studio complex! (Facebook)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia GT710, UAD2-OCTO, FireFaceUFX, REAPER x64]
daxliniere is offline   Reply With Quote
Old 05-08-2016, 12:27 PM   #56
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 1,980
Default

Quote:
Originally Posted by heda View Post
applied to current release
Sorry man, I can't get your changes to work. Here is current code, would you be able to take a look at it, please? Or perhaps you'd post your current code, please?

Also, I'd love to have the project markers removed as soon as they're inserted. Any ideas for that?

Code:
--------------------------------------------------------------------------------
---   Live Take Commenter   ----------------------------------------------------
---   GUI code by Eugen2777  ---------------------------------------------------
---   Marker writing code by spk77  --------------------------------------------
---   Operate during stop-mode code by HeDa  -----------------------------------
---   Hotkey code by HeDa   ----------------------------------------------------
---   Return focus to Arrange Window (pass keystrokes through) by spk77  -------
---   Writing cue to WAV code by ????? -----------------------------------------
---   Concept by Dax Liniere  --------------------------------------------------

local Element = {}
function Element:new(x,y,w,h, r,g,b,a, lbl,fnt,fnt_sz, norm_val)
    local elm = {}
    elm.def_xywh = {x,y,w,h,fnt_sz} -- its default coord,used for Zoom etc
    elm.x, elm.y, elm.w, elm.h = x, y, w, h
    elm.r, elm.g, elm.b, elm.a = r, g, b, a
    elm.lbl, elm.fnt, elm.fnt_sz  = lbl, fnt, fnt_sz
    elm.norm_val = norm_val
    ------
    setmetatable(elm, self)
    self.__index = self 
    return elm
end
--------------------------------------------------------------
--- Function for Child Classes(args = Child,Parent Class) ----

function extended(Child, Parent)
  setmetatable(Child,{__index = Parent}) 
end
--------------------------------------------------------------
---   Element Class Methods(Main Methods)   ------------------

function Element:update_xywh()
  if not Z_w or not Z_h then return end -- return if zoom not defined
  if Z_w>0.5 and Z_w<3 then  
   self.x, self.w = math.ceil(self.def_xywh[1]* Z_w) , math.ceil(self.def_xywh[3]* Z_w) --upd x,w
  end
  if Z_h>0.5 and Z_h<3 then
   self.y, self.h = math.ceil(self.def_xywh[2]* Z_h) , math.ceil(self.def_xywh[4]* Z_h) --upd y,h
  end
  if Z_w>0.5 or Z_h>0.5  then --fix it!--
     self.fnt_sz = math.max(9,self.def_xywh[5]* (Z_w+Z_h)/2)
     self.fnt_sz = math.min(22,self.fnt_sz)
  end       
end
--------
function Element:pointIN(p_x, p_y)
  return p_x >= self.x and p_x <= self.x + self.w and p_y >= self.y and p_y <= self.y + self.h
end
--------
function Element:mouseIN()
  return gfx.mouse_cap&1==0 and self:pointIN(gfx.mouse_x,gfx.mouse_y)
end
--------
function Element:mouseDown()
  return gfx.mouse_cap&1==1 and self:pointIN(mouse_ox,mouse_oy)
end
--------
function Element:mouseClick()
  return gfx.mouse_cap&1==0 and last_mouse_cap&1==1 and
  self:pointIN(gfx.mouse_x,gfx.mouse_y) and self:pointIN(mouse_ox,mouse_oy)         
end
--------
function Element:draw_frame()
  local x,y,w,h  = self.x,self.y,self.w,self.h
  gfx.rect(x, y, w, h, 0)--frame1
  gfx.roundrect(x, y, w-1, h-1, 3, true)--frame2         
end
--------------------------------------------------------------------------------
---   Create Element Child Classes(Button,Slider,Knob)   -----------------------

local Button ={}; local Knob ={}; local Slider ={}; 
  extended(Button, Element)
  extended(Knob,   Element)
  extended(Slider, Element)
---Create Slider Child Classes(V_Slider,H_Slider)----
local H_Slider ={}; local V_Slider ={};
  extended(H_Slider, Slider)
  extended(V_Slider, Slider)

--------------------------------------------------------------------------------
---   Button Class Methods   ---------------------------------------------------

function Button:draw_lbl()
    local x,y,w,h  = self.x,self.y,self.w,self.h
    local fnt,fnt_sz = self.fnt, self.fnt_sz
    --Draw btn lbl(text)--
      gfx.set(0.7, 1, 0, 1)--set label color
      gfx.setfont(1, fnt, fnt_sz);--set label fnt
        local lbl_w, lbl_h = gfx.measurestr(self.lbl)
        gfx.x = x+(w-lbl_w)/2; gfx.y = y+(h-lbl_h)/2
        gfx.drawstr(self.lbl)
end
---------------------
function Button:draw()
    self:update_xywh()--Update xywh(if wind changed)
    local x,y,w,h  = self.x,self.y,self.w,self.h
    local r,g,b,a  = self.r,self.g,self.b,self.a
    ---Get L_mouse state--
          --in element--
          if self:mouseIN() then a=a+0.1 end
          --in elm L_down--
          if self:mouseDown() then a=a+0.2 end
          --in elm L_up(released and was previously pressed)--
          if self:mouseClick() then self.onClick() end
    --Draw btn(body,frame)--
    gfx.set(r,g,b,a)--set btn color
    gfx.rect(x,y,w,h,true)--body
    self:draw_frame()
    ------------------------
    self:draw_lbl()
end

----------------------------------------------------------------------------------------------------
---   START   --------------------------------------------------------------------------------------

local btn1 = Button:new(10,10,70,70, 0.2,0.2,1.0,0.5, "PERFECT","Arial",15, 0 )
local btn2 = Button:new(90,10,70,70, 0.0,1.0,0.0,0.5, "good","Arial",15, 0 )
local btn3 = Button:new(170,10,70,70, 0.0,1.0,0.0,0.5, "not bad","Arial",15, 0 )
local btn4 = Button:new(250,10,70,70, 0.0,1.0,0.0,0.5, "okay","Arial",15, 0 )
local btn5 = Button:new(10,90,70,70, 1.0,0.0,0.0,0.5, "sharp","Arial",15, 0 )
local btn6 = Button:new(90,90,70,70, 1.0,0.0,0.0,0.5, "flat","Arial",15, 0 )
local btn7 = Button:new(170,90,70,70, 1.0,0.0,0.0,0.5, "early","Arial",15, 0 )
local btn8 = Button:new(250,90,70,70, 1.0,0.0,0.0,0.5, "late","Arial",15, 0 )
local btn9 = Button:new(10,170,70,70, 1.0,0.0,0.0,0.5, "lumpy","Arial",15, 0 )
local btn10 = Button:new(90,170,70,70, 1.0,0.0,0.0,0.5, "no energy","Arial",15, 0 )
local btn11 = Button:new(170,170,70,70, 1.0,0.0,0.0,0.5, "","Arial",15, 0 )
local btn12 = Button:new(250,170,70,70, 0.5,0.3,0.4,1.0, "double\n check","Arial",15, 0 )

local Button_TB = {btn1,btn2,btn3,btn4,btn5,btn6,btn7,btn8,btn9,btn10,btn11,btn12}


add_marker_to_play_pos =  function(name, r,g,b)
                            local play_state = reaper.GetPlayState()
                            local floor = math.floor
                            r = floor(r*255+0.5)
                            g = floor(g*255+0.5)
                            b = floor(b*255+0.5)                            
                            local int_col=reaper.ColorToNative(r, g, b)|0x1000000
                            reaper.Undo_BeginBlock()
							if play_state == 0 or play_state&2 == 2 then position=reaper.GetCursorPosition() else position=reaper.GetPlayPosition() end
                            reaper.AddProjectMarker2(0, false, position, 0, name, -1, int_col)
                            reaper.Undo_EndBlock("Live Take Commenter - add marker", -1)
                          end 
                          
-- Add "on click function" for each button
for i=1, #Button_TB do
  local curr_btn = Button_TB[i]
  curr_btn.onClick =
                      function()
                        add_marker_to_play_pos(curr_btn.lbl, curr_btn.r, curr_btn.g, curr_btn.b)
						if hotkey<49 and hotkey >57 and hotkey ~= 32 and hotkey ~= 42 then -- not numkeys, spacebar or * in numpad
                        reaper.Main_OnCommand(reaper.NamedCommandLookup("_BR_FOCUS_ARRANGE_WND"),0)	-- Set focus to arrange view
						end
                      end
end
----------------------------------------------------------------------------------------------------
---   Main DRAW function   -------------------------------------------------------------------------

function DRAW()
    for key,btn  in pairs(Button_TB) do btn:draw()  end 
end

--------------------------------------------------------------------------------
--   INIT   --------------------------------------------------------------------

function Init()
    --Some gfx Wnd Default Values--------------
    local R,G,B = 20,20,20        --0..255 form
    Wnd_bgd = R + G*256 + B*65536 --red+green*256+blue*65536
    Wnd_Title,Wnd_W,Wnd_H,Wnd_Dock,Wnd_X,Wnd_Y = "Live Take Commenter", 330,250, 0,100,320
    --Init window------------------------------
    gfx.clear = Wnd_bgd
    gfx.init( Wnd_Title, Wnd_W,Wnd_H, Wnd_Dock, Wnd_X,Wnd_Y )
    --Mouse--------------
    last_mouse_cap = 0
    last_x, last_y = 0, 0
end
----------------------------------------
--   Mainloop   ------------------------

function mainloop()
    Z_w,Z_h = gfx.w/Wnd_W, gfx.h/Wnd_H
    if gfx.mouse_cap&1==1 and last_mouse_cap&1==0 then
       mouse_ox, mouse_oy = gfx.mouse_x, gfx.mouse_y
    end
    Ctrl  = gfx.mouse_cap&4==4
    Shift = gfx.mouse_cap&8==8
    -----------------------
    --DRAW,MAIN functions--
      DRAW()--Main()
    -----------------------
    -----------------------
    last_mouse_cap = gfx.mouse_cap
    last_x, last_y = gfx.mouse_x, gfx.mouse_y
    hotkey = gfx.getchar()
	if hotkey>=49 and hotkey <=57 then -- numkeys
		Button_TB[hotkey-48].onClick()
	end
	if hotkey == 32 then  -- spacebar
		reaper.Main_OnCommand("40044",0) -- play stop
	end
	if hotkey == 42 then  -- * in numpad
		reaper.Main_OnCommand("1013",0) -- record
	end
    if hotkey~=-1 then reaper.defer(mainloop) end --defer
    -----------
    gfx.update()
    -----------
end
Init()
mainloop()
__________________
Dax Liniere
London's newest premium studio complex! (Facebook)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia GT710, UAD2-OCTO, FireFaceUFX, REAPER x64]
daxliniere is offline   Reply With Quote
Old 05-09-2016, 04:42 AM   #57
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 5,826
Default

Hi Dax,
here is my latest code. I've added the removal of markers when stops recording. Try it.

https://stash.reaper.fm/27532/Live%20...0Commenter.lua
heda is offline   Reply With Quote
Old 05-09-2016, 05:07 AM   #58
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 1,980
Default

Quote:
Originally Posted by heda View Post
Hi Dax,
here is my latest code. I've added the removal of markers when stops recording. Try it.
Thanks man, this is beautiful!!
Nice work on the focus/passthrough stuff, too.
__________________
Dax Liniere
London's newest premium studio complex! (Facebook)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia GT710, UAD2-OCTO, FireFaceUFX, REAPER x64]
daxliniere is offline   Reply With Quote
Old 05-09-2016, 09:45 AM   #59
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 1,980
Default

Okay, the first post is updated. I'm going to create a post in another forum to let people know this exists.

Thanks again to everyone!!
__________________
Dax Liniere
London's newest premium studio complex! (Facebook)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia GT710, UAD2-OCTO, FireFaceUFX, REAPER x64]
daxliniere is offline   Reply With Quote
Old 05-10-2016, 09:02 AM   #60
mamazai
Human being with feelings
 
Join Date: Oct 2009
Posts: 357
Default

Cool script, is it possible play mode ?
mamazai is offline   Reply With Quote
Old 05-10-2016, 09:04 AM   #61
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 1,980
Default

Quote:
Originally Posted by mamazai View Post
Cool script, is it possible play mode ?
Yes, but not to write markers into audio files.
__________________
Dax Liniere
London's newest premium studio complex! (Facebook)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia GT710, UAD2-OCTO, FireFaceUFX, REAPER x64]
daxliniere is offline   Reply With Quote
Old 05-10-2016, 09:58 AM   #62
mamazai
Human being with feelings
 
Join Date: Oct 2009
Posts: 357
Default

Ok, script only insert markers and after recording deleted but not write comments. Project settings is O.K. What's wrong with that ?
mamazai is offline   Reply With Quote
Old 05-10-2016, 10:11 AM   #63
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 1,980
Default

Quote:
Originally Posted by mamazai View Post
Ok, script only insert markers and after recording deleted but not write comments. Project settings is O.K. What's wrong with that ?
You need to ensure that BWF is enabled in Project settings and you've chosen one of the modes that containers markers. ("Markers only", "Markers and regions", etc)
__________________
Dax Liniere
London's newest premium studio complex! (Facebook)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia GT710, UAD2-OCTO, FireFaceUFX, REAPER x64]
daxliniere is offline   Reply With Quote
Old 05-10-2016, 11:59 AM   #64
mamazai
Human being with feelings
 
Join Date: Oct 2009
Posts: 357
Default

Settings O.K that I said, but it doesn't work unfortunately.
mamazai is offline   Reply With Quote
Old 05-16-2016, 07:14 AM   #65
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 1,980
Default

Hi Mamazai,
Please show me a video of it not working. Remember it can only write markers into the audio files during record mode while markers are enabled for BWF .WAV mode.
__________________
Dax Liniere
London's newest premium studio complex! (Facebook)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia GT710, UAD2-OCTO, FireFaceUFX, REAPER x64]
daxliniere is offline   Reply With Quote
Old 05-16-2016, 10:39 AM   #66
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 1,968
Default

Hi,
I thought I'd mention this (sorry if it already was)

If the settings are set right as Dax has mentioned
"You need to ensure that BWF is enabled in Project settings and you've chosen one of the modes that containers markers. ("Markers only", "Markers and regions", etc)"

If you still don't see any cues on the items, it's a possibility that the action View: Toggle show media cues in items is off.

Run this action View: Toggle show media cues in items, and make sure it's on.

Hope that helps,
Regards,
Wyatt
WyattRice is online now   Reply With Quote
Old 05-16-2016, 10:49 AM   #67
mamazai
Human being with feelings
 
Join Date: Oct 2009
Posts: 357
Default

Quote:
Originally Posted by WyattRice View Post
Hi,
I thought I'd mention this (sorry if it already was)

If the settings are set right as Dax has mentioned
"You need to ensure that BWF is enabled in Project settings and you've chosen one of the modes that containers markers. ("Markers only", "Markers and regions", etc)"

If you still don't see any cues on the items, it's a possibility that the action View: Toggle show media cues in items is off.

Run this action View: Toggle show media cues in items, and make sure it's on.

Hope that helps,
Regards,
Wyatt
Yes, you're right. Thanks. Problem is solved friends.
mamazai is offline   Reply With Quote
Old 05-16-2016, 12:10 PM   #68
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 1,980
Default

Quote:
Originally Posted by WyattRice View Post
Run this action View: Toggle show media cues in items, and make sure it's on.
Ahh, excellent, thanks for that, Wyatt!
I'll add that to the first post.

Quote:
Originally Posted by mamazai View Post
Yes, you're right. Thanks. Problem is solved friends.
Great, I'm glad you can use it now.
__________________
Dax Liniere
London's newest premium studio complex! (Facebook)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia GT710, UAD2-OCTO, FireFaceUFX, REAPER x64]
daxliniere is offline   Reply With Quote
Old 05-16-2016, 01:29 PM   #69
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 1,968
Default

You guys could probably add check toggle state to the script, and do a check to see if its on or off.

if reaper.GetToggleCommandState(40691) == false then

reaper.Main_OnCommand(40691, 0)

then when the script is exited or window closes, return it back where it was.
WyattRice is online now   Reply With Quote
Old 05-16-2016, 01:56 PM   #70
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 1,980
Default

Quote:
Originally Posted by WyattRice View Post
You guys could probably add check toggle state to the script, and do a check to see if its on or off. Then when the script is exited or window closes, return it back where it was.
Hmm.. that's a very good idea, Wyatt.

So upon open of GUI, if it's off, turn it on and when the GUI is closed, turn it back off if it was off.
However, this depends of the script being able to tell if it is closed and to run one last action at that time.

I don't think that's possible unless we specifically added a Close/Exit button.

I am in favour of adding a line that switches it on and leaves it on.
__________________
Dax Liniere
London's newest premium studio complex! (Facebook)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia GT710, UAD2-OCTO, FireFaceUFX, REAPER x64]
daxliniere is offline   Reply With Quote
Old 05-16-2016, 02:19 PM   #71
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 9,635
Default

Quote:
Originally Posted by daxliniere View Post
However, this depends of the script being able to tell if it is closed and to run one last action at that time.
There's atexit() in the Reaper API which could be used for this I think.
nofish is offline   Reply With Quote
Old 05-16-2016, 03:56 PM   #72
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 5,826
Default

put this before running init()
Code:
function exitnow()
  is_new_value,filename,sectionID,cmdID,mode,resolution,val = reaper.get_action_context()
  reaper.SetToggleCommandState(sectionID, cmdID, 0)
  reaper.RefreshToolbar2(sectionID, cmdID)
end
reaper.atexit(exitnow)
and this in the init funciton

Code:
is_new_value,filename,sectionID,cmdID,mode,resolution,val = reaper.get_action_context()
  reaper.SetToggleCommandState(sectionID, cmdID, 1)
  reaper.RefreshToolbar2(sectionID, cmdID)
heda is offline   Reply With Quote
Old 05-17-2016, 01:13 AM   #73
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 1,980
Default

Quote:
Originally Posted by heda View Post
put this before running init()...
Done. Thanks, Hector!

(link updated)
__________________
Dax Liniere
London's newest premium studio complex! (Facebook)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia GT710, UAD2-OCTO, FireFaceUFX, REAPER x64]
daxliniere is offline   Reply With Quote
Old 05-17-2016, 08:38 PM   #74
eugen2777
Human being with feelings
 
eugen2777's Avatar
 
Join Date: Aug 2012
Posts: 271
Default

Adding markers directly into a file.

However, I do not think this is a good way.
Just I was wondering.
__________________
ReaScripts
eugen2777 is offline   Reply With Quote
Old 05-17-2016, 09:58 PM   #75
Garrick
Human being with feelings
 
Garrick's Avatar
 
Join Date: Jul 2009
Location: Wellington
Posts: 4,613
Default

Pretty complex scripting getting the marker written to the source file but great to see what can be done.
I was wondering if there was a way make a dummy item automation envelope and envelope points being place holders for stuff like this. I've combed through the API but only see track envelopes.

My head hurts
Garrick is offline   Reply With Quote
Old 05-18-2016, 03:44 PM   #76
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 1,980
Default

Quote:
Originally Posted by eugen2777 View Post
Adding markers directly into a file.

However, I do not think this is a good way.
Just I was wondering.
Hmmm, well if you think this is not safe, then perhaps we should not implement it.
I really like the idea of doing it that way, but if we cannot be 100% sure it's safe, then best to leave that out.

Thank you very much, Eugen, for your time to test it out. I do appreciate it.
__________________
Dax Liniere
London's newest premium studio complex! (Facebook)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia GT710, UAD2-OCTO, FireFaceUFX, REAPER x64]
daxliniere is offline   Reply With Quote
Old 05-18-2016, 05:13 PM   #77
eugen2777
Human being with feelings
 
eugen2777's Avatar
 
Join Date: Aug 2012
Posts: 271
Default

Maybe I could do it more accurately after some time.
I want to study it, to avoid damage to existing markers and other data
__________________
ReaScripts
eugen2777 is offline   Reply With Quote
Old 05-24-2016, 02:31 AM   #78
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,516
Default ReaTeam Repo Upload

As requested by Daxliniere, I uploaded the Live Take Commenter on ReaTeam repo.
The file name is :
daxliniere_Live recording take commenter.lua

A ReaPack friendly script header has been added with information about the script (contributors, version, release date etc).

If you want to make modifications on it, join ReaTeam or fork the file on GitHub.

Thanks to all for your work on this!
X-Raym is offline   Reply With Quote
Old 05-24-2016, 03:43 PM   #79
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 1,980
Default

Quote:
Originally Posted by eugen2777 View Post
Maybe I could do it more accurately after some time.
I want to study it, to avoid damage to existing markers and other data
Yes, I understand perfectly.
__________________
Dax Liniere
London's newest premium studio complex! (Facebook)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia GT710, UAD2-OCTO, FireFaceUFX, REAPER x64]
daxliniere is offline   Reply With Quote
Old 05-24-2016, 03:43 PM   #80
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 1,980
Default Re: ReaTeam Repo Upload

Thanks a lot Raymond!!
__________________
Dax Liniere
London's newest premium studio complex! (Facebook)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia GT710, UAD2-OCTO, FireFaceUFX, REAPER x64]
daxliniere 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 06:47 AM.


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