Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 08-10-2019, 12:57 AM   #1
Phazma
Human being with feelings
 
Join Date: Jun 2019
Posts: 2,875
Default Edit a script to insert Instrument instead of normal track?

Hello,

I have not yet found time to try and learn scripting, however I managed to do some very simple edits on some scripts by just using common sense.
Right now I am using me2beats script 'Insert and select track after selected track or folder' to insert new tracks in my project.. however I would like a script like this (that acts after folder) also to replace Reaper's native action 'Insert virtual instrument on new track..'.

You can see the script that I am using here:
https://github.com/me2beats/reapack/...r%20folder.lua

By looking at this as a layman I suspect that line 37 - r.InsertTrackAtIndex(num,1) - is responsible for actually adding the track. Is there some kind of function (if that is the right way to call it), something like r.InsertInstrumentAtIndex, that I can simply write to replace this line and have it do what I need, or is this something more complex and I would need some actual scripting knowledge to edit it?
Phazma is offline   Reply With Quote
Old 08-10-2019, 05:38 AM   #2
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

Not sure if this is what you need but you should be able to put this
Code:
  reaper.Main_OnCommand(40291,0) -- Track: View FX chain for current/last touched track
after that in the script, this should do the same as 40701 "Insert virtual instrument on new track...." but bring up the FX browser for the track it inserts "r.InsertTrackAtIndex(num,1)" the r is just told to = reaper at the top.
The 40291 is the right click Command ID in the Action list for Track: View FX chain for current/last touched track

see also https://www.extremraym.com/cloud/reascript-doc/
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 08-11-2019, 07:14 AM   #3
Phazma
Human being with feelings
 
Join Date: Jun 2019
Posts: 2,875
Default

Hey,

thanks for the idea. Technically it worked, however only in the same way as if I made a custom action consisting of the script in question, followed by the action 'View FX chain for current/last touched track'. The difference between 'View FX chain for current/last touched track' and 'Insert virtual instrument on new track...' is that the latter automatically names the new track, which is important to me.

However I found an alternative solution for this by creating a custom action which first triggers the me2beats script 'Insert and select track after selected track or folder' to create a "dummy track" at the right position and afterwards triggers 'Insert virtual instrument on new track..' Finally I added a few additional actions which are needed to automatically delete the dummy track (I might elaborate further and list all involved actions if someone is interested).
Phazma is offline   Reply With Quote
Old 08-11-2019, 12:30 PM   #4
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

Quote:
Originally Posted by Phazma View Post
..automatically names the new track, which is important to me....
try this

sel_track = reaper.GetSelectedTrack2( 0, 0, 1 )
reaper.GetSetMediaTrackInfo_String(sel_track, "P_NAME", "my track name", true)
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak

Last edited by MusoBob; 08-11-2019 at 02:19 PM.
MusoBob is offline   Reply With Quote
Old 08-12-2019, 12:15 AM   #5
Phazma
Human being with feelings
 
Join Date: Jun 2019
Posts: 2,875
Default

Thanks will try asap!
Phazma 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:28 PM.


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