Trevliga Spel forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Simulating button presses (and releases) in scripts

2 posters

Go down

Simulating button presses (and releases) in scripts Empty Simulating button presses (and releases) in scripts

Post by AL1_1956 Sat Nov 02, 2024 2:59 pm

Hello everybody.

Let me explain what I am wishing to have if it's possible

I want to build a Chord Sequencer .

So in order to do that , I have 12 buttons for the root of the chord (C,C#-Db,D....)
I also have 7 buttons for the most used chord types (Major,Minor,7th....)

So with a combination of 1 root button and 1 chord type button i can send 4 midi notes (or more)

My first Root button has the following script

[(press)
{@root:#48+@low#}
]

(48 is the low C and @low is a variable which permits to choose the octave)

My first chord type button has the following script

[(press)
{cc:1,123,0}
{noteon:1,#@root#,#@vel#}
{noteon:1,#@root+4#,#@vel#}
{noteon:1,#@root+7#,#@vel#}
{noteon:1,#@root+12#,#@vel#}
]

(@vel is the velocity of the note) , cc 123 is all note off to cut the previous chord)

so when I press C button and Maj button , I can send a Cmajor chord

and when I press D button and Min button I cut the Cmajor and send D minor

I cannot think of a mean to mesmorize the chord sequence other than putting the scripts of the pair of buttons (root-type) in a string variable that grows each time

So it would be nice if instead of making a gigantic script I could mesmorize only the buttons and then replay them with the help of timers

So it would be great to have "press button " and "release button" in the possible events

Anyway , this is a great plugin and I thank you for your continuous job

Kindly

Alain

AL1_1956

Posts : 7
Join date : 2024-03-30

Back to top Go down

Simulating button presses (and releases) in scripts Empty Re: Simulating button presses (and releases) in scripts

Post by Admin Sat Nov 02, 2024 10:14 pm

Hi, I see what you are getting at, but unfortunately, the plugin can't do that.

I would suggest that you create a solution where a background script plays the chords and that you trigger that script from buttons, using variables.

You have the @root and @vel variables, and I suggest defining a third variable for chord type. You could, e.g., have a variable @chord that can have values like "Maj", "Min", "Maj7", and whatever chord you need to have available.

The background script can have commands like this:

[(@chord:"Maj"){cc:1,123,0}{noteon:1,#@root#,#@vel#}{noteon:1,#@root+4#,#@vel#}{noteon:1,#@root+7#,#@vel#}{noteon:1,#@root+12#,#@vel#}]

[(@chord:"Min"){cc:1,123,0}{noteon:1,#@root#,#@vel#}{noteon:1,#@root+3#,#@vel#}{noteon:1,#@root+7#,#@vel#}{noteon:1,#@root+12#,#@vel#}]
...and so on.

On a button, you could then have a command like this:

[(press){@root:64}{@vel:100}{@chord:"Maj"}]

The important thing is to set the @chord variable last since that's what triggers the chord in the background script. You can, of course, split the command if you want to set the root with one button and the chord type with another.

If you want to automate a sequence of chords, you can either have a script like this:

[(press){@root:64}{@vel:100}{@chord:"Maj"}{wait:1000}
{@root:50}{@vel:100}{@chord:"Min"}{wait:500}
{@root:74}{@vel:100}{@chord:"Maj7"}{wait:1000}]

Or create a multi-action with separate script actions separated by delay actions.
Admin
Admin
Admin

Posts : 1250
Join date : 2020-03-26

https://trevligaspel.forumotion.eu

Back to top Go down

Simulating button presses (and releases) in scripts Empty Re: Simulating button presses (and releases) in scripts

Post by AL1_1956 Tue Nov 05, 2024 10:49 am

Okay , Thank You for the tip of using the background script.

I was at first a bit surprised because as I am working on several projects with the StreamDeck , I had some strange things happening in my other projects.

Then I realized that I forgot to deactivate the background script 
(Silly me , Age is really a shipwreck)

Then I thought "What is the simplest way to record a sequence of keys ," and the answer was to use a combination of e_row and e_column which is unique for each key of the StreamDeck.

So I build a string wich looks like this

Let's say I want a sequence of 4 chords

the C root is '01' and the Major Chord is '31' 
my string is '0131,'

the C# root is '02' and the Minor Chord is '32'
my string becomes '0131,0232,'

and so on...

then my background script reads and cuts the long string in several pieces , each one being a root+chord and sends the "noteon ,wait, noteoff" 

Easy on paper , lets do that on the StreamDeck

Have a nice day

Alain

AL1_1956

Posts : 7
Join date : 2024-03-30

Back to top Go down

Simulating button presses (and releases) in scripts Empty Re: Simulating button presses (and releases) in scripts

Post by Admin Tue Nov 05, 2024 5:06 pm

It sounds complicated to me, but if it works for you, it's fine. Smile
Admin
Admin
Admin

Posts : 1250
Join date : 2020-03-26

https://trevligaspel.forumotion.eu

Back to top Go down

Simulating button presses (and releases) in scripts Empty Re: Simulating button presses (and releases) in scripts

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum