The right way to switch between groups

lidoravitan
lidoravitan Member Posts: 12 Newcomer

What is the right way to switch between groups with ksp script?

I want to write script that switch group according to the held note.

for example: play note c(0) will switch to group a, play note D#(3) will switch to group D

Best Answers

  • EvilDragon
    EvilDragon Moderator Posts: 1,022 mod
    Answer ✓

    So, in your case you have 12 groups, and you want each C to trigger group 1, each C# to trigger group 2, etc.?

    That's pretty simple:

    on note
        disallow_group($ALL_GROUPS)
        allow_group($EVENT_NOTE mod 12)
    end on
    
  • EvilDragon
    EvilDragon Moderator Posts: 1,022 mod
    Answer ✓

    Yes, group allowing is only scanned before actually playing a note, you cannot change this during a note. You would have to kill your first pressed note then play the right one based on user input, I suppose.

  • EvilDragon
    EvilDragon Moderator Posts: 1,022 mod
    Answer ✓

    Yes you can simply play all groups at the same time then modify their volume, but this will possibly play a lot of voices (depending on number of groups you have) and is definitely not gonna be CPU efficient.

Answers

  • EvilDragon
    EvilDragon Moderator Posts: 1,022 mod
    Answer ✓

    So, in your case you have 12 groups, and you want each C to trigger group 1, each C# to trigger group 2, etc.?

    That's pretty simple:

    on note
        disallow_group($ALL_GROUPS)
        allow_group($EVENT_NOTE mod 12)
    end on
    
  • lidoravitan
    lidoravitan Member Posts: 12 Newcomer
    edited February 2022

    @EvilDragon Thanks for your response. First, I wanted to verify I've got the point of allow/disallow groups.

    Now, on my script it quite different, I want to allow_group based on played chord.

    I wrote a script that runs "on note", and each time verify if it's a combination of chord. I mean it starts the calculation on each note played, and if at least 3 notes are held It could be a chord.

    as you know midi sent message per note. so to calculate chord, "on note" called at least three time. I managed to recognize chord by patterns.

    One note: This script written for specific use case. So In my use-case when consumer play C major, I received a chord notes between 0-45 (C/E/G) and the base note (C) on higher octave ( that helps me to know the base before I know the chord type)

    Now I want to play loops/sample accordingly. I thought to play the loop/sample based on the base note immediately and when I got the chord pattern to switch between groups Major/Minor etc...

    However it seems that allow_groups/disallow_group works for each note and not globally ( like mute/unmute groups), am I right? if, yes. do you have any thoughts?

  • EvilDragon
    EvilDragon Moderator Posts: 1,022 mod
    Answer ✓

    Yes, group allowing is only scanned before actually playing a note, you cannot change this during a note. You would have to kill your first pressed note then play the right one based on user input, I suppose.

  • lidoravitan
    lidoravitan Member Posts: 12 Newcomer

    @EvilDragon  Is there a workaround for this limitation like changing the volume of the group? Or something you can think of

    thanks

  • EvilDragon
    EvilDragon Moderator Posts: 1,022 mod
    Answer ✓

    Yes you can simply play all groups at the same time then modify their volume, but this will possibly play a lot of voices (depending on number of groups you have) and is definitely not gonna be CPU efficient.

  • lidoravitan
    lidoravitan Member Posts: 12 Newcomer

    Yeah there is a trade-off. well, with that implementation it gonna play only one note per chord, which means one voice (loop) from each group at the same time. max of 8 group so it will be worth case 8 voices at the same time. wdyt? :) Is it really terrible trad-off?

    thanks a lot

Back To Top