|
|
|
02-26-2023, 09:37 AM
|
#1
|
Human being with feelings
Join Date: Nov 2018
Location: Montreal
Posts: 405
|
Set Send to Multichannel Source Missing API fonction
Hi,
I'm trying to write a script that sets the send's output of an 8 channel track to "Multichannel Source - 1-8". Both source and destination tracks have 8 channels.
I'm not very good at coding but I'm using Chat GPT to generate the code and I seem to have tried everything.
Still I'm pretty close. Here's where I'm at so far :
Code:
-- Get the selected track
selected_track = reaper.GetSelectedTrack(0, 0)
-- Get the send count for the selected track
send_count = reaper.GetTrackNumSends(selected_track, 0)
-- If there is at least one send, change the first send's output to multichannel source
if send_count > 0 then
-- Get the first send's information
send_index = 0
send_info = reaper.GetTrackSendInfo_Value(selected_track, 0, send_index, "I_SRCCHAN")
-- Set the first send's output to multichannel source
reaper.SetTrackSendInfo_Value(selected_track, 0, send_index, "I_SRCCHAN", 0)
end
Using the "I_SRCCHAN" :
The value -1 sets the ouptput to "none"
The value 0 sets the ouput to "1/2".
The value 1 sets the ouput to "3/4.
etc...
Nothing seems to work to set it to "Multichannel Source"
When looking at the ReaScript API I can't find any information on "Multichannel Source"
All I've found was this :
I_SRCCHAN : int * : index,&1024=mono, -1 for none
Could it be that Multichannel Source is missing from the API?
Thanks,
Last edited by fbeauvaisc; 02-26-2023 at 11:06 AM.
|
|
|
02-26-2023, 10:09 AM
|
#2
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
|
Code:
local channel_offset = 4
local num_channels = 10
--> channels 5-14
reaper.SetTrackSendInfo_Value(
selected_track, 0, send_index, 'I_SRCCHAN',
(num_channels << 9) | channel_offset)
Last edited by cfillion; 02-26-2023 at 10:16 AM.
|
|
|
02-26-2023, 11:01 AM
|
#3
|
Human being with feelings
Join Date: Nov 2018
Location: Montreal
Posts: 405
|
Quote:
Originally Posted by cfillion
Code:
local channel_offset = 4
local num_channels = 10
--> channels 5-14
reaper.SetTrackSendInfo_Value(
selected_track, 0, send_index, 'I_SRCCHAN',
(num_channels << 9) | channel_offset)
|
Thanks, maybe I'm doing something wrong be when I try this
Code:
-- Get the selected track
selected_track = reaper.GetSelectedTrack(0, 0)
-- Get the send count for the selected track
send_count = reaper.GetTrackNumSends(selected_track, 0)
-- If there is at least one send, change the first send's output to multichannel source
if send_count > 0 then
-- Get the first send's information
send_index = 0
channel_offset = 4
num_channels = 10
send_info = (num_channels << 9) | channel_offset
-- Set the first send's output to multichannel source
reaper.SetTrackSendInfo_Value(selected_track, 0, send_index, "I_SRCCHAN", send_info)
end
I get this :
What I'm trying to acheive is this :
Any thoughts?
|
|
|
02-26-2023, 11:05 AM
|
#4
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
|
For 1-8, it would be:
Code:
local channel_offset = 0
local num_channels = 8
|
|
|
02-26-2023, 11:23 AM
|
#5
|
Human being with feelings
Join Date: Nov 2018
Location: Montreal
Posts: 405
|
Quote:
Originally Posted by cfillion
For 1-8, it would be:
Code:
local channel_offset = 0
local num_channels = 8
|
Wow great! It works! Thank you so much!
Now what I'm actually trying to acheive is a little harder. Maybe you can help.
Ive generated a few scripts that sends the selected tracks to tracks with prefix FX1, FX2 FX3 accordingly. Different scripts for each. The scripts also avoids duplicating an existing send.
Code:
-- Get all selected tracks
num_sel_tracks = reaper.CountSelectedTracks(0)
-- Loop through all selected tracks
for i = 0, num_sel_tracks - 1 do
selected_track = reaper.GetSelectedTrack(0, i)
-- Loop through all tracks in the project
for j = 0, reaper.CountTracks(0) - 1 do
track = reaper.GetTrack(0, j)
-- Check if the track name starts with "FX1"
track_name_ok, track_name = reaper.GetSetMediaTrackInfo_String(track, "P_NAME", "", false)
if track_name_ok and string.sub(track_name, 1, 3) == "FX1" then
-- Check if the selected track already has a send to the FX1 track
has_send = false
for k = 0, reaper.GetTrackNumSends(selected_track, 0) - 1 do
dest_track = reaper.GetTrackSendInfo_Value(selected_track, 0, k, "P_DESTTRACK")
if dest_track == track then
has_send = true
break
end
end
-- If the selected track doesn't already have a send to the FX1 track, create one
if not has_send then
send_idx = reaper.CreateTrackSend(selected_track, track)
end
break -- Exit the loop after the first "FX1" track is found
end
end
end
Now I'd like to upgrade that script so it looks at the number of channels from the source track and sets the output accordingly.
Adding this code :
Code:
-- Get the number of audio channels on the selected track
num_channels = reaper.GetMediaTrackInfo_Value(selected_track, "I_NCHAN")
then add "if" statements that would set the outputs to the right mono, stereo, quad, 6 or 8 channel accordingly. So if the track has 6 channels, then I'm assuming :
Code:
local channel_offset = 0
local num_channels = 6
Would you be so kind as to help me put such a script toguether? We seem to have all the elements down, I'm just too novice to put them all toguether.
Thanks!
|
|
|
02-26-2023, 12:02 PM
|
#6
|
Human being with feelings
Join Date: Nov 2018
Location: Montreal
Posts: 405
|
Actually, Chat GPT is pretty good at helping me. I've got it figured out. What an amazing tool! Of course, it needed a human touch to get things going in the right direction. Thanks cfillion!
Code:
-- Get all selected tracks
num_sel_tracks = reaper.CountSelectedTracks(0)
-- Loop through all selected tracks
for i = 0, num_sel_tracks - 1 do
selected_track = reaper.GetSelectedTrack(0, i)
-- Loop through all tracks in the project
for j = 0, reaper.CountTracks(0) - 1 do
track = reaper.GetTrack(0, j)
-- Check if the track name starts with "FX1"
track_name_ok, track_name = reaper.GetSetMediaTrackInfo_String(track, "P_NAME", "", false)
if track_name_ok and string.sub(track_name, 1, 3) == "FX1" then
-- Check if the selected track already has a send to the FX1 track
has_send = false
for k = 0, reaper.GetTrackNumSends(selected_track, 0) - 1 do
dest_track = reaper.GetTrackSendInfo_Value(selected_track, 0, k, "P_DESTTRACK")
if dest_track == track then
has_send = true
break
end
end
-- If the selected track doesn't already have a send to the FX1 track, create one
if not has_send then
send_idx = reaper.CreateTrackSend(selected_track, track)
end
-- Get the send count for the selected track
send_count = reaper.GetTrackNumSends(selected_track, 0)
-- Get the number of channels in the selected track
num_channels = reaper.GetMediaTrackInfo_Value(selected_track, "I_NCHAN")
-- If there is at least one send and the track has a supported number of channels, change all sends' output to multichannel source
if send_count > 0 and (num_channels == 4 or num_channels == 6 or num_channels == 8) then
-- Set the number of channels based on the track's number of channels
if num_channels == 4 then
num_channels = 4
elseif num_channels == 6 then
num_channels = 6
elseif num_channels == 8 then
num_channels = 8
else -- num_channels == 2
return
end
-- Loop through all sends for the selected track
for i = 0, send_count - 1 do
-- Set the send info based on the number of channels
send_info = (num_channels << 9) | 0
-- Set the send's output to multichannel source
reaper.SetTrackSendInfo_Value(selected_track, 0, i, "I_SRCCHAN", send_info)
end
end
break -- Exit the loop after the first "FX1" track is found
end
end
end
Last edited by fbeauvaisc; 02-27-2023 at 06:05 AM.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 08:25 AM.
|