Skip to main content
Topic: ChordPlay.nw (Read 40791 times) previous topic - next topic

ChordPlay.nw

ChordPlay enables show and play of a named chord. For play back, the duration of the chord is determined by the indicated Span value, which defines the number of notes/rests for which the chord will play.

The Font, Size, and Style can be set within any instance of ChordPlay, but only the first instance in a staff generally needs to define the font details. By default, all subsequent ChordPlay objects will use the font details specified in the first instance in the staff. If the first instance is being used only for setting default display options, then it will show as a special object.

The following clip will get you started:

Code: (nwc) [Select · Download]
!NoteWorthyComposerClip(2.75,Single)
|User|ChordPlay.nw|Pos:7|Font:MusikChordSerif|Size:8|Style:b|Visibility:Never
|Clef|Type:Treble
|Instrument|Name:"Acoustic Guitar (nylon)"|Patch:24|Bank:0,112|Trans:0|DynVel:10,30,45,60,75,92,108,127|Pos:-9
|TimeSig|Signature:4/4
|User|ChordPlay.nw|Pos:7|Name:A|Span:1
|Rest|Dur:Whole
|Bar
|User|ChordPlay.nw|Pos:7|Span:1|Name:A
|Rest|Dur:Whole
|Bar
|User|ChordPlay.nw|Pos:7|Span:1|Name:D
|Rest|Dur:Whole
|Bar
|User|ChordPlay.nw|Pos:7|Span:1|Name:A
|Rest|Dur:Whole
|Bar
|User|ChordPlay.nw|Pos:7|Span:1|Name:D
|Rest|Dur:Whole
|Bar
|User|ChordPlay.nw|Pos:7|Span:1|Name:F#m
|Rest|Dur:Whole
|Bar
|User|ChordPlay.nw|Pos:7|Span:1|Name:A
|Rest|Dur:Whole
|Bar
|User|ChordPlay.nw|Pos:7|Span:1|Name:C#m
|Rest|Dur:Half
|User|ChordPlay.nw|Pos:7|Span:1|Name:F#
|Rest|Dur:Half
|Bar
|User|ChordPlay.nw|Pos:7|Span:1|Name:B7
|Rest|Dur:Half
|User|ChordPlay.nw|Pos:7|Span:1|Name:E7
|Rest|Dur:Half
|Bar|Style:LocalRepeatClose|Repeat:4
!NoteWorthyComposerClip-End

Re: ChordPlay.nw

Reply #1
New version with strum direction and improved support for inversions. This clip is a good example of walking the bass note from C5 down to C4 within a chord progression.

Code: (nwc) [Select · Download]
!NoteWorthyComposerClip(2.74974,Single)
|Clef|Type:Treble
|Text|Text:"walk the bass note from C5 down to C4"|Font:StaffBold|Pos:-11|Color:1|Visibility:Never
|User|ChordPlay.nw|Pos:8|Name:C|Span:1|Strum:Up|Font:MusikChordSerif|Size:10|Style:Bold|Octave:5
|Rest|Dur:Whole
|Bar
|User|ChordPlay.nw|Pos:8|Name:G/B|Span:1|Strum:Down|Octave:4
|Rest|Dur:Whole
|Bar
|User|ChordPlay.nw|Pos:8|Name:Am|Span:1|Strum:Up
|Rest|Dur:Whole
|Bar
|User|ChordPlay.nw|Pos:8|Name:Am/G|Span:1|Strum:Down
|Rest|Dur:Whole
|Bar
|User|ChordPlay.nw|Pos:8|Name:F|Span:1|Strum:Up
|Rest|Dur:Whole
|Bar
|User|ChordPlay.nw|Pos:8|Name:C/E|Span:1|Strum:Down
|Rest|Dur:Whole
|Bar
|User|ChordPlay.nw|Pos:8|Name:Dm7|Span:1|Strum:Up
|Rest|Dur:Whole
|Bar
|User|ChordPlay.nw|Pos:8|Name:C|Span:1|Strum:Down
|Rest|Dur:Whole
!NoteWorthyComposerClip-End

Re: ChordPlay.nw

Reply #2
Updated to allow custom key sequences:

Code: (nwc) [Select · Download]
!NoteWorthyComposerClip(2.74974,Single)
|User|ChordPlay.nw|Pos:7|Name:C|Span:1|Keys:0,4,7,16,19,24,28,31,28,24,19,16,7,4,0
|Rest|Dur:Whole
|Bar
|User|ChordPlay.nw|Pos:7|Name:D|Span:1|Keys:0,4,7,16,19,24,28,31,28,24,19,16,7,4,0
|Rest|Dur:Whole
|Bar
|User|ChordPlay.nw|Pos:7|Name:E|Span:1|Keys:0,4,7,16,19,24,28,31,28,24,19,16,7,4,0
|Rest|Dur:Whole
!NoteWorthyComposerClip-End

