Accesso rapido:  

Forum: General Discussion

Topic: Script School - Page: 46
Hi, I can't use JOG_WHEEL to smoothly change the position of the end of the loop section. Is there any option? Thanks
 

Inviato Sat 20 Apr 24 @ 11:19 pm
locoDogPRO InfinityModeratorMember since 2013
see the wheel_mode script
 

Inviato Sat 20 Apr 24 @ 11:24 pm
wheel_mode 'loop_out' ? wheel_mode 'loop_out,jog' : loop ? wheel_mode 'loop_out,jog' : loop_out
Already solved. Bye.
 

Inviato Sat 20 Apr 24 @ 11:27 pm
I'm trying to modify Touchdan's Title (Video Skin) to work for my needs.

I'd noticed that the title didn't always appear, or seemed to favour one deck over the other, so I investigated...

The original code looks like it checks the crossfader position to determine whether to show or not:
visibility="pulse 25000ms '`param_equal get_crossfader_result 0 ? deck left load_pulse : param_equal get_crossfader_result 1 ? deck right load_pulse : fadeout 1000ms 750ms`'"


I don't use the crossfader (so it sits centrally) which I guess is why the titles are inconsistent.

I found is_audible being used in another videoskin so borrowed the code:
visibility="is_audible 'or scratch' & fadeout 1000ms 500ms"


That works, but I've been trying to add a delay so that the text appears after 5 seconds of play rather than immediately, but so far have failed in all attempts.

(no idea what the 'or scratch' is doing)
 

Inviato Sun 21 Apr 24 @ 9:43 am
locoDogPRO InfinityModeratorMember since 2013
Try load_pulse_active

visibility="load_pulse_active 2000ms 5000ms & fadeout 1000ms 500ms"
 

Inviato Sun 21 Apr 24 @ 12:03 pm
Thank you locodog. I just did a quick mod to make it stay on screen a little longer, and we're away!
 

Inviato Sun 21 Apr 24 @ 1:11 pm
locoDogPRO InfinityModeratorMember since 2013
Another user wish, the concept is interesting as instruction to how to scale a dial.

User wanted a fine detailed key change on a dial.
So key_smooth is the script, but key_smooth goes from -6.0 key to +6.0 key so we need to reduce the range a bit.

As is from centre [key natural] key_smooth goes -6.0 to +6.0 so 12 divisions. We only want a range of -1.0 key to +1.0 key so 1/6th of the full range. Then we want to ignore the first 5/12ths of the range.
A dial usually goes from 0.0 to 1.0, so
( dial val * 0.166666 [a 6th] ) + 0.416666 [5/12ths] = val =>0.416666 & <=0.583333

That as script you'd use on a dial
param_multiply 0.166666 & param_add 0.416666 & key_smooth

That would be ±100 cents across a whole dial

param_multiply 0.016666 & param_add 0.491666 & key_smooth

This would be ±10 cents across a whole dial
 

Inviato 5 days ago @ 11:26 am
locoDogPRO InfinityModeratorMember since 2013
Another interesting user request that involves implicit manipulation.

User wanted a more increment kind of pitch slider, to some it might not make sense but I get it, instead of having infinity values between 2 contiguous integers you have just 10, so from 120 to 121 bpm you just have 121.0, 121.1, 121.2 ... etc

part of it is showing off, part of it is cheating, part of it is how digital sliders work when you look closely at X num of bit precision.
The dancefloor doesn't really care as long as you don't trainwreck.

A rare use case but an interesting script to learn from

So the dial implicit is 0.0 - 1.0
we need to turn implicit into ±1.0

so multiply by 2, now our implicit is 0.0 - 2.0
so add -1, now our implicit is -1.0 to +1.0

multiply implicit by pitch range, pitch range returns a value between 0.01 to 1.00 [1% pitch range to 100% pitch range]
so implicit == -pitch range to +pitch range

add 1 so our implicit is (1 - pitch range) to (1 + pitch range)

multiply implicit by bpm absolute
param_cast '0.0' to limit digits to one decimal place
param_cast as beats because we're passing a beat value to the pitch verb

pitch

param_multiply 2 & param_add -1 & param_multiply pitch_range & param_add 1 & param_multiply 'get_bpm absolute' & param_cast '0.0' & param_cast beats & pitch
 

