Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Developer Forum

Reply
 
Thread Tools Display Modes
Old 04-02-2018, 12:52 PM   #361
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

How do I execute some code at the project load/switch?

I was using fixed arrays of 1024 elements to store tracks data (mute/pan/vol/etc) and decided to switch to vector of objects, with a single object for each track, containing the necessary data.
I've also added a resize vector method into the Run() function and in every function, that is called by Reaper (there are bunch of them already in the example).
It was going fine until I've tried to load an existing project. Reaper then crashed with vector subscript out of range error.
I guess, resize should also be executed at the project loading or switching to another project's tab, but I don't know ho do I track it. Any help would be appreciated.

UPD. For some unknown reason, Reaper was calling track related function even when there weren't any tracks in the project, so it was giving the track number -1, which lead to crash, when the plugin tried to write track's vol/pan/etc state into the vector at index '-1'.
I don't know why does reaper_plugin.h calls those functions for track -1, so I've simply added a check, if the tracks number is zero or positive.

Last edited by fundorin; 04-02-2018 at 01:41 PM.
fundorin is offline   Reply With Quote
Old 05-04-2018, 05:17 PM   #362
sai'ke
Human being with feelings
 
sai'ke's Avatar
 
Join Date: Aug 2009
Location: Germoney
Posts: 81
Default

When I call the following:

Code:
  -- Fetch all the tracks
  for i=0,tracks-1 do
    local track   = reaper.GetTrack(project, i)  

    local ret, name = reaper.GetTrackName(track, "                                                              ")
    if ( name ~= "MASTER" ) then  
      local sendidx = reaper.CreateTrackSend(track, spectroTrack)
      local sn = reaper.SetTrackSendInfo_Value(track, 0, sendidx, "I_DSTCHAN", 2*i)
    end
  end

it seems that SetTrackSendInfo_Value doesn't actually create "new" audio channels. It only works for the ones that already exist 1/2, 3/4, 5/6. What's also interesting is that if I go to that track, and I try to add them manually, it still doesn't give me the options 7/8 and higher until I've fiddled around with all the inputs made by the script.

Is it possible to create new audio dest channels from lua (preferably without SWS)?
sai'ke is offline   Reply With Quote
Old 05-05-2018, 12:21 AM   #363
azslow3
Human being with feelings
 
Join Date: Nov 2017
Location: Heidelberg, Germany
Posts: 356
Default

I think adding the following before loop
Code:
reaper.SetMediaTrackInfo_Value(spectroTrack, "I_NCHAN", tracks*2)
should do the trick
azslow3 is offline   Reply With Quote
Old 05-05-2018, 04:02 AM   #364
sai'ke
Human being with feelings
 
sai'ke's Avatar
 
Join Date: Aug 2009
Location: Germoney
Posts: 81
Default

Quote:
Originally Posted by azslow3 View Post
I think adding the following before loop
Code:
reaper.SetMediaTrackInfo_Value(spectroTrack, "I_NCHAN", tracks*2)
should do the trick
Thanks man, it did!
sai'ke is offline   Reply With Quote
Old 05-17-2018, 08:39 PM   #365
ausbaxter
Human being with feelings
 
Join Date: Apr 2016
Posts: 27
Default

Is there a way to get a mouse left click or any click event outside of a gfx window? (preferably without having to instantiate a window at all) As far as I've seen in the API there isn't a way to do this. I'm looking to run code between mouse down and up events within the reaper arrange window.

I'm looking more into python which seems to have some libraries to help, but I'm really hoping to keep this script in lua or eel.
ausbaxter is offline   Reply With Quote
Old 07-07-2018, 03:14 PM   #366
olilarkin
Human being with feelings
 
olilarkin's Avatar
 
Join Date: Apr 2009
Location: Huddersfield, UK
Posts: 1,098
Default

How do I get the "pin" icon in the top right hand corner to keep my window (generated from reaper extension" on top?

thanks

oli
__________________
VirtualCZ | pMix | Endless Series | WDL-OL | Linkedin | Facebook
Available for Audio Dev tuition via Skype (IPlug/JUCE/C++)
olilarkin is offline   Reply With Quote
Old 07-07-2018, 07:59 PM   #367
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 1,945
Default

SWS does it with the undocumented API function AttachWindowTopmostButton when handling WM_INITDIALOG. It's not included in reaper_plugin_functions.h.

Code:
void (*AttachWindowTopmostButton)(HWND hwnd);
cfillion is online now   Reply With Quote
Old 07-08-2018, 05:27 AM   #368
olilarkin
Human being with feelings
 
olilarkin's Avatar
 
Join Date: Apr 2009
Location: Huddersfield, UK
Posts: 1,098
Default

thanks!
__________________
VirtualCZ | pMix | Endless Series | WDL-OL | Linkedin | Facebook
Available for Audio Dev tuition via Skype (IPlug/JUCE/C++)
olilarkin 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 04:46 AM.


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