Updated again to fix timing errors when spanning small duration intervals.

Re: ChordPlay.nw

Reply #3
Which allows it to be used to retime grace notes:
Code: (nwc) [Select · Download]
!NoteWorthyComposerClip(2.74974,Single)
|Clef|Type:Treble
|RestChord|Dur:8th|Opts:Stem=Down,HideRest|Dur2:4th|Pos2:-2
|User|ChordPlay.nw|Pos:6|Name:C|Span:3|Keys:0|Octave:5|Visibility:Never
|Rest|Dur:16th|Opts:Stem=Down|Visibility:Never
|User|ChordPlay.nw|Pos:8|Name:E|Span:2|Keys:0|Octave:5|Visibility:Never
|Rest|Dur:16th|Opts:Stem=Down|Visibility:Never
|Note|Dur:16th,Grace|Pos:-6^|Opts:Stem=Up,Beam=First,Muted
|Note|Dur:16th,Grace|Pos:-4^|Opts:Stem=Up,Beam=End,Muted
|Chord|Dur:4th|Pos:-6,-4,-2
|Note|Dur:4th|Pos:-2
|Note|Dur:4th|Pos:-2
!NoteWorthyComposerClip-End
Registered user since 1996

Re: ChordPlay.nw

Reply #4
Updated to support new property menu and native font selection dialog.

After adding a ChordPlay.nw object, you can refine its behavior by either right clicking on its anchor, or by selecting it and pressing J.

Re: ChordPlay.nw

Reply #5
I have to record my continued objection to the way the development and implementation of user objects is going.

1. When inserting a user object it is really counter productive to have to insert it blind without setting any parameters and then edit it using select and "j"  to look through each parameter to see what is set in there to see if you want / need to change it. What a waste of effort and additional keying action

2. Noteworthy Objects can normally be seen traditionally by selecting the object and pressing ALT and ENTER. With this new method, you can only see items that have been changed from the default. There is nowhere you can now see a list of parameters and how they have been set without numerous key actions via select and "j".

3. The only parameters passed in a copy to an nwctxt clip is defaults that have been changed. This means that if you want to do global changes on parameters via a text editor, you have to go and deliberately alter one so that it gets passed via nwctxt to the text editor. What a waste of time and effort.

Not being able to see what the parameters are and being able to change them when inserting a new object is a leap backward.
Not having all parameters in nwctxt for a particular user object is a leap backward.
Not having parameters displayed in the user object properties box unless they are not the default is a leap backward.

I've had my say !  I would ask for these leaps backward to be re-considered.


Rich.

Re: ChordPlay.nw

Reply #6
2. Noteworthy Objects can normally be seen traditionally by selecting the object and pressing ALT and ENTER.
Which brings up a Property Sheet that is customized for each object. That will not happen for User Objects.

We have been down this road with wxphp and User Tools. My head still hurts from the experience ...
Edit: Added strikethrough. My head hurts, but I am dealing with it.
Registered user since 1996

Re: ChordPlay.nw

Reply #7
Updated to include an integrated user tool, ChordPlay.nw: Convert Text Chords (new tool requires 2.75a Beta 2 or later)

Re: ChordPlay.nw

Reply #8
Updated as follows:

  • When not using Lawrie Pardy's chord fonts, '#' and 'b' are automatically mapped to true flat and sharp characters for display purposes.
  • When using one of Lawrie Pardy's Germanic chord fonts, B and Bb are automatically remapped to H and B for display purposes.

Re: ChordPlay.nw

Reply #9
Updated to protect from a song position out of range error when playing or exporting to a MIDI file.

Re: ChordPlay.nw

Reply #10
My daughter can read the chords written "the english way" but many of her friends don't.
It's a pity this tool doesn't manage "the italian way" too (I mean: Do, Re, Mi, Fa, Sol, La, Si).

Today I learned, courtesy of Mike, that these objects transpose automatically.
Very good, but I found no reference of it in the instructions.

Re: ChordPlay.nw

Reply #11
I'm trying to convert myself to use this plugin for convenience.
I inserted some chords, but I discovered that the chord names are by far too small.
I fought with the plugin until I discovered that I have to select it, click it with the right mouse button to access a submenu that can let me choose what to do, then, maybe, actually doing it... Bah!
To quote Rich: it is a leap backward.

Anyway, I went to modify the text size and I discovered it already is (so it says) 32 points! N.B. my staff is 18 points!
Looking at the source code I see:
Code: [Select · Download]
{id='Size',label='Font Size',type='float',default=nil,min=0.1,max=50,step=0.1},
Max 50? False. (Luckily) I can even use 100 or more... just to reach the same size of a 18 point text.
There's something wrong with the metric...

