-
Hi everyone, this is X-Raym,
for the 6th part of our ReaScript tutorial.
-
Imagine that we want our previous
transformation to be applied
-
on items in time selection
rather than on selected one
-
I clean that... car we will start
where we stopped.
-
In order to get items in time selection,
-
I will search in the doc how to get
this time selection.
-
I take the second function, as it is
more complete.
-
I paste it here.
-
I clean up a bit before
renaming the variables.
-
I add = here...
-
Current project is 0
-
Set means that you can define new
values, or get the actual ones.
-
It expect a bolean value, so I writte false
(for Get.)
-
I don't want to define a new selection.
-
IsLoop is false too,
as I want the Time selection.
-
For Loop, it would be true.
-
Here I put 0 cause it needs a number,
and here too.
-
And here I set false.
-
GetSet_LoopTimeRange2 returns two values
-
I name the first start_time,
and the second end_time.
-
Reacap: I use GetSet_LoopTimeRange2 to get
start and end time of the time selection
-
without setting new value.
-
And here I have to set 0 because this function
expect number as 4th and 5th argument,
-
but it will have no influence on
the returned values.
-
If there is no time selection,
start_time and end_time will be equal.
-
So, I will add a conditions.
-
If start_time is different than end_time
-
in other words, if there
is a time selection,
-
then, run the following part.
-
Now I will have to get the items
that are in time selection.
-
I will first put a function to count
the number of items in the project.
-
CountMedialtems
-
I name my variable count_items, I paste
this. I set 0 for current project.
-
I create a loop.
-
For i = 0, count_items - 1,
- 1 because we start i at 0
-
do
Reaper. SetMedialtemlnfo_Value()
-
as third parameters, I set the new value,
which is item_mouse_fadeout
-
We will create the variable item,
-
and to get an item based on is index
in the project, it is GetMedialtem
-
project is 0, and inddex integer is i,
our incrementation variable.
-
I will add else to display a message
if there is no time selection.
-
As you can see, if
start_time is different than
-
end_time aka, if there
is a time selection,
-
all this get executed, else a message
will be displayed in the console.
-
If delete the time selection and
put the mouse under no item
-
A message told me that I don't have
any item under the mouse.
-
If I execute the script over an item, but
without time selection, a message will warn me.
-
If I make a time selection, and that
I run the script hover an item.
-
It works. However, at this time, I didn't make any
conditions to check if the item is in time selection or not,
-
to check if we modify its
fade-out length value or not.
-
As you can see, the script has an effect
an all items, in time selection or not.
-
I will have to get the items
position and its length and
-
add a new conditions, before
modify their fade-out length.
-
Item_pos =
-
I copy that.
-
The position is "D_POSITION.
It is not
-
I duplicate and I rename it to item_length
-
length parameter is "D_LENGTH"...
-
This parameters value can be find in
the doc at GetMedialtemlnfo_Value
-
here are "D_POSITION"
and "D_LENGTH"
-
There is not Item End parameter, so I will
create a small calculation...
-
item_end = item_pos + item_len
-
Now I have to check that item start (item
pos) and item end are in the time selection
-
I will write the following condition:
-
if...then...
I prepare the room...
-
If... item position is after than
time selection start...
-
and that item position is before than
time selection end...
-
I put that bewteen parenthis as all that
should be compared to another possibilities...
-
OR (of if)
-
item end is after time selection start,
and before end of time selection
-
Then run the set fade-out length function.
-
It is a complicated condition,
but we only try to find ways
-
to see if an item is inside
the time selection or not.
-
Let's analyse the function.
It tells the following thing:
-
if item position is after time selection
start and below time selection end,
-
it means that if the item position is between
here and here, the set functions is executed.
-
Indeed, the item belong to the
time selection.
-
2nd conditions: or if the item end
is after time selection start
-
and before time selection end,
the set function is executed.
-
There is a 3rd case.
-
If item start is before time selection start
and item end is after time selection end,
-
I will add this other condition...
-
If item pos is before time selection start,
and if item end is after time selection end
-
I put in place the third case described...
-
If item is at time selection start, end,
all over, or outside
-
I set fades.
-
And I run this script, from this item.
-
As you can see, all happend
as expected (item under mouse
-
(fade-out length get propagated
to item in time selection).
-
In the next video, we will see how to
get items according to selected tracks,
-
and we will continue to develop our script
in order to learn new functions. See ya!