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: 114
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: 454
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: 114
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: 33
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,111
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: 2,191
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,111
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
Old 08-25-2018, 11:52 AM   #369
mrelwood
Human being with feelings
 
mrelwood's Avatar
 
Join Date: Nov 2006
Location: Finland
Posts: 1,237
Default

In short, I can't get a graphical slider to run commands in the @slider section in a JS plugin. I expected the slider_automate(sliderX) to do just that. Was I wrong?

In detail:

I have a graphical slider that I wish to use to adjust a basic JS slider1. The slider1 itself adjusts fine, but I can't get it to run the commands in the @slider section.

Say the graphical slider adjusts a parameter called "gfxslider". Even if:

Code:
@slider
parameter1 = slider1;

...

@gfx
slider1 != gfxslider ? (
  slider1 = gfxslider;
  slider_automate(slider1);
  );
The last part can be in @block or @sample, same result, slider1 changes but "parameter1" does not. Only way I've found is to have the "parameter1 = slider1" command in @block, @sample or @gfx instead of the @slider section.
__________________
______Announcing__mrelwood plugins______
.. MacBook Pro 15" Late '13 .. Focusrite: Scarlett 6i6, Saffire Pro 24 DSP (+ADA8000) .. Behringer FCA610 .. Focal: Alpha 65, CMS 40, Listen Pro ..
mrelwood is online now   Reply With Quote
Old 08-25-2018, 01:27 PM   #370
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Germany
Posts: 5,726
Default

Rather obviously @slider is only called when a slider is modified from outside the JSFX code.

You might try to do a function that contains what you want to do in @slider and do something like

Code:
@init 
  function do_slider() (
    parameter1 = slider1;
  );

@slider
  do_slider();

@gfx
  slider1 != gfxslider ? (
    slider1 = gfxslider;
    do_slider();
  );
__________________
www.boa-sorte.de
mschnell is offline   Reply With Quote
Old 08-25-2018, 02:12 PM   #371
D Rocks
Human being with feelings
 
Join Date: Dec 2017
Location: Quebec, Canada
Posts: 422
Default

Hey guys,

Is it possible to use the SWS marque zoom tool with a mouse modifier and NOT the middle mouse button drag? I find that this middle click often messes up with my mouse moving the wheel by accident. This mouse also has left right move for the middle button so it also messes up the middle drag.
I'd like to use the SWS Zoom tool exactly as is works by default but with right button drag rather than middle click.

is it possible?

Yes, I've tried the action menu but this way it introduces an on/off state and you need mutiple clicks. I've also tried Autohotkey to disable my left/right middle button triggers but it doesnt help since the middle click is considered released
__________________
Alex | www.drocksrecords.com | Thanks for REAPER

Last edited by D Rocks; 08-25-2018 at 02:22 PM.
D Rocks is offline   Reply With Quote
Old 08-25-2018, 02:44 PM   #372
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,051
Default

Marquee zoom is also available as Mouse modifier, Arrange view -> right drag.
Wouldn't that do as substitute ?

edit:
I don't think Reaper's native marquee zoom has the undo functionality SWS zoom tool has though, so probably not a full substitute.

Last edited by nofish; 08-25-2018 at 03:12 PM.
nofish is online now   Reply With Quote
Old 08-25-2018, 03:06 PM   #373
D Rocks
Human being with feelings
 
Join Date: Dec 2017
Location: Quebec, Canada
Posts: 422
Default

yes it works but the only problem I didnt find how to manage is that this zoom is not considered as an undo step for the SWS undo zoom.
I don't want the SWS to undo MouseWheel zoom steps cause its a waste of time, but lets say I use the Reaper Marquee zoom, it will be ignored fro the undo history. This is the only thing that makes me absolutely want to use the SWS marquee instead.

thanks for reply
__________________
Alex | www.drocksrecords.com | Thanks for REAPER
D Rocks is offline   Reply With Quote
Old 08-25-2018, 03:19 PM   #374
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,051
Default

Ah right, I edited my post before I saw yours, didn't think about the special undo zoom feature in SWS zoom tool at first.

I don't know if it's possible to use it in any other way than middle mouse button though (that's how I use it), sorry.
nofish is online now   Reply With Quote
Old 08-25-2018, 06:47 PM   #375
D Rocks
Human being with feelings
 
Join Date: Dec 2017
Location: Quebec, Canada
Posts: 422
Default

No prob man theres alot of little details making this feature great. Thanks for taking time.

Any other insights?
__________________
Alex | www.drocksrecords.com | Thanks for REAPER
D Rocks is offline   Reply With Quote
Old 09-06-2018, 12:57 AM   #376
Aries1985
Human being with feelings
 
Join Date: Jul 2011
Posts: 30
Default How to set value of plugin parameter displayed as TCP FX?

Hello guys,
is there an easy way how to set value for parameter displayed in TCP FX?

I have noticed functions CountTCPFXParms and GetTCPFXParm but nothing for setting value.

Any help is greatly appreciated!
Aries1985 is offline   Reply With Quote
Old 09-06-2018, 09:58 AM   #377
tparker24
Human being with feelings
 
Join Date: Dec 2017
Posts: 35
Default

Perhaps TrackFX_SetParam
tparker24 is offline   Reply With Quote
Old 09-06-2018, 11:48 AM   #378
Aries1985
Human being with feelings
 
Join Date: Jul 2011
Posts: 30
Default

Ah, I checked once more documentation for GetTCPFXParm - I did not realize it returns fx index and parameter index.

TrackFX_SetParam is the correct function, then.

Thanks.
Aries1985 is offline   Reply With Quote
Old 09-18-2018, 06:25 AM   #379
sai'ke
Human being with feelings
 
sai'ke's Avatar
 
Join Date: Aug 2009
Location: Germoney
Posts: 114
Default

I'm not sure if I'm using this command correctly but TrackFX_AddByName( track, fxname, recFX, instantiate ) doesn't seem to work for me for JSFX or VSTs with spaces in the name. I always figured it took the same name as in the search field, but I guess it doesn't?

What should I use here?
__________________
[Soundcloud] | [Tracker Plugin: Thread|Github|Reapack link] | [Machine UI Plugin: Thread|Github|Reapack link] | [Spectral Analyzer: Github]
sai'ke is offline   Reply With Quote
Old 10-02-2018, 04:42 PM   #380
sai'ke
Human being with feelings
 
sai'ke's Avatar
 
Join Date: Aug 2009
Location: Germoney
Posts: 114
Default

If anyone runs into the previous issue in the future. Seems that for JSFX it takes filenames... not sure why.

I have a new question though. How do I get the true length of an item (not the length on the arranger)? When stretching a MIDI or audio item, the item repeats and these notches appear. Is there a way to poll how long an item actually is (not D_LENGTH) in seconds from lua?
__________________
[Soundcloud] | [Tracker Plugin: Thread|Github|Reapack link] | [Machine UI Plugin: Thread|Github|Reapack link] | [Spectral Analyzer: Github]
sai'ke is offline   Reply With Quote
Old 10-02-2018, 05:06 PM   #381
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,051
Default

GetMediaSourceLength() ?

https://www.extremraym.com/cloud/rea...iaSourceLength

(maybe I'm misunderstanding though...)
nofish 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 08:36 AM.


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