Skip to main content
Topic: ABC to NWCTXT conversion (Read 23534 times) previous topic - next topic

ABC to NWCTXT conversion

Last week I was too much in a hurry to get my conversion web page out the door, but I think it is ready for testing now. Click abcnwc.htm to check it out.  It doesn't do more than one staff at a time, instant layering, macros, or anything delimited by + signs.  Please refresh it before using it on another file.  Also, only one tune/song at a time, don't have more than one X: record.  It can only work with what you have pasted into the first field or changed before hitting "Click".

If you have a problem checking it out, please email or PM me with the details and I'll see what I can do to fix it.

RickG's script was invaluable for me while testing it out (Many thanks!), the details are topic=7088.0.

Merry Christmas!
Since 1998

Re: ABC to NWCTXT conversion

Reply #1
What is ABC in this context, please?

Re: ABC to NWCTXT conversion

Reply #2
Perhaps this link will help, Phil:
http://abc.sourceforge.net/
I plays 'Bones, crumpets, coronets, floosgals, youfonymums 'n tubies.


Re: ABC to NWCTXT conversion

Reply #4
When reporting a problem, please give me the last modified date on the very bottom.  TIA
Since 1998

Re: ABC to NWCTXT conversion

Reply #5
Last modified: 12/09/2010 21:05:33
|SongInfo is not working. Each line must begin with "|" or it is ignored. You are outputting:
Quote
|SongInfo|Title:"Od's Zounds Make Room For Cuckolds. ASH.16
"|Author:""|Lyricist:"Derbyshire
"|Copyright1:""|Copyright2:""|Comments:"S:Harrison & Wall MS,Ashover,Derbyshire,1762-75
\r\nR:.Jig
\r\nO:England
\r\nZ:vmp.Chris Partington., 2003.
"
When all you need is:
Quote
|SongInfo|Title:"Od's Zounds Make Room For Cuckolds. ASH.16"|Lyricist:"Derbyshire"
|SongInfo|Comments:"S:Harrison & Wall MS,Ashover,Derbyshire,1762-75\r\nR:.Jig\r\nO:England\r\nZ:vmp.Chris Partington., 2003."
You need not output |Font, |PgMargins, |StaffProperties, etc. unless you a changing NWC's defaults and the you usually only need to specifiy the fields that differ from NWC's defaults.
Registered user since 1996

Re: ABC to NWCTXT conversion

Reply #6
Thanks for looking at it.

There are a number of header records possible (or required) in abc to dictate tempo, key, or time signature while others don't really have a place in an NWC file.  The ones I don't see a place for I just append to comments.  When you click on file info do the R:, O:, and Z: lines appear?  If not I'll dig a little further.  There may not be the space for the really long lines so it may appear to wrap.

Thanks for the tip on eliminating the NWC default lines.

What I got when I tested it was a very long line for SongInfo, but I don't have a way to test on other PC systems.  I'll check into breaking it down into separate lines soon, along with removing some boilerplate info (all but user font 1 for boxmark2 perhaps?).

Quote
|SongInfo|Title:"Od's Zounds Make Room For Cuckolds. ASH.16
"|Author:""|Lyricist:"Derbyshire"|Copyright1:""|Copyright2:""|Comments:"S:Harrison & Wall MS,Ashover,Derbyshire,1762-75\r\nR:.Jig\r\nO:England\r\nZ:vmp.Chris Partington., 2003."
Since 1998

Re: ABC to NWCTXT conversion

Reply #7
What I got when I tested it was a very long line for SongInfo
I didn't. IE8 broke the lines up. Perhaps you need to tell IE8 to use a horizontal scrollbar :-)
Registered user since 1996

Re: ABC to NWCTXT conversion

Reply #8
Confirmed. I had been testing it w/ FireFox, but got the same thing when I went to IE8.  I'll post again after I've had a chance to look into it and fix it along with some other problems  (key and meter appearing prematurely on some tunes, numbered endings).
Since 1998

Re: ABC to NWCTXT conversion

Reply #9
[red]Edit: Sorry - I see now that Rick embedded this knowledge in his example![/red]