I think I should try to adjust it to my needs.

Re: ChordPlay.nw

Reply #12
Code: [Select · Download]
{id='Size',label='Font Size',type='float',default=nil,min=0.1,max=50,step=0.1},
Max 50? False. (Luckily) I can even use 100 or more... just to reach the same size of a 18 point text.
There's something wrong with the metric...

I think I should try to adjust it to my needs.

Not clear on your point. The size 50 max is clearly a thing. These two clips give the same result:

Code: (nwc) [Select · Download]
!NoteWorthyComposerClip(2.751,Single)
|Clef|Type:Treble
|Rest|Dur:Whole
|Bar
|User|ChordPlay.nw|Pos:-8.5|Name:B|Span:5|Font:MusikChordSerif|Style:b|Size:50|Strum:Up
|Note|Dur:4th|Pos:0
|Note|Dur:4th|Pos:0
|Note|Dur:4th|Pos:0
|Note|Dur:4th|Pos:0
|Bar
|Note|Dur:Whole|Pos:0
!NoteWorthyComposerClip-End
Code: (nwc) [Select · Download]
!NoteWorthyComposerClip(2.751,Single)
|Clef|Type:Treble
|Rest|Dur:Whole
|Bar
|User|ChordPlay.nw|Pos:-8.5|Name:B|Span:5|Font:MusikChordSerif|Style:b|Size:150|Strum:Up
|Note|Dur:4th|Pos:0
|Note|Dur:4th|Pos:0
|Note|Dur:4th|Pos:0
|Note|Dur:4th|Pos:0
|Bar
|Note|Dur:Whole|Pos:0
!NoteWorthyComposerClip-End

Re: ChordPlay.nw

Reply #13
Not clear on your point. The size 50 max is clearly a thing. These two clips give the same result:
(snip)
Perhaps he was confused by the fact that the point size in the font chooser dialog is 4x the value that is returned to the program. So a 50 point font in the object properties corresponds to a 200 point font in the dialog.

Re: ChordPlay.nw

Reply #14
The limit is artificial. It can be increased with a proper justification.

Re: ChordPlay.nw

Reply #15
the point size in the font chooser dialog is 4x the value that is returned to the program
Right that!
I just didn't investigate what is tha ratio and why.
Quote
There's something wrong with the metric...

Re: ChordPlay.nw

Reply #16
I just discovered that if someone is missing the MusikChordSerif font the plugin crashes.
The bug is in line 192:
Quote
defaultChordFontFace = Arial
Arial is nil, so later the process is aborted.
The correct line should be:
Quote
defaultChordFontFace = "Arial"
in which Arial is the (quoted) typeface name.

N.B. I'm working on changing this object to show and print the chords "the italian way" too (I mean: Do, Re, Mi, Fa, Sol, La, Si).
It's almost ready and I will publish it here, but my feelings, from other tools and plugins, is that not many out there are interested in this option.

Re: ChordPlay.nw

Reply #17
N.B. What a mess in the font metrics!

Re: ChordPlay.nw

Reply #18
I just discovered that if someone is missing the MusikChordSerif font the plugin crashes.
Fortunately, NWC 2.75 and later include the font as part of the installation, so the only way it should be missing is if someone intentionally removed it.

Re: ChordPlay.nw

Reply #19
Just in case someone (else) cares about this feature, this new version of the object can show and print the chords "the italian way" (I mean: Do, Re, Mi, Fa, Sol, La, Si).
It only shows and prints the chords that way. While editing, the chords are still written as A..G.
The choice is in a new parameter, "Italian style chords", that can be "Default", "Yes" or "No".
I think "Yes" and "No" are self explaining.  :D
If it's "Default" then it "inherites" the status from the nearest preceeding ChordPlay.nw that has "Yes" or "No". If none is found then "No" is assumed, so it's perfectly compatible with the official version (1.6). This is the reason why I didn't change the "developer ID".

Re: ChordPlay.nw

Reply #20
Just in case someone (else) cares about this feature, this new version of the object can show and print the chords "the italian way" (I mean: Do, Re, Mi, Fa, Sol, La, Si).

I would have called it "the belgian way" ;)
Always look on the bright side of life!

Re: ChordPlay.nw

Reply #21
Well, what's important is to understand.  :)
Let me know if you find something wrong. I'm not an expert of Lua.

Re: ChordPlay.nw

Reply #22
Since it appears there are more than one country that use this style of chord, perhaps a better name would be "solfeggio chords".  And then perhaps another sub-option for Si vs. Ti as the 7th note?


Re: ChordPlay.nw

Reply #24
I always wondered where "Ti" comes from.
For a long time I was sure I misheard it!  :D  Then, somewhere, I read it...