Inviato 5 days ago @ 12:30 pm
locoDogPRO InfinityModeratorMember since 2013
Script and the deck it acts on.
deck specified

Should have done this earlier as it's basic, but I'm doing it now and have a thing to add that is a little more advanced.

So think about this script play_pause,
now think about where you could write this script and the results you get from writing in different places.
You could write; to a custom_button, to a pad, actually into a skin, to an action poi, to a controller mapping, to a keyboard mapping.

The thing is, it knows what deck to act on, how does it know?
The first 3 are all part of a skin and in the skin you can specify the deck to act upon.
apoi are called from a track on a deck so it inherits the assigned deck there.

Controller mapping is usually deck specified in the definition file; a device may have a left play_pause & a right play_pause, those buttons do send different midi messages those different messages are assigned to different decks. You might just map 1 entry to play_pause but in the definition it's actually several buttons assigned to different decks.

Not all controllers are like this though, like a launchpad or similar auxiliary device, they don't have a deck specified in the definition. A play_pause there will act on the selected deck, also known as deck default.
A keyboard mapping, similar to an auxiliary device, has no deck assigned to so defaults to... the default deck, also known as the selected deck.

So most of the time we don't need to worry about specifying the deck,
but what if we want to get fancy?
What if we're doing stuff across several decks?
How do we check our calling deck number?
How do we specify a deck with script?
A few different scripts here.

Query against
device_side %PARAM ? 

params that can be used are left right [ or integer number for 4 deck devices]
This is just for devices,

action_deck %NUM ?

This works for all cases

deck %PARAM masterdeck ?

this query is, is this deck the active/masterdeck

Info query to get a number
get_deck - returns integer
get_defaultdeck - returns integer
get_leftdeck - returns integer
get_rightdeck - returns integer
get_decks - returns integer number of decks
get_activedeck - returns integer of masterdeck

Normal way of specifying a deck to a known value
deck %PARAM SOME_VERB
params that can be used are deck number, left, right, master, active, default

How to make a deck the default deck [presuming there's a deck specified to where this script is written.]
select
If you want to specify the deck
deck %PARAM select
params could be NUM, left, right, master, active


Specifying a deck with dynamic script.
set_deck `ACTION`

This is the newer interesting specifier, this accepts action script as a parameter meaning you can get smart with it.

Let's do an example case, we'll make our own automix/timeline with action poi.
so you'd have a couple of action poi like this

if we're on deck 1 load deck 2, if we're on deck 2 load deck 1
action_deck 1 ? deck 2 load "C://FILEPATH.mp3" : action_deck 2 ? deck 1 load "C://FILEPATH.mp3" :

similar story press play on the other deck
action_deck 1 ? deck 2 play_sync : action_deck 2 ? deck 1 play_sync :

So far so boring, how do we use set_deck with this?
We could do something like this, but it's not really much smarter
set_deck `action_deck 1 ? get_constant 2 : action_deck 2 ? get_constant 1 : ` & load C://FILEPATH.mp3"

What would be smart would be the remainder of our deck number divided by our number of decks, then add 1
We're on deck 1, we have 2 decks,
1%2 = 1
then add 1 to get 2.
other case
2%2 = 0
add 1 to get 1

As it happens we have a script that does this kind of remainder division, param_mod, [modulo operation if you haven't heard of it]

set_deck `param_mod get_decks get_deck & param_add 1` & load "C://FILEPATH.mp3"


If you have lots of "act on the other deck" type of scripts, I'd use a variable, set variables like this
set $callingDeck `get_deck` & set $otherDeck `param_mod get_decks get_deck & param_add 1`
then use the variables something like this
set_deck `get_var $otherDeck` & level +10%


After setting the variables you could do something like this that will act on both decks with different actions, [be careful using DECK ALL, see deck all lesson as to why]

deck all param_equal `get_var $callingDeck` `get_deck` ? DO THING TO CALLING DECK : DO THING TO OTHER DECK


Pretty basic, set_deck has its uses.
 

Inviato 2 days ago @ 4:52 pm
locoDogPRO InfinityModeratorMember since 2013
Parse Values Anywhere in Script

A cross over episode with virtualfx. Since virtualfx is available on all platforms I consider it unofficially official.
If it didn't exist I'd be pestering the devs that script should do this.

Now anybody who has got into scripting has got to the point of "I want to parse script values into other scripts because... awesome idea"
and a lot of times you can cast a value to a param with a bit of work, but it's not the easiest.

So let's make it easy with an example that would be very difficult otherwise.
First grab yourself a copy of virtualfx
next outside of vdj rename the .dll or .bundle to "parser"

So let's do something with padfx to control echo out [I keep meaning to cover padfx but it's a 'busy' verb with a lot to it]
now let's set some variables to recall later. Just examples

set $fxParam1 `effect_slider echo 1` & set $fxParam2 0.75 & set $fxParam3 `filter` & set_var $fxStemState 'stemfx:Vocal'


so a mixed bag here, we saved from effect_sliders, we saved a fixed value, we saved from the filter position, and we saved a fixed string variable.

So now the magic, we build a string with literal text and parsed values, send it to parser fx as an effect_string and then have that string called as a script [that's what virtualfx does, effect_strings called as script]
make this a button
get_text "padfx 'echo out' `get_var $fxParam1` `get_var $fxParam2` `get_var $fxParam3` `effect_slider 'echo out' 4` `get_var $fxStemState`" & param_cast & effect_string parser 7 & effect_button parser 1 -1


first 3 params we get from saved variables, 4th param we grab from the fx itself at run time, and the stem state we get from a saved string variable.

Either you're intrigued and you want to test, or you don't get it.
Short and sweet, but crazy powerful.
 

Inviato 8 hours ago
Awesome stuff Locodog..

Always wanted to wrap my head around your plugin, virtualfx, and always stuck at knowing what virtualfx expects.. or what is under its hood.

For example.. what is reason for the items (parameters) you passed to virtualfx (parcer) and how did you know which, and order to pass them?
(seems some additional info is required)

And then, there is question .. the virtualfx, button,
what is it doing and what does the button's parameters mean 1 -1... ?

Without an understanding of the above it is a black box that may be difficult to interact with, though powerful as it is..

Yes, intrigued, and would love to learn more.



PS
In the spirit of learning here at school:
when initially setting variables, you used set, set, set, & set_var
is there a reason for not using set for the 4th variable also?

 

Inviato 2 hours ago
locoDogPRO InfinityModeratorMember since 2013
The order of params is how padfx works, you pass params in the order they're found on the plugin you're calling.

It really is just a list in order
I want to call "some fx" on, and I want to pass these values I list to that fx.

Try play with the padfx script, it should become clear

[example demo, should be instructive]
effect_show_gui echo on & wait 1000ms & effect_slider echo 1 100% & effect_slider echo 2 100% & effect_slider echo 3 100% & effect_slider echo 4 100% & effect_button echo 1 on & effect_button echo 2 on & wait 1000ms & padfx echo 0.1 0.3 0.9 0.7 "mute source:off" "trailing stop:off" & wait 1000ms & effect_active echo


the button names at the end can be either case what is returned from
get_effect_button_name "FXNAME" BUTTON_NUM
or
get_effect_button_shortname "FXNAME" BUTTON_NUM

As to
effect_button parser 1 -1, the -1 is button state, -1 being toggle [1|0|-1] same as [on|off|toggle]
It's needed here as my string of text becomes the implicit so what is called without the -1 would be
effect_button parser 1 "my load of text"
it's expecting on|off|toggle or 1|0|-1, so it wouldn't know what to do with my load of text. Using -1 tells the script engine what we want to do and it bumps the implicit text to param 4 [and there is no param 4 for a button script so our text is safely ignored]

And last bit. I use set_var as we are saving a string variable, if we did this
set $fxStemState 'stemfx:Vocal'
we wouldn't be saving the literal text, we would be saving whatever the variable named 'stemfx:Vocal' was holding [we've not set a variable named that so it would be holding Zero]
Read up on set verb for that one.

I could have done this instead to avoid the error
set $fxStemState `get_text 'stemfx:Vocal'`

There's a little more to padfx, slider params have to be in order they're found on the plugin, you don't have to include all params, once you miss a param that's the end of slider param setting, buttons you can call by name so order isn't as important but they can still screw up slider setting so best follow the order as found on the plugin.

Yeah, padfx is a busy verb.
 

Inviato an hour ago