--[[------------------------------------------------------------------------- Version 1.0 29/05/2026 Flurmy $NWCUT$CONFIG: ClipText $ --]]------------------------------------------------------------------------- nwcut.setlevel(2) nwcut.status = nwcut.const.rc_Success local progname = 'Beat slashes (fl)' local HelpMsg = [[ This tool converts rests or notes to beat slashes (a purely visual marker). In jazz and popular music, passages are often notated with slash noteheads that indicate no specific pitch and show no rhythm. Depending on the content, this might indicate an improvised solo and accompaniment pattern to be devised by the player, or a suggestion to continue in the style of previously notated passage. The NWC rests, notes or chords are uninportant, provided that their durations are multiples of 1/4. Assumes font User 1 being MusicDingsSans or MusicDingsSerif with the same size of the standard NWC2STDA. ]] ------------------------------------------------------------------------------- assert(nwcut.getprop('Mode') == nwcut.const.mode_ClipText, "Input type must be 'Clip Text' - adapt user tool config") ------------------------------------------------------------------------------- -- Backward compatibility function local function GetTextProp(item, lbl) local t = item.Opts[lbl] return (t and t.Text) and t.Text or t end ------------------------------------------------------------------------------- local Lengths = {["Whole"]=4, ["Half"]=2, ["4th"]=1 } local function ComputeSlashes(p_item) if not p_item:HasDuration() or p_item.Opts.Dur.Grace or p_item.Opts.Dur.Triplet then return 0 end local Value = Lengths[p_item:NoteDurBase("Dur")] if not Value then return 0 end if p_item:NoteDots("Dur") == 1 then if Value < 2 then return 0 end Value = (3*Value)/2 elseif p_item:NoteDots("Dur") == 2 then if Value < 4 then return 0 end Value = (7*Value)/4 end return Value end ------------------------------------------------------------------------------- local Skip = 0 for item in nwcut.items() do if not item:IsFake() then -- Skip already processed notes (or vey similar :-) if item:Is('Text') and (GetTextProp(item, 'Text') == '/') then Skip = 2 end if Skip > 0 then nwcut.writeline(item) Skip = Skip - 1 else local Slashes = ComputeSlashes(item) if Slashes == 0 then nwcut.writeline(item) else while Slashes > 0 do nwcut.writeline('|Text|Text:"/"|Placement:AtNextNote|Justify:Center|Pos:-2.5|Scale:80|Font:User1') nwcut.writeline('|Note|Dur:4th|Pos:0z|Opts:StemLength=0,Muted') -- Alternative solution -- nwcut.writeline('|Rest|Dur:4th|Opts:VertOffset=25000') Slashes = Slashes - 1 end end end end end