Helpful ReplyQuantizing notes lenghts (durations)

Author
hypolydien
Max Output Level: -85 dBFS
  • Total Posts : 258
  • Joined: 2005/09/16 17:43:50
  • Location: Montréal,Québec, Canada
  • Status: offline
2017/05/08 18:47:15 (permalink)

Quantizing notes lenghts (durations)

Hello,
I have tried to this different ways which are all quite tedious and I am wondering of there would be a faster way.
Lets say I have a bunch of 1/8 notes in a midi recording which I want to come out with a specific staccato feel. I notice in the event inspector that the notes' durations ranges form 190 to 330 ticks. It turns out I like the way the notes around 275 ticks sound. I would like to change the values of all the notes toward that value without having them all exactly 275 long, so the results does not sound so machine-like.
What is strange is that this works if you choose a specific note value in the resolution field. If I select a 1/16 value in the resolution field, select only "Notes Duration" in the "Change" field and adjust the Strenght to %90, I get all the notes' durations going %90 toward the 240 ticks value of a 1/16 note. However, if I type 275 in the resolution field and do the same then the results are completely erratic. Some notes duration values move towards 275 ticks others away from it.
I know I can change all of them to exactly 275 using the event inspector. I know I can use select by filter and select all the ones which are too long and use Process Lenght to change them by percentage towards my desired 275 value, and then start over with all the notes which are too short making them longer. However, if I want to do this with an orchestral arrangement with hundreds of notes, it is a very long and tedious process.
I have tried to copy a note of my desired length to clipboard and then use groove quantize setting Strength Duration towards 90% and turning off Time and Velocity, but the results are also erratic, with some notes values moving towards my desired length an other away from it.
 
Dos anyone know a quicker way to do this? BTW I am using  Sonar Platinum  23.2.0
 
Thanks for any help,
 
Jean
#1
Slugbaby
Max Output Level: -33.5 dBFS
  • Total Posts : 4172
  • Joined: 2004/10/01 13:57:37
  • Location: Toronto, Canada
  • Status: offline
Re: Quantizing notes lenghts (durations) 2017/05/08 18:53:20 (permalink)
If you can highlight them all, either by clicking on the piano key they're on (if it's the same note), or by using the Select tool, do that.  Then change the cursor to the Edit tool, grab the right edge of one note, and move it to where you want it.  
This will extend the notes by the same amount, not to the same length.
 
EDIT:  That willl only work for extending or shrinking the notes, but not both.   Try highlighting the ones you want extended, and dragging the durations longer.  Then highlight the ones you want shrunk, and dragging them to the left to shorten them.

http://www.MattSwiftMusic.com
 
Dell i5, 16Gb RAM, Focusrite 2i2 IO, Telecasters, P-bases, Personal Drama for a muse.
#2
Bristol_Jonesey
Max Output Level: 0 dBFS
  • Total Posts : 16775
  • Joined: 2007/10/08 15:41:17
  • Location: Bristol, UK
  • Status: offline
Re: Quantizing notes lenghts (durations) 2017/05/08 19:49:36 (permalink)
Use the Event inspector in the Control Bar
 
Lasso the notes you want to adjust the lengths of and type 275 in the duration field

CbB, Platinum, 64 bit throughout
Custom built i7 3930, 32Gb RAM, 2 x 1Tb Internal HDD, 1 x 1TB system SSD (Win 7), 1 x 500Gb system SSD (Win 10), 2 x 1Tb External HDD's, Dual boot Win 7 & Win 10 64 Bit, Saffire Pro 26, ISA One, Adam P11A,
#3
SquireBum
Max Output Level: -84 dBFS
  • Total Posts : 347
  • Joined: 2013/06/26 13:23:55
  • Status: offline
Re: Quantizing notes lenghts (durations) 2017/05/08 23:51:21 (permalink)
hypolydien
 
Dos anyone know a quicker way to do this? BTW I am using  Sonar Platinum  23.2.0
 
Thanks for any help,
 
Jean


 
Jean,
The only quicker way to accomplish what you want is with a CAL script.  I created the CAL script at the end of this post that should meet your requirements.
 