If it helps you any, your program can emit multiple SongInfo lines, and NWC will "merge" their values (it's kind of a standard already to break the StaffProperties into two lines, when they could be only one line, or more than two lines).  For example:

Quote
|SongInfo|Title:"..."
|SongInfo|Author:"..."
|SongInfo|Lyricist:"..."
|SongInfo|Copyright1:"..."
|SongInfo|Copyright2:"..."
|SongInfo|Comments:"..."

This doesn't help break up a long comment, but it at least gives you an entire line for the comment.

P.S.  Or you can minimize your code changes with a hybrid, only breaking out the comment:

Quote
|SongInfo|Title:"..."|Author:"..."|Lyricist:"..."|Copyright1:"..."|Copyright2:"..."
|SongInfo|Comments:"..."

Re: ABC to NWCTXT conversion

Reply #10
I've added a wrap attribute to both textareas and instead of checking for just \n I am checking for \n and/or \r in any combination.  In the source it is in lines 409-415.  It now runs in IE.

In the early days of PC's and printers, some systems required both a line feed (\n) and a carriage return (\r), others had one or the other.  If the system allowed overprinting, \r by itself put the carriage where it needed to be, but both would be required to get to the first character in a new line.

I haven't made any other changes in the boilerPlate text yet, but this should work now.
Since 1998

Re: ABC to NWCTXT conversion

Reply #11
Confirmed.

If I copy ABC data into the top window and click "Click", NwcTxt appears in the lower window. But if I then modify the ABC data into the top window and click "Click", invalid data appears in the lower window.

To get around this, I had to copy the ABC data into the clipboard, refresh the page, and then paste the ABC data back in. Not very user friendly :-(
Registered user since 1996

Re: ABC to NWCTXT conversion

Reply #12
To get around this, I had to copy the ABC data into the clipboard, refresh the page, and then paste the ABC data back in. Not very user friendly :-(
I've added some code to (re)initialize the global variables and zero some table lengths.  In a few tests I could rerun it w/o refreshing it.  Should be a little friendlier now.

I've also removed some boiler plate.

A source of test data: abc.sourceforge.net/NMD/nmd/ashover.txt.

*****************************************
P.S  Have cleaned up some code for "variations" of numbered endings.  If there is a bar line with nothing between it and a MasterRepeat, it takes it out now.  If there is an ordinary bar line at the end of the piece, it gets taken out so the NWC default of "Section Close" will be applied.
Since 1998

Re: ABC to NWCTXT conversion

Reply #13
In an abcusers forum, I was just asked
Quote
What advantages does NoteWorthy Composer have over the programs we're already using to turn ABC into MIDI's and sheet music?
From the hit counter info, I've seen a number of people have tried it out.

I already have ideas for an answer such as a steep learning curve and collections of nwc files such as scriptorium, but would appreciate further input before answering.  TIA

I may have jumped the gun in posting that before the nwctxt feature is added to the Player.
Since 1998

Re: ABC to NWCTXT conversion

Reply #14
I may have jumped the gun in posting that before the nwctxt feature is added to the Player.

But nwctxt has been added to the player and the preview with that facility is now publicly available.
Rich.

Re: ABC to NWCTXT conversion

Reply #15
If all someone wants to do is turn an ABC file directly into MIDI and/or sheet music, I see no advantage to interposing NWC.  There is only a potential advantage if they want to make changes to the music prior to turning it into MIDI and/or sheet music.  Do you also provide for NWCTXT to ABC conversion, so they could capture any edited changes back into an ABC file?  This would help them be able to update their ABC files, while continuing to use the tools they're used to for generating MIDI and/or sheet music.  Would you be at all interested in letting me work with you to create a user tool to provide easy import/export of ABC into/from NWC?

 

Re: ABC to NWCTXT conversion

Reply #16
But nwctxt has been added to the player and the preview with that facility is now publicly available.
I'm not positive about that.  As I look at the license you have to agree to before installing it, it can only be distributed to a limited audience.  It would be OK to tell everyone in the chorus about some NWC training files and how to get the beta player, but the way I read it I can't just post it on the WWW.

BTW, I know nothing about other notation systems to answer the question from two three posts ago.  If anyone can fill me in, please do so.

If all someone wants to do is turn an ABC file directly into MIDI and/or sheet music, I see no advantage to interposing NWC.  There is only a potential advantage if they want to make changes to the music prior to turning it into MIDI and/or sheet music.  Do you also provide for NWCTXT to ABC conversion, so they could capture any edited changes back into an ABC file?  This would help them be able to update their ABC files, while continuing to use the tools they're used to for generating MIDI and/or sheet music.  Would you be at all interested in letting me work with you to create a user tool to provide easy import/export of ABC into/from NWC?
I am planning to do a conversion back from NWCTXT within a month or two but I need to make two major changes to what I have first.  If the abc had the V: command (voice) to use more than one staff, I would need to add the number of that staff to a new field in my 2-d array with a sequence number then sort it before building one staff at a time.  Also like to allow macros and dynamics in the revision after that.

If you think this is worthwhile, I would welcome any help.  Feel free to view the source when you bring up my page to see what I have thus far.
Since 1998

Re: ABC to NWCTXT conversion

Reply #17
As I look at the license you have to agree to before installing it, it can only be distributed to a limited audience.
I downloaded the 2.1 Viewer from:
http://www.noteworthysoftware.com/nwc2/viewer.htm
and copied the license to 21.txt
I downloaded the 2.5 Viewer from:
https://forum.noteworthycomposer.com/?topic=7439.0
and copied the license to 25.txt

File compare (fc.exe) reports this:
Quote
D:\>fc 21.txt 25.txt
Comparing files 21.txt and 25.txt
FC: no differences encountered

the way I read it I can't just post it on the WWW.
True of nearly all NoteWorthy executabes. Post a link instead.
Registered user since 1996

Re: ABC to NWCTXT conversion

Reply #18
Made a small modification in the page:
  • All internal note values have increased by a factor of 4 (see quintuplet thread).
  • Removed some boiler plate and some commented out code.
  • Allow staccato chords.
  • Cutoff alerts for "I can't identify this code" at 8 and summarize the rest.

This is what the abcusers group looks like now: abcusers.

P.S. Last two items of list, link to group.
Since 1998

Re: ABC to NWCTXT conversion

Reply #19
A major change is the removal of "posTab" from the script, the previous version is now "abcnwco.htm";  the "workTab" is written to directly as a two dimension table rather than the unnecessary first step of creating a 1-d, semicolon delimited table.  NWC requires each staff to be written in its entirety one at a time while in ABC the "voices" are interspersed (headers V:x ).  If voices are found, a working voice number will be the major sort along with a sequence number before the NWCTXT code can be created.  

It can't do separate voices now, but that will be the next step.

One of my favorite resources is sourceforge.net as Lawrie already mentioned.

P.S. There is now a link to the new viewer at the bottom of the page.
Since 1998

Re: ABC to NWCTXT conversion

Reply #20
It was fun working on this, getting it to produce real nwctxt, and corresponding with others with an interest in it.  For the last two+ months I've spent way too much time on this (or just thinking about what I would do next), but now I need to concentrate on things that bring in the green stuff.  I might tweak an error message now and then but not try to incorporate new features such as multiple voices.

Phil Taylor has a set of abc test files and the first one has two "songs" separated by a comment which was not coded as a comment.  In abc, the letters C-B start the octave at middle C, c-b is the octave above that.  A trailing apostrophe sends the note up an octave while a comma sends it down (see the end of the attachment).  Also a z creates a rest while x makes a hidden rest.  If my script doesn't know what to do with what it finds, it inserts it as blue text.

Should be an easy puzzle. Enjoy!

Since 1998

Re: ABC to NWCTXT conversion

Reply #21
This is what went into my previous attachment after conversion:
Code: [Select · Download]
X:1
T:Shave and a haircut
T:Aye tiddly bagpipe
N:Shortest tune I can think of
M:4/4
K:C
c2 GG A2 G2 | z2 .B2 .c2 ||

Here's a bit of uncommented text between the tunes.  Programs
should ideally ignore it.  This is the only example of uncommented
text in this file, so if it causes problems for your program
you can comment it out.

X:2
T:Scale
N:From abc2ps sample file
M:C
K:C
L: 1/4
 "C,"C,"D,"D,"E,"E,"F,"F,  "G,"G,"A,"A,"B,"B,\
| "C"C"D"D"E"E"F"F  "G"G"A"A"B"B| "c"c "d"d"e"e"f"f  "g"g"a"a"b"b"c'"c' |
I just changed it to create more than one staff when the "V:" command is used (Voices).  It is a major change so there may have been a few bugs to creep in.  Enjoy!
Since 1998

Re: ABC to NWCTXT conversion

Reply #22
Have added a facility to catch commands delimited by "!" such as !fermata! and plan to implement a few of them in the near future.  Fewer alerts before I summarize and note lengths not in the table have text inserted in front of them so they can be found easier.
Since 1998

Re: ABC to NWCTXT conversion

Reply #23
Fixed a few bugs: If the last of a beamed note also ends a slur and a space follows, the beam will not continue, e.g. "ab(cd) efga".  Unrecognized data at the end of input will no longer cause an endless loop.  Added lyrics to "Speed the Plough".
Since 1998