Also the "solfeggio" name for what are, for us Italians, the standard notes was a bit of surprise to me.
It shouldn't. How can someone sing ("solfeggiare") "C" or "G"?  :))

UT queant laxis
REsonare fibris
...
LAbii reatum
Sancte Ioannes

The seventh note is called "Si" from "Sancte Ioannes"
Ut was replaced with Do at least since 1536 in a text by Pietro Aretino and comes from "Dominus".


Re: ChordPlay.nw

Reply #26
I don't know what I'm doing wrong, but Chordplay does not give me any font options.  Everything says "right-click" and they'll be there, but they just aren't.

Thanks if anyone can point me in the right direction.

Don H.

Re: ChordPlay.nw

Reply #27
It's a bit obscure, but if you highlight the object, then right click you get a context menu where you can select the Object (Chordplay...) option, where there is a font option.
Also, instead of highlighting the object, just right click it and it will take you straight to the submenu where the font option exists.

I plays 'Bones, crumpets, coronets, floosgals, youfonymums 'n tubies.

Re: ChordPlay.nw

Reply #28
Thanks, that was it.  I'm very grateful for the help.

Don H.


Re: ChordPlay.nw

Reply #30
After some discussion with Flurmy and some testing for myself I've updated my copy of Flurmy's version (1.7) of this user object to what I'm calling V1.7a.

What it adds is some more common characters used in my *Chord fonts as included with the Pardy font suite (SwingDings et al)

The additional glyphs/characters and their meanings are:
%, H, <%, m%, >%, min%, <, <7, <9, >, >7, >9, W, W2, X, Z, I, J, K, L
where:
%=6/9, H=Maj6/9, <%=Maj6/9 >%=min6/9, <=Maj, >=min, W=sus, X=sus4, Z=7sus, I=Maj6, J=Maj7, K=Maj9, L=Maj13
N.B.    H, I, J, K and L are using a small triangle for the Maj symbol rather than the text "Maj"

To use it you need to locate your current ChordPlay.nw.nwcuser.lua file (<Ctrl+J> dialogue, click "Source Folder"), preserve the current ChordPlay.nw.nwcuser.lua file and copy the one in this zip file to the same location.<edit> Don't do this - see below
Please Note:  If you do an online update for your objects NWC will offer to update this file back to V1.6 which is the current release version from Noteworthy.

USE AT YOUR OWN RISK - NO warranties apply.  Eric, if you see this post and the content breaches any conditions please remove it, or advise me and I'll remove it.

<edit> Attachment removed - see replies #32 and #38 below for new version and additional notes.
I plays 'Bones, crumpets, coronets, floosgals, youfonymums 'n tubies.

Re: ChordPlay.nw

Reply #31
Rather than replace the ChordPlay.nw file, I would suggest changing the name of the new file to something like ChordPlay.lp.nwcuser.lua.  This was the reason that the ID field was included in the plugin filename, so that people could create different flavors of objects. But to do this properly, you would need to request the "lp" ID (or a different one if you don't want to use your initials).

Re: ChordPlay.nw

Reply #32
Rather than replace the ChordPlay.nw file, I would suggest changing the name of the new file to something like ChordPlay.lp.nwcuser.lua.  This was the reason that the ID field was included in the plugin filename, so that people could create different flavors of objects. But to do this properly, you would need to request the "lp" ID (or a different one if you don't want to use your initials).
Hi Mike
That's a very fair call, I've only hesitated because:
a) at best I might be able to manage the odd very simple modification, because,
b) I am definitely NOT a programmer and thus would not be productive, and
c) I have no idea how to request one any way...

Also, would this break the automatically created usertool that automates conversion?

<wait a few>

Ok, I've copied my installation back to the original ChordPlay.nw, named my  version ChordPlay.lp.  It verks!!!  But...
Internally I made sure references to ChordPlay.nw were changed to ChordPlay.lp  and I changed the default font to SwingChord, font size to 16 and style to r (for regular)

I confirmed that the object embedded user tool for text conversion does not seem to work.  Not in my modified version nor in NWC's version so this is not an error on my part.  This tool appears in the ".plugins" section of the user tool dialogue

There is also a user tool created in the ".automatic" area of the user tool dialogue which is stored as a lua file in the
"C:\Program Files (x86)\Noteworthy Software\NoteWorthy Composer 2\AutoUserTools"
section of the filesystem. 
Presumably this is created during the user tool starter kit installation.
I duplicated that .automatic tool by copying the file ("Convert Text to ChordPlay.nw.lua") and renaming the copy to "Convert Text to ChordPlay.lp.lua".
Then edited the bits in the renamed copy that made sense to me in order to use ChordPlay.lp and to position the object at the same visual height as the original text object.  This position parameter entry is relative to font size and may not suit all.  Original entries were made into comments so the changes would be obvious.

So herewith my version of ChordPlay.  Now called V1.7b