The script contains 4 user prompts:  Shortest duration to adjust in ticks, longest duration to adjust in ticks, target duration, and percent strength.  The current defaults for these inputs are: 120, 480, 240, and 100.  Using your example, you would enter 190, 330, 275, and 90.
 
If you read the comments in the script you will see where you can change the default values for these prompts if they don't meet your requirements.
 
I only did limited testing on a limited amount of data and it worked successfully on my system, but as with all CAL scripts, use with caution.
 
Just an FYI:
Quantize did not appear to function as expected, because when you set the Duration field to 275 you are essentially telling SONAR that the snap grid is now occurring every 275 ticks.  When the PRV grid is set to a standard value, such as 1/16, the resulting Quantize function will appear incorrect, but is actually adjusting the end of the notes on the 275 grid. 
 
You can prove this by setting the global snap to 275 ticks and set the PRV grid resolution to "Follow Snap".  If you then Quantize using the 275 tick duration, you will see that the end of each note is correctly snapping to your new 275 tick grid.
 
Hope this helps,
-- Ron
 
-----------------------------------------Cut here---------------------------------------------
;;Adjust duration to target value by percent
;;This CAL script will adjust MIDI note durations within a user selected range in ticks
;;closer to a user selected target value in ticks based on a user selected strength.
;;Checks provided to prevent zero durations.
;;
;;
(do
    (dword offset)
    (int new_duration)

    ;;initialize user input variables and defaults
    (int lowDur 120)       ;;<= default shorted duration value can be adjusted here
    (int hiDur 480)        ;;<= default longest duration value can be adjusted here
    (int targetDur 240)    ;;<= default target duration value can be adjusted here
    (int percent 100)      ;;<= default strength percent value can be adjusted here

    ;;initialize valid input field range values
    (int validLow 60)      ;;<= valid low value for duration input fields can be adjusted here
    (int validHi 960)      ;;<= valid high value for duration input fields can be adjusted here

    ;;get all user input
    (getInt lowDur "Select shortest duration to adjust (ticks): " validLow validHi)
    (getInt hiDur "Select longest duration to adjust (ticks): " lowDur validHi)
    (getInt targetDur "Select target duration (ticks): " validLow validHi)
    (getInt percent "Select %strength (1-100): " 1 100)

    (forEachEvent
        (if (== Event.Kind NOTE)
            (do
                ;;is the note within the low and hi range?
                (if (&& (>= Note.Dur lowDur) (<= Note.Dur hiDur))
                  (do
                     ;; determine offset using target duration and percent strength
                     (if (>= Note.Dur targetDur)
                         (= offset (- Note.Dur targetDur))
                         (= offset (- targetDur Note.Dur))
                     );end if
                     (*= offset percent)
                     (/= offset 100)

                     ;; calculate new duration
                     (= new_duration Note.Dur)
                     (if (>= Note.Dur targetDur)
                         (-= new_duration offset)
                         (+= new_duration offset)    
                      );end if

                      ;;is calculated new duration not a zero value?
                      (if (>= new_duration 0)
                            (= Note.Dur new_duration)
                      );end if
                  );end do
                );end if
            );end do
        );end if
    );end for
);end do

Cakewalk by Bandlab, Sonar Platinum x64 2017.10, X3E, X2a, X1d, 8.5
Windows 10 x64
AMD Phenom II X4 955 3.20 GHz
8 GB Ram
Nvidia GeForce 9500 GT
Echo Gina 3G
#4
hypolydien
Max Output Level: -85 dBFS
  • Total Posts : 258
  • Joined: 2005/09/16 17:43:50
  • Location: Montréal,Québec, Canada
  • Status: offline
Re: Quantizing notes lenghts (durations) 2017/05/09 17:06:45 (permalink)
Thanks everyone!
------------------------------------------------------------------
Ron,
 
Thanks so much, this is really cool. I hope you didn't write this just for me. I am not a programmer so this seems like a lot of work to me!
I have been wanting something like this for quite a while. I am a string teacher and  I like do record play-along practice material for my students. I am trying to salvage an old midi recording of the Bach double violin Concerto. Back then, I recorded it using a piano sound and exact durations weren't so much of an issue. Now I am trying to double the parts with a string track and since the strings are sustained, the wrong durations kill the feel. 
 
