WEBVTT 00:00:00.120 --> 00:00:04.520 Hi everyone, this is X-Raym, for the 6th part of our ReaScript tutorial. 00:00:04.639 --> 00:00:09.808 Imagine that we want our previous transformation to be applied 00:00:09.809 --> 00:00:14.320 on items in time selection rather than on selected one 00:00:14.359 --> 00:00:19.399 I clean that... car we will start where we stopped. 00:00:20.679 --> 00:00:24.960 In order to get items in time selection, 00:00:25.000 --> 00:00:31.399 I will search in the doc how to get this time selection. 00:00:38.759 --> 00:00:41.759 I take the second function, as it is more complete. 00:00:41.799 --> 00:00:43.959 I paste it here. 00:00:45.520 --> 00:00:50.320 I clean up a bit before renaming the variables. 00:00:52.039 --> 00:00:54.479 I add = here... 00:00:54.520 --> 00:00:59.240 Current project is 0 00:00:59.640 --> 00:01:03.799 Set means that you can define new values, or get the actual ones. 00:01:03.840 --> 00:01:08.920 It expect a bolean value, so I writte false (for Get.) 00:01:09.000 --> 00:01:11.159 I don't want to define a new selection. 00:01:11.239 --> 00:01:17.439 IsLoop is false too, as I want the Time selection. 00:01:17.519 --> 00:01:19.359 For Loop, it would be true. 00:01:19.400 --> 00:01:25.000 Here I put 0 cause it needs a number, and here too. 00:01:25.040 --> 00:01:30.080 And here I set false. 00:01:30.159 --> 00:01:33.159 GetSet_LoopTimeRange2 returns two values 00:01:33.239 --> 00:01:39.919 I name the first start_time, and the second end_time. 00:01:39.959 --> 00:01:47.959 Reacap: I use GetSet_LoopTimeRange2 to get start and end time of the time selection 00:01:52.079 --> 00:01:56.079 without setting new value. 00:01:56.120 --> 00:02:01.640 And here I have to set 0 because this function expect number as 4th and 5th argument, 00:02:01.719 --> 00:02:05.640 but it will have no influence on the returned values. 00:02:05.680 --> 00:02:11.240 If there is no time selection, start_time and end_time will be equal. 00:02:11.280 --> 00:02:13.719 So, I will add a conditions. 00:02:17.560 --> 00:02:20.319 If start_time is different than end_time 00:02:20.400 --> 00:02:23.800 in other words, if there is a time selection, 00:02:23.840 --> 00:02:26.280 then, run the following part. 00:02:26.319 --> 00:02:30.879 Now I will have to get the items that are in time selection. 00:02:30.960 --> 00:02:34.879 I will first put a function to count the number of items in the project. 00:02:42.240 --> 00:02:45.840 CountMedialtems 00:02:48.360 --> 00:02:54.640 I name my variable count_items, I paste this. I set 0 for current project. 00:02:54.680 --> 00:02:56.599 I create a loop. 00:02:59.479 --> 00:03:04.159 For i = 0, count_items - 1, - 1 because we start i at 0 00:03:04.199 --> 00:03:12.199 do Reaper. SetMedialtemlnfo_Value() 00:03:14.960 --> 00:03:22.080 as third parameters, I set the new value, which is item_mouse_fadeout 00:03:23.840 --> 00:03:31.360 We will create the variable item, 00:03:33.360 --> 00:03:41.040 and to get an item based on is index in the project, it is GetMedialtem 00:03:46.520 --> 00:03:54.520 project is 0, and inddex integer is i, our incrementation variable. 00:03:56.400 --> 00:04:04.400 I will add else to display a message if there is no time selection. 00:04:07.319 --> 00:04:10.596 As you can see, if start_time is different than 00:04:10.597 --> 00:04:13.599 end_time aka, if there is a time selection, 00:04:13.639 --> 00:04:18.240 all this get executed, else a message will be displayed in the console. 00:04:18.319 --> 00:04:23.079 If delete the time selection and put the mouse under no item 00:04:23.319 --> 00:04:25.719 A message told me that I don't have any item under the mouse. 00:04:25.759 --> 00:04:32.680 If I execute the script over an item, but without time selection, a message will warn me. 00:04:33.319 --> 00:04:37.800 If I make a time selection, and that I run the script hover an item. 00:04:37.879 --> 00:04:45.879 It works. However, at this time, I didn't make any conditions to check if the item is in time selection or not, 00:04:46.879 --> 00:04:50.360 to check if we modify its fade-out length value or not. 00:04:50.439 --> 00:04:54.319 As you can see, the script has an effect an all items, in time selection or not. 00:04:54.360 --> 00:04:58.291 I will have to get the items position and its length and 00:04:58.292 --> 00:05:02.360 add a new conditions, before modify their fade-out length. 00:05:05.040 --> 00:05:07.520 Item_pos = 00:05:08.240 --> 00:05:10.360 I copy that. 00:05:12.079 --> 00:05:18.959 The position is "D_POSITION. It is not 00:05:19.680 --> 00:05:25.879 I duplicate and I rename it to item_length 00:05:26.439 --> 00:05:30.879 length parameter is "D_LENGTH"... 00:05:30.959 --> 00:05:35.000 This parameters value can be find in the doc at GetMedialtemlnfo_Value 00:05:35.040 --> 00:05:36.800 here are "D_POSITION" and "D_LENGTH" 00:05:36.879 --> 00:05:41.800 There is not Item End parameter, so I will create a small calculation... 00:05:41.839 --> 00:05:49.839 item_end = item_pos + item_len 00:05:51.240 --> 00:05:57.360 Now I have to check that item start (item pos) and item end are in the time selection 00:05:57.399 --> 00:06:00.239 I will write the following condition: 00:06:00.319 --> 00:06:08.319 if...then... I prepare the room... 00:06:11.040 --> 00:06:19.040 If... item position is after than time selection start... 00:06:24.560 --> 00:06:32.560 and that item position is before than time selection end... 00:06:34.839 --> 00:06:41.679 I put that bewteen parenthis as all that should be compared to another possibilities... 00:06:41.720 --> 00:06:43.920 OR (of if) 00:06:47.439 --> 00:06:55.439 item end is after time selection start, and before end of time selection 00:07:13.319 --> 00:07:18.360 Then run the set fade-out length function. 00:07:18.439 --> 00:07:22.613 It is a complicated condition, but we only try to find ways 00:07:22.614 --> 00:07:26.439 to see if an item is inside the time selection or not. 00:07:30.160 --> 00:07:33.360 Let's analyse the function. It tells the following thing: 00:07:33.439 --> 00:07:41.439 if item position is after time selection start and below time selection end, 00:07:43.519 --> 00:07:47.680 it means that if the item position is between here and here, the set functions is executed. 00:07:47.720 --> 00:07:53.120 Indeed, the item belong to the time selection. 00:07:53.160 --> 00:07:57.287 2nd conditions: or if the item end is after time selection start 00:07:57.288 --> 00:08:01.160 and before time selection end, the set function is executed. 00:08:07.120 --> 00:08:10.360 There is a 3rd case. 00:08:12.040 --> 00:08:20.040 If item start is before time selection start and item end is after time selection end, 00:08:26.720 --> 00:08:31.680 I will add this other condition... 00:08:31.759 --> 00:08:39.759 If item pos is before time selection start, and if item end is after time selection end 00:08:51.639 --> 00:08:58.520 I put in place the third case described... 00:08:59.360 --> 00:09:06.000 If item is at time selection start, end, all over, or outside 00:09:07.600 --> 00:09:09.560 I set fades. 00:09:10.120 --> 00:09:13.200 And I run this script, from this item. 00:09:13.240 --> 00:09:15.480 As you can see, all happend as expected (item under mouse 00:09:15.481 --> 00:09:17.762 (fade-out length get propagated to item in time selection). 00:09:17.840 --> 00:09:22.920 In the next video, we will see how to get items according to selected tracks, 00:09:22.960 --> 00:09:28.000 and we will continue to develop our script in order to learn new functions. See ya!