Jump to content

CAL Script For Alternating Velocity


sjoens

Recommended Posts

Quickly came up with this script

This script asks for the alternative value, then sets all alternative notes to that alternative value, leaves the rest alone.

(do
    (int count 0)
    (int Alt_velocity 100)
    (getInt Alt_velocity "Please enter velocity for every alternative note" 1 127)
    (forEachEvent
        (if (== Event.Kind NOTE)
            (do
                (if (== (% count 2) 0) (= Note.Vel Alt_velocity))
                (++ count))))
);end do

Link to comment
Share on other sites

Just now, Promidi said:

Your question should not be “Is there a CAL script that..........”, but rather, “Can a CAL script be written that..........”

hey! can you write a CAL script which removes HiHat note which is parallel to a Snare note to help thin down the drum MIDI 🙂 

Link to comment
Share on other sites

1 hour ago, Promidi said:

Your question should not be “Is there a CAL script that..........”, but rather, “Can a CAL script be written that...

Or maybe "Can this be done without a CAL script?"

If the notes can't be easily be differentiated by note number, you might be able to use Select By Filter to pick out every other note based on Beat/Tick values. Or you could make a short Groove Clip consisting of just 2 or 4 of the events and roll it out as needed.

Link to comment
Share on other sites

1 hour ago, Promidi said:

Your question should not be “Is there a CAL script that..........”, but rather, “Can a CAL script be written that..........”

:) I was sure one could be written but wanted to know if one already existed.  If not, I would have asked how to make one, tho I have no clue how to read/write CAL.

Also seems like one of the MFX should do this but apparently not.

FWIW, I have a huge collection of CAL from Mudgel and others, but some don't work right or at all.

Link to comment
Share on other sites

2 minutes ago, David Baay said:

Or you could make a short Groove Clip consisting of just 2 or 4 of the events and roll it out as needed.

This was my next option but a CAL script would be easier after the fact.

Link to comment
Share on other sites

1 hour ago, Glenn Stanton said:

hey! can you write a CAL script which removes HiHat note which is parallel to a Snare note to help thin down the drum MIDI 🙂 

This is one I came up with at such short notice.

To use this, select the notes, so that the hi hats are the highest notes selected are the snares are the lowest selected is the snares

It should delete any hihats that are within 50 ticks of a snare.

No warranties

(do
    (int min_val 127)
    (int max_val)
    (int current_note_count)
    (int Previous_note_count)
    (long Snare_time)
    (long time_diff)
    (forEachEvent
        (if (== Event.Kind NOTE)
            (do
                (if (<= Note.Key min_val) (= min_val Note.Key))
                (if (>= Note.Key max_val) (= max_val Note.Key))
            );end do
        );end if
    );end for
    
    (forEachEvent
        (if (== Event.Kind NOTE)
            (do
                (if (== Note.Key min_val) (= Snare_time Event.Time))
                
                (if (== Note.Key max_val)
                    (do
                        (= time_diff (- Event.Time Snare_time))
                        (if (&& (< time_diff 50) (> time_diff -50)) (delete))
                    );end do
                );end if
            );end do
        );end if
    );end for
);end do

Link to comment
Share on other sites

7 minutes ago, sjoens said:

FWIW, I have a huge collection of CAL from Mudgel and others, but some don't work right or at all.

That might be down to the differences in the way CAL commands are processed between CPA9 and CbB

For instance, issue EditCut40 EditCopy40 or EditPaste40 commands without paramters in CPA9 bring up a dialogue box.  In CbB, the command just executes.

Also the EditSlide40 command will categorically crash CbB.

Any CAL scripts I have written, I make sure work in CbB.

Link to comment
Share on other sites

13 minutes ago, David Baay said:

Or maybe "Can this be done without a CAL script?"

If the notes can't be easily be differentiated by note number, you might be able to use Select By Filter to pick out every other note based on Beat/Tick values. Or you could make a short Groove Clip consisting of just 2 or 4 of the events and roll it out as needed.

Yeah, that could work if the notes are different.  However, if they are the same and/or the timing is all over the place, then it’s a CAL script. 

A CAL script that selected every other note could work - then set the velocity of selected notes to an arbitrary value.

These are the sort of things I would like to see in the new Sonar as native functions rather than having users messing around with CAL scripts.

Link to comment
Share on other sites

14 minutes ago, Promidi said:

Yeah, that could work if the notes are different.  However, if they are the same and/or the timing is all over the place, then it’s a CAL script. 

Dollars to donuts, anyone trying to alternate velocities between two values is starting with a string of notes all at the same velocity that are exactly on the grid. ;^) And even if there's some variation, Select By Filter can usually be made to accomodate that though it might be necessary to make a second selection.

14 minutes ago, Promidi said:

These are the sort of things I would like to see in the new Sonar as native functions rather than having users messing around with CAL scripts.

I strongly agree Sonar should have a library of basic MIDI selection/transformation rules with user-specifiied parameters to facilitate basic operations like this. And, related to this, that all the existing CAL scripts should be converted to native functions as has been frequently suggested in the past.

Edited by David Baay
Link to comment
Share on other sites

14 hours ago, Promidi said:

(do
    (int count 0)
    (int Alt_velocity 100)
    (getInt Alt_velocity "Please enter velocity for every alternative note" 1 127)
    (forEachEvent
        (if (== Event.Kind NOTE)
            (do
                (if (== (% count 2) 0) (= Note.Vel Alt_velocity))
                (++ count))))
);end do

This works for single non-stacked notes but not when notes are stacked vertically at the same time stamp.

What I get:
c3    1-120    2-120    3-120    4-120
b2    1-100    2-100    3-100    4-100

What I want:
c3    1-120    2-100    3-120    4-100
b2    1-120    2-100    3-120    4-100
What line can I add to affect this outcome?  Or will I need to process the lines separately?

Edited by sjoens
Link to comment
Share on other sites

14 minutes ago, sjoens said:

This works for single non-stacked notes but not when notes are stacked vertically at the same time stamp.

What I get:
c3    1-120    2-120    3-120    4-120
b2    1-100    2-100    3-100    4-100

What I want:
c3    1-120    2-100    3-120    4-100
b2    1-120    2-100    3-120    4-100
What line can I add to effect this outcome?  Or will I need to process the lines separately?

Separately....

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...