I had never worked with CAL scripts before, so I just want to run this by you to make sure I did this right:
I copied the code above in NotePad, made up a name(I called it Quantize Length)saved it with a .CAL extension in  C:\Cakewalk Content\SONAR Platinum\CAL Scripts.
From then I was able to use it like any other CAL scripts.
 
This will save me a lot of time in the future. I don't need to do so many takes to get the perfect feel as I can fix it so much quicker. It will also be useful to adjust duration values to keep the same feel when I change tempos .
 
Would you know of a duration randomizer CAL script by any chance  ?
--------------------------------------------------------------------------
If you can highlight them all, either by clicking on the piano key they're on (if it's the same note), or by using the Select tool, do that.  Then change the cursor to the Edit tool, grab the right edge of one note, and move it to where you want it.  
This will extend the notes by the same amount, not to the same length.
 
I actually didn't think of using the piano roll view for this. My background is classical and jazz so I rarely use piano roll view. I usually stick to Staff view and Event List View. I do the same thing selecting notes in the staff view and running the Length Process using percentages. But I can see this could be useful and quicker for a small selection of notes. Thanks! 
------------------------------------------------------------------------------------------------
Use the Event inspector in the Control Bar 
Lasso the notes you want to adjust the lengths of and type 275 in the duration field
 
Thanks for this. I had tried this already, unfortunately it made all the values exactly 275, and I wanted a more randomized result. This could work well if I could apply some duration randomizing script afterwards.
 
 
#5
garrigus
Max Output Level: 0 dBFS
  • Total Posts : 8599
  • Joined: 2003/11/05 17:23:21
  • Location: www.garrigus.com
  • Status: offline
Re: Quantizing notes lenghts (durations) 2017/05/09 17:30:50 (permalink)
The Event Inspector also allows you to scale the various note values via a percentage or by adding and subtracting relative amounts. Not sure if that's what you might need as well, but this video explains it...
https://www.youtube.com/watch?v=Ixb8gIcGM-U&index=3&list=PLFdNhPVD03KCTxKOWpz8tfzCMbWfXASJS

--
Scott R. Garrigus - http://www.garrigus.com
* Cakewalk SONAR Video Tutorials: https://www.youtube.com/u...gus?sub_confirmation=1
* Author of the Cakewalk Sonar and Sony Sound Forge Power book series: http://garrigus.com/?PowerBooks
* Publisher of the DigiFreq music recording newsletter: http://www.digifreq.com/
* Publisher of the NewTechReview consumer tech newsletter: http://www.newtechreview.com/
#6
Anderton
Max Output Level: 0 dBFS
  • Total Posts : 14070
  • Joined: 2003/11/06 14:02:03
  • Status: offline
Re: Quantizing notes lenghts (durations) 2017/05/09 19:02:22 (permalink) ☄ Helpfulby tlw 2017/05/09 21:51:13
hypolydien
Thanks for this. I had tried this already, unfortunately it made all the values exactly 275, and I wanted a more randomized result. This could work well if I could apply some duration randomizing script afterwards.

 
You don't need a script.
 
Insert the Quantize MIDI FX and select only Duration. Then enable the Random option, and choose the amount of randomness. Use a high resolution. 
 

The first 3 books in "The Musician's Guide to Home Recording" series are available from Hal Leonard and http://www.reverb.com. Listen to my music on http://www.YouTube.com/thecraiganderton, and visit http://www.craiganderton.com. Thanks!
#7
jsg
Max Output Level: -69 dBFS
  • Total Posts : 1079
  • Joined: 2003/11/20 04:54:18
  • Location: San Francisco, California
  • Status: offline