I have deleted the one in my previous post so this is the one you're all stuck with ;)

<edited>
USE AT YOUR OWN RISK - NO warranties apply. ;)

<edit> Attachment removed - see reply #38 below for new version and additional notes.
I plays 'Bones, crumpets, coronets, floosgals, youfonymums 'n tubies.

Re: ChordPlay.nw

Reply #33
Goody, goody, I've got a new toy  :D  :D  :D

It would be helpful if the internal user tool worked, but guess what!  I've got a new toy  :D

Thanks @Flurmy for helping me get off my butt!  One of the primary reasons I wasn't using ChordPlay was that it didn't recognise the *Chord font glyphs I most commonly used - now, thanks to some unconscious guidance from you, it does.  The other main reason for not using it was the (perceived) tediousness of entering ChordPlay objects manually - I'm pretty quick with text chords, BUT the discovery of the user tool to automate conversion from text to ChordPlay objects was a real winner!

Thanks @Mike Shawaluk for your suggestion which got me further off my butt  8)

And guess what!  I've got a new toy :D
I plays 'Bones, crumpets, coronets, floosgals, youfonymums 'n tubies.

Re: ChordPlay.nw

Reply #34
I confirmed that the object embedded user tool for text conversion does not seem to work.  Not in my modified version nor in NWC's version so this is not an error on my part.  This tool appears in the ".plugins" section of the user tool dialogue

There is also a user tool created in the ".automatic" area of the user tool dialogue which is stored as a lua file in the
"C:\Program Files (x86)\Noteworthy Software\NoteWorthy Composer 2\AutoUserTools"
section of the filesystem. 
I'm very puzzled.
I have only one entry in the user tools. It's called "Convert text to ChordPlay.nw" and is in the ".automatic" area.
But I must say that more than once I cleaned up the list.

The tool is in ChordPlay.nw (or newer  ;) ) in the short routine starting with "if nwcut then".
And, believe it or not, it worked for me a lot of times!

After a brief start putting  chords in the lyrics I switched to put the chords in text items.
Then ChordPlay arrived, so I converted many old scores (not yet all of them) to ChordPlay via that tool.
My only problem was the limited range of supported chord types...  :))

Re: ChordPlay.nw

Reply #35
I'm very puzzled.
I have only one entry in the user tools. It's called "Convert text to ChordPlay.nw" and is in the ".automatic" area.
But I must say that more than once I cleaned up the list.
<snip>
OK, the one in the ".automatic" area is definitely a separate piece of code and works just fine - my edited version is posted above.

<snip>
The tool is in ChordPlay.nw (or newer  ;) ) in the short routine starting with "if nwcut then".
And, believe it or not, it worked for me a lot of times!
<snip>
I believe this is the one that appears in the ".plugins" area and it doesn't seem to work correctly.  At least it never found any text chords to convert when I tested.  It always came back with a "change 0 objects" in the STDERR warning dialogue.
If you've done a few clean ups, perhaps you removed the ".plugins" group?

<snip>
After a brief start putting  chords in the lyrics I switched to put the chords in text items.
Then ChordPlay arrived, so I converted many old scores (not yet all of them) to ChordPlay via that tool.
My only problem was the limited range of supported chord types...  :))
Yeah, the limited range was what was mainly stopping me.
I seem to recall trying to use Lyrics for chords and not being very impressed... ;)
I plays 'Bones, crumpets, coronets, floosgals, youfonymums 'n tubies.

Re: ChordPlay.nw

Reply #36
Quote
OK, the one in the ".automatic" area is definitely a separate piece of code and works just fine
No, I haven't any "separate piece of code" and, as I wrote, the (one and only) "Convert text to ChordPlay.nw" tool appears in the ".automatic" area.
And, no, I didn't remove the ".plugins" group. I have it and well populated too.
But now I'm too sleepy to investigate more. Bed time here.
Maybe tomorrow.

Re: ChordPlay.nw

Reply #37
No, I haven't any "separate piece of code" and, as I wrote, the (one and only) "Convert text to ChordPlay.nw" tool appears in the ".automatic" area.
And, no, I didn't remove the ".plugins" group. I have it and well populated too.
But now I'm too sleepy to investigate more. Bed time here.
Maybe tomorrow.
Sleep well.

I'm very curious as to why we should be seeing such different things.

Please, when you have time, this is what I see in my system:
Navigate to
"C:\Program Files (x86)\Noteworthy Software\NoteWorthy Composer 2\AutoUserTools"
and look for a file called "Convert Text to ChordPlay.nw.lua"
If you move this file elsewhere (or maybe rename the extension) so NWC can't see it does the tool disappear from the ".automatic" group of the user tool dialogue? 
(hint: I've found I cannot have NWC open and do any manipulation of objects or user tool files - makes sense as I think they're loaded at start up)

