Skip to main content

Topic: User Tool: Make Tremolo.ms.lua (0.2) (Read 1610 times) previous topic - next topic

User Tool: Make Tremolo.ms.lua (0.2)
The attached user tool will perform the following over a selected range of notes/chords:

  • Convert each non-split-voice note/chord to a rest chord, whose rest duration is half of the chord's duration. The rest will be hidden and the chord will be muted. Any dot on the source chord will be preserved in the rest chord. Also, if the original chord's duration was eighth, the destination note duration will be set to quarter (to suppress the flag).
  • For each pair of converted chords, insert a Tremolo.ms object before the second one.

If the original chords have a forced stem direction, the stem direction for converted chords will be preserved. Otherwise, it will be set to Down. The inserted Tremolo.ms objects will have the default parameters (3 beams, Play=true).
  • Last Edit: 2015-10-26 04:15 pm by Mike Shawaluk

Re: User Tool: Make Tremolo.ms.lua
Reply #1
Hi Mike,

Thanks for doing this - closing the loop I suppose.
You know how I like my dotted and double dotted tremolos.  Well this user tool cannot deal with them. Although there is nothing amiss by using the tool for undotted notes/chords and then dotting afterwards.

This is the STDERR :

Quote
Scripts\MakeTremolo.ms.lua:64: attempt to perform arithmetic on field '?' (a nil value)


Rich.

Re: User Tool: Make Tremolo.ms.lua
Reply #2
You know how I like my dotted and double dotted tremolos.  Well this user tool cannot deal with them. Although there is nothing amiss by using the tool for undotted notes/chords and then dotting afterwards.

This is the STDERR :
Thanks for the feedback Rich. I completely forgot to test this with dotted/double-dotted notes.

Given what I have learned so far with user tools, I think this one will need a significant rewrite to handle dotted notes.  I do have a question for you about the dotted durations though. I've noticed in the Caprice6 sample score, most of the tremolos have a dotted quarter note, but an undotted 16th rest. Normally, the rest duration is 1/2 of the note duration (excepting eighth tremolos, which use a quarter note instead to avoid the pesky flags). Is there a reason that the rest and note portions aren't both dotted the same?

Mike

Re: User Tool: Make Tremolo.ms.lua (0.2)
Reply #3
The "Make Tremolo.ms.lua" user tool has been updated, with the following changes:

  • Dotted notes are now properly handled (I think).
  • Rest chord auditing has been removed, as it is fraught with peril for dotted note durations.
  • Source chord stem direction is now preserved, when the direction is set explicitly.
  • Automatically sets triplet playback mode on Tremolo.ms object if the chord is dotted.
  • Warnings are changed to "future case".

Please refer to the parent post for a description of the tool's behavior and usage.
  • Last Edit: 2015-10-26 04:16 pm by Mike Shawaluk

Re: User Tool: Make Tremolo.ms.lua (0.2)
Reply #4
Is there a reason that the rest and note portions aren't both dotted the same?


Hi Mike,

Thanks for the update - will test when I have time.
In answer to the question - yes - triplets.

Rich.

Re: User Tool: Make Tremolo.ms.lua (0.2)
Reply #5
Problem: I have a score with lots of tremolo like the snippet below. (Lets forget the grace notes.)