Re: Quantizing notes lenghts (durations) 2017/05/09 19:19:57 (permalink)
hypolydien
Hello,
I have tried to this different ways which are all quite tedious and I am wondering of there would be a faster way.
Lets say I have a bunch of 1/8 notes in a midi recording which I want to come out with a specific staccato feel. I notice in the event inspector that the notes' durations ranges form 190 to 330 ticks. It turns out I like the way the notes around 275 ticks sound. I would like to change the values of all the notes toward that value without having them all exactly 275 long, so the results does not sound so machine-like.
What is strange is that this works if you choose a specific note value in the resolution field. If I select a 1/16 value in the resolution field, select only "Notes Duration" in the "Change" field and adjust the Strenght to %90, I get all the notes' durations going %90 toward the 240 ticks value of a 1/16 note. However, if I type 275 in the resolution field and do the same then the results are completely erratic. Some notes duration values move towards 275 ticks others away from it.
I know I can change all of them to exactly 275 using the event inspector. I know I can use select by filter and select all the ones which are too long and use Process Lenght to change them by percentage towards my desired 275 value, and then start over with all the notes which are too short making them longer. However, if I want to do this with an orchestral arrangement with hundreds of notes, it is a very long and tedious process.
I have tried to copy a note of my desired length to clipboard and then use groove quantize setting Strength Duration towards 90% and turning off Time and Velocity, but the results are also erratic, with some notes values moving towards my desired length an other away from it.
 
Dos anyone know a quicker way to do this? BTW I am using  Sonar Platinum  23.2.0
 
Thanks for any help,
 
Jean




Try either one of these CAL routines.   The one posted above didn't work at all, at least that was my experience.
 
RANDOM NOTE LENGTH (CAL Routine)
;;Randomize duration
;;This script will randomize MIDI note duration based on a user
;;provided range in ticks from 1 to 240 ticks.  Checks are
;;provided to prevent zero durations.
;;
;;
(do
    (int offset)
    (int range 30)            ;; Change default input value here
    (getInt range "Select +/- range (ticks): " 1 240)
    (int new_duration)
    (int pos_range range)
    (int  neg_range (*= range -1))
    (forEachEvent
        (if (== Event.Kind NOTE)
            (do
                (= offset (random neg_range pos_range))
                (= new_duration Note.Dur)
                (+=  new_duration offset)
                (if (>= new_duration 0)  ;; Make sure calculated duration is not zero
                        (= Note.Dur new_duration)
                );end if
            );end do
        );end if
    );end for
);end do
 
 
;;  RandTime.CAL, written 1991 by Douglas L. Fetter [UID 5476]
;;;
;;  This CAL routine was written to humanize the starting times of notes
;;  for sequences that have been entered using either Step Record or which
;;  have been Quantized. The user will be requested to enter a value for the
;;  maximum number of ticks by which a note's start time can be shifted. The
;;  start times of all notes found in the From-to-Thru region on the selected
;;  track(s) will be shifted by a random value which is within a range of +/-
;;  the user entered value. Before performing a shift that will move a note
;;  earlier in time, this CAL routine will check to make certain that such a
;;  negative shift will not cause a note to be moved earlier than time 1:1:0
;;  (the earliest possible time value). If it would try to go earlier, the
;;  offset is adjusted so that the note is instead moved just up to 1:1:0,
;;  and no further.
;;;
;;  Then, since shifting one note later in time and a subsequent note earlier
;;  might cause notes of the same key value to become overlapped (a situation
;;  which is not handled well by most synths), the duration of shifted notes
;;  is adjusted proportionately so as to prevent this routine from creating
;;  this situation. As part of this duration shortening process, this CAL
;;  routine will check that reduced notes are not made shorter than a user
;;  specified value. If they would become too short, an error is reported and
;;  the user asked if the CAL program should abort. If abort is selected, the
;;  Cakewalk NOW Time will be altered to the point where the error occurred
;;  so that the user can take a look at the problem area. The user should do
;;  an Edit UNDO operation to restore the data to the values prior to the
;;  execution of the aborted RandTime.CAL routine.
;;;
;;  Note: the "Processing Note Event" message line was put in to indicate
;;  program status to the user. However, since it adds another 15-20% to
;;  the program execution time, it can be removed at the user's discretion.