The internal tool that should appear in ".plugins" shows as:
"ChordPlay.nw: Convert Text Chords"
as opposed to:
"Convert Text to ChordPlay.nw"
which is how the one in ".automatic" appears.

I'm really interested in seeing what differences we're experiencing.
I plays 'Bones, crumpets, coronets, floosgals, youfonymums 'n tubies.

Re: ChordPlay.nw

Reply #38
I think I've found the problem in the object code that stopped the internal user tool from working.

Updated versions attached below.

The following code snippet is from my test copy of ChordPlay.lp.nwcuser.lua:
Code: [Select · Download]
--        if o:Is('Text') and string.match(o:Get('Text','Text') or '','^%s*[A-G][b#]?[^/%s]*%s*/*%s*[^%s]*%s*$') then
        if o:Is('Text') and string.match(o:Get('Text') or '','^%s*[A-G][b#]?[^/%s]*%s*/*%s*[^%s]*%s*$') then
            local o2 = nwcItem.new('|User|'..userObjTypeName)
            o2.Opts.Name = o.Opts.Text
--            o2.Opts.Pos = o:Provide('Pos',0) - 1
            o2.Opts.Pos = o:Provide('Pos',0) - 5
You'll note I've left the original lines in place as comments.
<edit> 2022/02/25
I've just learned that the difference noted above:
Get('Text','Text') vs Get('Text') is specific the the NWC 2.8 beta I'm using.
If you have downloaded my version below and have NWC 2.75 and if the embedded tool (which appears in the .Plugins group) doesn't work then edit the file to remove the comment "--" on the line containing Get('Text','Text') and put it into the line that contains Get('Text') instead.  I believe this should resolve it.  Thanks to Mike Shawaluk for confirming this difference in the NWC 2.8 beta lua API.


This code snippet is from "Convert Text to ChordPlay.lp.lua:
Code: [Select · Download]
	if item:Is('Text') then
local textProp = item:Get('Text') or '--'
if textProp:match('^%"*%s*[A-G][b#]?[^/%s]*%s*/*%s*[^%s]*%s*%"*$') then
local newItem = nwcItem.new('|User|ChordPlay.lp')
-- local newPos = (tonumber(item:Get('Pos')) or 0) - 1
local newPos = (tonumber(item:Get('Pos')) or 0) - 5
If you compare the original:
--        if o:Is('Text') and string.match(o:Get('Text','Text') or '','^%s*[A-G][b#]?[^/%s]*%s*/*%s*[^%s]*%s*$') then

with the apparently equivalent section from the .automatic (working) tool:
      local textProp = item:Get('Text') or '--'
      if textProp:match('^%"*%s*[A-G][b#]?[^/%s]*%s*/*%s*[^%s]*%s*%"*$') then

you will notice the Get('Text' sections are different.
I have absolutely zero idea of how these actually work (not a programmer remember) but it seemed to me the "extra" ,'Text' in the original was the primary point of difference so as you can see from my sample above I removed that bit from my test copy and it appears to now work correctly.

To explain some of my thinking, when I saw the Get('Text','Text') construct it reminded me of the Global_Mod syntax for identifying a text object (the first 'Text') with a comma delineator and specified text (the second 'Text') and that seemed spurious.  Especially as any specific text needed would come from the
'^%s*[A-G][b#]?[^/%s]*%s*/*%s*[^%s]*%s*$') section which I think is a regular expression (of which I have no understanding due to a severe lack of familiarity.  I.E. I never learned them ;) )

I would appreciate some guidance from someone who knows what all this crap actually means and why my change seems to have worked ;)
And maybe why it's a bad idea and recommend a different change...

Oh yeah, this change:

--            o2.Opts.Pos = o:Provide('Pos',0) - 1
            o2.Opts.Pos = o:Provide('Pos',0) - 5