Code: (nwc) [Select · Download]
!NoteWorthyComposerClip(2.75,Single)
|Clef|Type:Bass
|Key|Signature:F#|Tonic:G
|TimeSig|Signature:Common
|Dynamic|Style:mf|Pos:-10|Visibility:Never
|Note|Dur:8th,Grace,Slur|Pos:-4|Opts:Muted
|RestChord|Dur:4th,Slur|Opts:Stem=Up,Muted,HideRest|Dur2:Half|Pos2:0,3
|User|Tremolo.ms|Pos:5|Play:N
|RestChord|Dur:4th|Opts:Stem=Up,Muted,HideRest|Dur2:Half|Pos2:5
|Note|Dur:8th,Grace,Slur|Pos:-4|Opts:Muted
|RestChord|Dur:4th,Slur|Opts:Stem=Up,Muted,HideRest|Dur2:Half|Pos2:0,3
|User|Tremolo.ms|Pos:5|Play:N
|RestChord|Dur:4th|Opts:Stem=Up,Muted,HideRest|Dur2:Half|Pos2:5
|Bar
|Note|Dur:8th,Grace,Slur|Pos:-4|Opts:Muted
|RestChord|Dur:4th,Slur|Opts:Stem=Up,Muted,HideRest|Dur2:Half|Pos2:0,2
|User|Tremolo.ms|Pos:5|Play:N
|RestChord|Dur:4th|Opts:Stem=Up,Muted,HideRest|Dur2:Half|Pos2:6
|Note|Dur:8th,Grace,Slur|Pos:-4|Opts:Muted
|RestChord|Dur:4th,Slur|Opts:Stem=Up,Muted,HideRest|Dur2:Half|Pos2:0,2
|User|Tremolo.ms|Pos:5|Play:N
|RestChord|Dur:4th|Opts:Stem=Up,Muted,HideRest|Dur2:Half|Pos2:6
|Bar
|Note|Dur:8th,Grace,Slur|Pos:-4|Opts:Muted
|RestChord|Dur:4th,Slur|Opts:Stem=Up,Muted,HideRest|Dur2:Half|Pos2:0,2
|User|Tremolo.ms|Pos:5|Play:N
|RestChord|Dur:4th|Opts:Stem=Up,Muted,HideRest|Dur2:Half|Pos2:6
|Note|Dur:8th,Grace,Slur|Pos:-4|Opts:Muted
|RestChord|Dur:4th,Slur|Opts:Stem=Up,Muted,HideRest|Dur2:Half|Pos2:0,2
|User|Tremolo.ms|Pos:5|Play:N
|RestChord|Dur:4th|Opts:Stem=Up,Muted,HideRest|Dur2:Half|Pos2:6
|Bar
!NoteWorthyComposerClip-End

The tremolo notes are somehow "cluttered" and hard to read at a glance.
A stem a bit longer can make things clearer. (See below)

Code: (nwc) [Select · Download]
!NoteWorthyComposerClip(2.75,Single)
|Note|Dur:8th,Grace,Slur|Pos:-4|Opts:Muted
|RestChord|Dur:4th,Slur|Opts:Stem=Up,StemLength=9,Muted,HideRest|Dur2:Half|Pos2:0,3
|User|Tremolo.ms|Pos:5|Play:N
|RestChord|Dur:4th|Opts:Stem=Up,StemLength=9,Muted,HideRest|Dur2:Half|Pos2:5
|Note|Dur:8th,Grace,Slur|Pos:-4|Opts:StemLength=9,Muted
|RestChord|Dur:4th,Slur|Opts:Stem=Up,StemLength=9,Muted,HideRest|Dur2:Half|Pos2:0,3
|User|Tremolo.ms|Pos:5|Play:N
|RestChord|Dur:4th|Opts:Stem=Up,StemLength=9,Muted,HideRest|Dur2:Half|Pos2:5
|Bar
!NoteWorthyComposerClip-End

The problem is that the stem increment is fixed, but the stems are not all of equal length; changing them all by hand is very tedious.
A solution is using the magic global modification, and I think I'll build up the relevant command line, but I was wondering: since there is a tool for "making tremolos", why not include the "incremental stem length" parameter?

Re: User Tool: Make Tremolo.ms.lua (0.2)
Reply #6
Problem: I have a score with lots of tremolo like the snippet below. (Lets forget the grace notes.)

Code: (nwc) [Select · Download]
!NoteWorthyComposerClip(2.75,Single)
--snip--

The tremolo notes are somehow "cluttered" and hard to read at a glance.
A stem a bit longer can make things clearer. (See below)

Code: (nwc) [Select · Download]
!NoteWorthyComposerClip(2.75,Single)
--snip--