;Prolog
;
(do
  (dword SaveTime)         ; Storage for setting NOW time if routine aborted
  (int Range 15)           ; User specified range for +/- to note start times
  (int NegRange)           ; negative version of Range value
  (int Offset)             ; random number between NegRange & Range
  (int Decrease)           ; amount to decrease duration by to avoid overlap
  (int MinDur 5)           ; User specified note duration minimum value
  (int Abort 0)            ; 0 => Program Running; 1 => User Requested Abort
  (int EventCnt 0)         ; Event counter to provide processing status line

  (getInt Range "Enter maximum number of ticks to alter note start times +/- by." 0 480)
  (= NegRange (* Range -1))
  (getInt MinDur "Enter minimum duration (in ticks) a note may be reduced to." 1 480)
)
 
 

RANDOM NOTE LENGTH & START TIME (CAL Routine)
;Body
;
(if (== Abort 1)  ; test if user has aborted note processing
  (message "RandTime.CAL Aborted by User; Please Wait for Routine to Complete")
    ; provide message for user while routine continues thru remaining events

  (if (!= Event.Kind NOTE)  ; else test if event kind is a note
    NIL  ; do nothing if event type is not a note

    (do  ; else process events that are notes
      (= Offset (random NegRange Range))  ; offset is a random value within +/- Range
      (message "RandTime.CAL Processing Note Event #" (++ EventCnt) "with Offset of " Offset)

      (if (< Offset 0)  ; check if minus Offset that will shift note earlier
        (do  ; do these steps for a minus Offset
          (if (> (* Offset -1) Event.Time)
                            ; check if it moves start time before 1:1:0
            (do  ; if moves earlier than the earliest possible time
              (= Offset Event.Time)  ; make it equal to start time
              (*= Offset -1)  ; restore it to negative (this moves it to 1:1:0)
            )  ; close moves earlier than the earliest possible time
            NIL  ; no problem if negative shift not before 1:1:0
          )  ; close check if it moves start time before 1:1:0
        )  ; close do these steps for a minus Offset
        NIL  ; no extra check needed if shift is positive
      )  ; close check if minus Offset that will shift note earlier

      (= Decrease (+ Range Offset))
      (if (<= (+ Decrease MinDur) Note.Dur)  ; check decreased duration to Min
         (-= Note.Dur Decrease)  ; reduce duration if passes user's minimum
                                 ; else an error, so check with user for abort
         (getInt Abort "ERROR: A Duration went less than User Minimum; Enter 1 to Abort!" 0 1)
      )  ; close check decreased duration to Min

      (if (== Abort 0)           ; check if program to be aborted
        (+= Event.Time Offset)   ; if not, perform shift of note's start time
        (= SaveTime Event.Time)  ; if aborted, then save event time for later
      )  ; close check if program to be aborted

    )  ; close of process events that are notes
  )  ; close test if event type is a note
)  ; close test if user has aborted note processing

;Epilog
;
(if (== Abort 0)  ; check if program was aborted
  NIL  ; if not aborted, nothing to do in epilog
  (do  ; else, set Now time to point when abort occurred & display message
    (= Now SaveTime)  
    (pause "RandTime.CAL Aborted by User; Use UNDO to Restore Original Values  > Hit Enter <")
  )
)  ; close check if program was aborted


 
Jerry
www.jerrygerber.com
 
#8
SquireBum
Max Output Level: -84 dBFS
  • Total Posts : 347
  • Joined: 2013/06/26 13:23:55
  • Status: offline
Re: Quantizing notes lenghts (durations) 2017/05/09 19:21:42 (permalink)
hypolydien
Thanks so much, this is really cool. I hope you didn't write this just for me. I am not a programmer so this seems like a lot of work to me!

 
Jean,
  You are very welcome.  I enjoyed the challenge.

hypolydien
I had never worked with CAL scripts before, so I just want to run this by you to make sure I did this right:
I copied the code above in NotePad, made up a name(I called it Quantize Length)saved it with a .CAL extension in  C:\Cakewalk Content\SONAR Platinum\CAL Scripts.
From then I was able to use it like any other CAL scripts.

 
It looks like you did everything correctly here.

hypolydien
Would you know of a duration randomizer CAL script by any chance  ?