Repositions the object so the text appears at the same vertical location as the original text object - will only work properly at 16pt which is my default size for text chords.  *Chord text chords are top anchored (an error on my part when I first created them - I still have no idea how it happened, but it's wa-ay too late to change it now) and the displayed text  of ChordPlay objects is bottom anchored.  Thus the anchor point must move if the visible text is to remain in the same relative position.
The original ChordPlay.nw object lowered the anchor by 1 Pos (I imagine for normal text like Arial or Times New Roman which are also bottom anchored - at least I think that's the case), but for *Chord sourced ones at 16pt it needs to come down by 5 Pos distances.  I haven't tested, but I'm pretty sure if the objects were sized at, say, 12 point, the change would need to be 4.
Had I not made the error with *Chord fonts this change would not be necessary.

<edit>

UPDATE - attachments added.  Removed from reply #32

ChordPlay.lp.nwcuser.lua - New version 1.7c attached (V1.7b removed from reply#32 above).  This one has a working embedded user tool, as discussed above, that should appear in the .plugins group in the User Tool dialogue.  Defaults to SwingChord at 16pt, regular style
Unzip and copy to:
C:\ProgramData\Noteworthy Software\nwc2\UserPlugins

Also
"Convert Text to ChordPlay.lp.lua.zip" moved to here - no changes.
Unzip and copy to:
C:\Program Files (x86)\Noteworthy Software\NoteWorthy Composer 2\AutoUserTools
so that it mirrors the original installation of "Convert Text to ChordPlay.nw.lua"
You may choose to locate it elsewhere but I suspect that may generate some confusion.

Both user tools will position the object so the textual portion appears where the text object was, provided it was sized at 16pt.

USE AT YOUR OWN RISK - NO warranties apply. ;)

I plays 'Bones, crumpets, coronets, floosgals, youfonymums 'n tubies.

Re: ChordPlay.nw

Reply #39
I was about to post the same observation that you made, re: changing o:Get('Text','Text') to o:Get('Text'). Something must have changed in the user tools API that caused a change in behavior of the Get() function.  This question would be best answered by @NoteWorthy Online , if he sees these messages.

Re: ChordPlay.nw

Reply #40
I was about to post the same observation that you made, re: changing o:Get('Text','Text') to o:Get('Text'). Something must have changed in the user tools API that caused a change in behavior of the Get() function.  This question would be best answered by @NoteWorthy Online , if he sees these messages.
Cool.  Good to know I seem to be on the right track
I've attached my updated version in reply #38 above, as well as moving my edited version of Noteworthy's conversion tool that appears in .automatic to the same reply so they're together.

<edit> One thing has just come to mind.  I'm using the 2.8 beta, not 2.75a - could this explain the putative API change?
I plays 'Bones, crumpets, coronets, floosgals, youfonymums 'n tubies.

Re: ChordPlay.nw

Reply #41
Lawrie,
now that I'm a bit more awake I beg your pardon. Things are exactly as you described.
I completely forgot the AutoUserTools directory with its files, including Convert Text to ChordPlay.nw.lua.
Ad I always used it thinking it was .plugins->ChrodPlay.nw: Convert Text Chords.
Thank you for making things straight.

Re: ChordPlay.nw

Reply #42
Looking in my files, I discovered this (that obviously I read and immediately forgot long ago):
Quote
Allows custom key sequences, which allows it to be used to retime grace notes:
Code: (nwc) [Select · Download]
!NoteWorthyComposerClip(2.74974,Single)
|Clef|Type:Treble
|RestChord|Dur:8th|Opts:Stem=Down,HideRest|Dur2:4th|Pos2:-2
|User|ChordPlay.nw|Pos:6|Name:C|Span:3|Keys:0|Octave:5|Visibility:Never
|Rest|Dur:16th|Opts:Stem=Down|Visibility:Never
|User|ChordPlay.nw|Pos:8|Name:E|Span:2|Keys:0|Octave:5|Visibility:Never
|Rest|Dur:16th|Opts:Stem=Down|Visibility:Never
|Note|Dur:16th,Grace|Pos:-6^|Opts:Stem=Up,Beam=First,Muted
|Note|Dur:16th,Grace|Pos:-4^|Opts:Stem=Up,Beam=End,Muted
|Chord|Dur:4th|Pos:-6,-4,-2
|Note|Dur:4th|Pos:-2
|Note|Dur:4th|Pos:-2
!NoteWorthyComposerClip-End
Not the simplest to use, but good to know!

Re: ChordPlay.nw

Reply #43
Looking in my files, I discovered this (that obviously I read and immediately forgot long ago):
<snip>
Not the simplest to use, but good to know!
Ah yes, I recently saw this under RickG's name.  His legacy is huge.  I don't think anyone else has reached his level of control over NWC.
I plays 'Bones, crumpets, coronets, floosgals, youfonymums 'n tubies.

Re: ChordPlay.nw

Reply #44
Lawrie,
meditating about the topic (I'm slow...), I see that with your changes to the defaults you broke the backward compatibility, hence it's far better to avoid using the same name for the tool. And this is a strong argument in favor of Mike's suggestion.,

Then I'm wondering why you want to switch using the ChordPlay plugin.
I'm using it because it automatically translates the chords written in plain letters to *Chords fonts, but it looks like your "text" entries are already in *Chords fonts.
Then I use it because (now), in case of need, I can easily switch between "Solfeggio" or not. But I think this is not of your interest.
Then I use it because it automatically transposes the chords at once with the notes. Do you care about it?
Then I never used it for that, but you can also make it actually play the chords. Do you?
... But then, of course, you're asolutely free to do whatever you prefer! :D

N.B. Possibly, since your text entries are already in *Chords fonts, a simple change of object type (via GlobalMod or perhaps Change object type) from text to chordplay could have fit the bill.

Re: ChordPlay.nw

Reply #45
Hi Flurmy,
If you check my reply #32 I ended up implementing Mike's suggestion a couple of days ago (actually the same day I started fiddling), and the file attachments (now on reply #38) have the name change so they no longer need to replace the .nw versions.  To be honest, I originally only did that to:
a) follow your lead ;) and
b) so I could use the default change chord .automatic tool from .nw (which I did modify but would still have worked correctly aside from the Pos change)