The problem is that the stem increment is fixed, but the stems are not all of equal length; changing them all by hand is very tedious.
A solution is using the magic global modification, and I think I'll build up the relevant command line, but I was wondering: since there is a tool for "making tremolos", why not include the "incremental stem length" parameter?

Thanks for the suggestion; I'll consider it for my next update of that user tool.

There would seem to be a few things to consider for this addition:
  • I don't think there is a way for a tool to tell how long a note's stem is, if the override box is not already checked. So, if this were added to the tool, the actual desired stem length, not just the increment, might need to be specified.
  • I can see where there might be cases where someone would want the stem lengths on the two tremolo notes to be different (such as your example). The tool could prompt for that too, but that does make it more complicated to use.

Re: User Tool: Make Tremolo.ms.lua (0.2)
Reply #7
I don't think there is a way for a tool to tell how long a note's stem is, if the override box is not already checked.
If I select a note and open the properties box, I see a value of 7 for the stemlength (4 for a grace note). So I think your tool can use these values as a default when item:Get('Opts', 'StemLength') returns nil.
Always look on the bright side of life!

Re: User Tool: Make Tremolo.ms.lua (0.2)
Reply #8
I don't think there is a way for a tool to tell how long a note's stem is, if the override box is not already checked.
Yes, that's exactly the wall I crashed on now when I tried to use "global modification"!

Re: User Tool: Make Tremolo.ms.lua (0.2)
Reply #9
If I select a note and open the properties box, I see a value of 7 for the stemlength (4 for a grace note). So I think your tool can use these values as a default when item:Get('Opts', 'StemLength') returns nil.
You would think so, but you would be wrong. :)  Look at the notes in the following clip:

Code: (nwc) [Select · Download]
!NoteWorthyComposerClip(2.75,Single)
|Note|Dur:4th|Pos:8|Opts:Stem=Up
|Note|Dur:4th|Pos:8|Opts:Stem=Up
|Note|Dur:4th|Pos:-14|Opts:Stem=Up
|Note|Dur:4th|Pos:-14|Opts:Stem=Up
|Note|Dur:8th|Pos:8|Opts:Stem=Up,Beam=First
|Note|Dur:8th|Pos:-3|Opts:Stem=Up,Beam=End
|Bar
|RestChord|Dur:4th|Opts:Stem=Down,StemLength=7,Muted,HideRest|Dur2:Half|Pos2:8
|User|Tremolo.ms|Pos:0
|RestChord|Dur:4th|Opts:Stem=Down,StemLength=7,Muted,HideRest|Dur2:Half|Pos2:8
|RestChord|Dur:4th|Opts:Stem=Down,StemLength=7,Muted,HideRest|Dur2:Half|Pos2:-14
|User|Tremolo.ms|Pos:0
|RestChord|Dur:4th|Opts:Stem=Down,StemLength=7,Muted,HideRest|Dur2:Half|Pos2:-14
|RestChord|Dur:8th|Opts:Stem=Down,StemLength=7,Muted,HideRest|Dur2:4th|Pos2:8
|User|Tremolo.ms|Pos:0
|RestChord|Dur:8th|Opts:Stem=Down,StemLength=7,Muted,HideRest|Dur2:4th|Pos2:-3
!NoteWorthyComposerClip-End
The notes to the left of the bar do not have the override box checked; those to the right of the bar do. As you can see, NWC makes it own adjustments to non-overridden stem lengths based on staff position and stem direction (and beam slope, if the notes are beamed), and there is no way for a user tool to obtain this information. Still, as you say, a tool could simply assume a default of 7 when no value is stored, and the user could adjust them manually if they looked wrong.

Or on the flip side: functionality could be added to the Tremolo objects so they would draw their own stems if the note stem length was set to 0. This would give better default tremolos for cases such as the last pair. But the current Tremolo code is able to find the actual stem end points and draw the beams between them.

Re: User Tool: Make Tremolo.ms.lua (0.2)
Reply #10
You would think so, but you would be wrong. :) 
I don't think it anymore.  :-[
Always look on the bright side of life!