It is a coincidence that you ask about a randomizer CAL script, because I created the Quantize Duration script yesterday by modifying and expanding a Randomize duration script that I had written back in February of this year. 
 
The script below contains only one user input for the range in ticks that you want the duration to vary in the plus and minus direction.  Enter any value between 1 and 240 ticks.  The default value is set to 30 ticks.
 
Just follow the same procedure you performed for the previous script to install it and as usual, use the script with caution.
 
Hope this helps,
-- Ron
------------------------------------- CUT HERE --------------------------------------------------------
;;Randomize duration
;;This script will randomize MIDI note duration based on a user
;;provided range in ticks from 1 to 240 ticks.  Checks are
;;provided to prevent zero durations.
;;
;;
(do
    (int offset)
    (int range 30)            ;; Change default input value here
    (getInt range "Select +/- range (ticks): " 1 240)
    (int new_duration)
    (int pos_range range)
    (int  neg_range (*= range -1))
    (forEachEvent
        (if (== Event.Kind NOTE)
            (do
                (= offset (random neg_range pos_range))
                (= new_duration Note.Dur)
                (+=  new_duration offset)
                (if (>= new_duration 0)  ;; Make sure calculated duration is not zero
                        (= Note.Dur new_duration)
                );end if
            );end do
        );end if
    );end for
);end do

Cakewalk by Bandlab, Sonar Platinum x64 2017.10, X3E, X2a, X1d, 8.5
Windows 10 x64
AMD Phenom II X4 955 3.20 GHz
8 GB Ram
Nvidia GeForce 9500 GT
Echo Gina 3G
#9
hypolydien
Max Output Level: -85 dBFS
  • Total Posts : 258
  • Joined: 2005/09/16 17:43:50
  • Location: Montréal,Québec, Canada
  • Status: offline
Re: Quantizing notes lenghts (durations) 2017/05/10 17:17:16 (permalink)
Thanks everyone again,
I end up with a nice collection of  scripts and tricks from this post!
 
Ron,
I have been using the Quantize Duration script, and it works very well with my Windows 7 system. The duration randomizer will prove useful when duration values end up being too similar after being quantized, and I want to shuffle them up to humanize things.
 
Jerry,
Thanks also, These scripts might turn out to be useful as well. I recognize the RANDTIME script from the list which shows in the "run CAL" menu in Process. I have used it before. It is nice to have a second random note length script. I can experiment and see which one works best.
 
Craig,
Thanks also, using midi FX is indeed a quick way to go about it. The only problem in this case is it think it applies the same percentage randomizing effect to all notes in the track whether they are 1/4, 1/8 or 1/16. In this particular piece I want to randomize differently for the different notes values. But again, one never has too many tricks in their bag.
 
Jean
 
#10
vanblah
Max Output Level: -85 dBFS
  • Total Posts : 298
  • Joined: 2004/12/07 23:23:51
  • Location: Memphis
  • Status: offline
Re: Quantizing notes lenghts (durations) 2017/05/10 18:53:40 (permalink)
Franks MIDI plugins still work great in the current version of Sonar.  I use the humanize function to do exactly what you're talking about.
 
http://www.midi-plugins.de/
#11
hypolydien
Max Output Level: -85 dBFS
  • Total Posts : 258
  • Joined: 2005/09/16 17:43:50
  • Location: Montréal,Québec, Canada
  • Status: offline
Re: Quantizing notes lenghts (durations) 2017/05/11 14:32:49 (permalink)
vanblah
Franks MIDI plugins still work great in the current version of Sonar.  I use the humanize function to do exactly what you're talking about.
 
http://www.midi-plugins.de/


Thanks or that, I now remember Frank's midi plugins from a while ago.
I am looking at changing the midi data itself, this way I can analyze it when I get what I want, and I know what I am searching for the next time around. 
-----------------------------------------------------------------------------------------------------
 
Ron,  Jerry
Since we're on the randomizing scripts subject...
I maybe pushing my luck but would any of you have a randomizing script or Velocity as well?
I don't seem to see one in the CAL scripts folder.
Thanks,
 
Jean
 
#12
Jump to:
© 2024 APG vNext Commercial Version 5.1