When I updated the ID to "lp" only 1, or was it 2, people had downloaded the wrongly named versions.  I don't know who of course, but I'd guess perhaps Mike and/or yourself.  You both are well able to fix the problems that might otherwise have been created.

Of course I can't officially use the "lp" ID as I don't know how to successfully request registration, or whatever it is, but I figure that "lp" is what I'd end up with.

Hence the newer versions all refer to ChordPlay.lp, not ChordPlay.nw - in both the object and the separate user tool (which also has the .lp ID).

The primary reason I'm actively changing over is the inbuilt transposition facility.  While I can transpose text chords with the Transpose_Text_Chords user tool from Andrew Purdam, by using ChordPlay I have one less step to worry about.

This is useful as I regularly need to transpose for C, Bb, Eb, and the occasional F, instruments. 
When I write an arrangement or compose a piece I usually do everything in concert pitch, then transpose as required once it's all finished.  It is far, far easier to see chordal relationships if everything is in concert when writing.  And much faster (for me) to enter chords as text and then use the user tool to convert to ChordPlay objects.

Additionally. the playback feature has already significantly enhanced the sound of my test file.  I expect this will be reflected in other files as I extend my usage. 
It would be nice if, when the conversion tool is changing a text chord to a ChordPlay object, it could (perhaps optionally) automatically take into account the number of notes/chords on a staff until the next occurrence of a text chord to be converted and instruct ChordPlay to span that number of notes.  This might not be a perfect solution, but it would reduce labour a lot if one wanted to implement the playback feature.

I think using Global_Mod to change from text object to user object would not be very successful, if it's even possible at all.  I haven't investigated that.
ChangeOjectType does not recognise a text entry as an object.  The code specifically confirms that the object type is "user".
I plays 'Bones, crumpets, coronets, floosgals, youfonymums 'n tubies.

Re: ChordPlay.nw

Reply #46
Lawrie,
I'm not blaming you of anything. I saw you changed the name.
I simply discovered that in this case it must be done for a sound reason.
N.B. Remember that I haven't an ID either.  :D

The primary reason I'm actively changing over is the inbuilt transposition facility.  While I can transpose text chords with the Transpose_Text_Chords user tool from Andrew Purdam, by using ChordPlay I have one less step to worry about.
A-ha. So do I, as I wrote.

When I write an arrangement or compose a piece I usually do everything in concert pitch, then transpose as required once it's all finished.  It is far, far easier to see chordal relationships if everything is in concert when writing.
Absolutely agreed!

It would be nice if, when the conversion tool is changing a text chord to a ChordPlay object, it could (perhaps optionally) automatically take into account the number of notes/chords on a staff until the next occurrence of a text chord to be converted and instruct ChordPlay to span that number of notes.  This might not be a perfect solution, but it would reduce labour a lot if one wanted to implement the playback feature.
As I wrote, I didn't use this feature, but your suggestion looks meaningful.

I think using Global_Mod to change from text object to user object would not be very successful, if it's even possible at all.  I haven't investigated that.
ChangeOjectType does not recognise a text entry as an object.  The code specifically confirms that the object type is "user".
Which means that I'm wrong. Sorry.

 

Re: ChordPlay.nw

Reply #47
<edit> One thing has just come to mind.  I'm using the 2.8 beta, not 2.75a - could this explain the putative API change?
This is a somewhat tardy reply, but I have just confirmed that the
Code: (lua) [Select · Download]
o:Get('Text','Text')
vs.
Code: (lua) [Select · Download]
o:Get('Text')
issue is specific to the 2.8 beta.

Re: ChordPlay.nw

Reply #48
This is a somewhat tardy reply, but I have just confirmed that the
Code: (lua) [Select · Download]
o:Get('Text','Text')
vs.
Code: (lua) [Select · Download]
o:Get('Text')
issue is specific to the 2.8 beta.

Thanks Mike, my reply #38 edited to reflect this.
I plays 'Bones, crumpets, coronets, floosgals, youfonymums 'n tubies.

Re: ChordPlay.nw

Reply #49
Quote
WSH can run scripts written in VBScript and Jscript (java).
I'm ignorant, so I'm sorry for being picky, but my friends always told me javascript has almost nothing to do with java.