Skip to main content
Topic: Quickly (re)generate MIDI files for your entire NWC library (Read 14222 times) previous topic - next topic

Quickly (re)generate MIDI files for your entire NWC library

I'm looking for testing and feedback on a new tool.  It's not a user tool (run from within NWC) - it's a PHP script run from a DOS command line (or from a shortcut).

You give it a starting directory, and it will find all NWC files in that directory, and recursively in all directories under that if you want.  For each NWC file, it will generate (or regenerate) the corresponding MIDI file as desired.

There is an extra layer of functionality I'd like to add options for.  Right now, I've got some support for automatically expanding note/rest durations to account for any fermata delay in the NWC file.  There's more I can do with fermatas, and other things (like breath marks for example, or global instrument changes, or global tempo changes, or whatever one can think of) if someone wants it.

If there's any interest at all, I'll post details on the script's invocation (including setting up handy shortcuts and using all the options provided).  The script is attached now only for proof of existence.  :-)

Apologies in advance to those who expect NWC to natively support anything in this tool - I hope along with you that some or all of this tool will be obsolete someday.

Re: Quickly (re)generate MIDI files for your entire NWC library

Reply #1
If there's any interest at all, I'll post details on the script's invocation (including setting up handy shortcuts and using all the options provided).
You might start by showing us how to generate one MIDI from one sample NWC file. A program that operates recursively on subfolders is not one that I would like to test blindly. Too much chance that I might confuse it into thinking that it should start in the root folder...
Fermatas and breath marks must be accumulated and be reflected in all tracks. They often occur on triplets. In adding beats, a decision about correcting Time Signatures needs to be made. If TimeSigs are not changed, the resulting MIDI will import badly. Correcting TimeSigs is not trivial, especially around triplets.
The script is attached now only for proof of existence.  :-)
I can confirm that it exists. :-)
Registered user since 1996

Re: Quickly (re)generate MIDI files for your entire NWC library

Reply #2
Quote
You might start by showing us how to generate one MIDI from one sample NWC file. A program that operates recursively on subfolders is not one that I would like to test blindly. Too much chance that I might confuse it into thinking that it should start in the root folder...

There are several protections already available - use any one or more of these - however many you want:
  • As I said in my initial post, but not clearly enough, recursion only occurs if you want it to - you have to specify the "-r" flag to get it.  Leave off the "-r" flag, and it will only see NWC files in the directory you run the tool from.  Even with recursion, it will only ever recurse "down" from the working directory, never "up".  You'd have to run it from "C:\" to hit all NWC files, but even then, it won't find other drives.
  • There is a "-t" option available for "test" mode.  If you specify it, the script will tell you what it would have done (without the test option), but it will not actually do anything.  Add the "-v" verbose option (with or without test option) to get even more information.
  • There is a "-n" option available for "no clobber" mode.  If you specify it, the script will never overwrite any pre-existing midi file.  It will only generate new midi files, and not regenerate old ones.
  • There is a "-i" option available for "interactive" mode.  If you specify it, the script will prompt you every time there is a pre-existing midi file, and you can choose whether to overwrite it (regeneration) or leave it alone.
  • There is a "-b" option available for "backup" mode.  If you specify it, the script will always rename any pre-existing midi file to a "*.bak" name before regenerating a new midi file.  If there was a previous backup file, the (current) script will overwrite that with the new backup file!
  • There is a "-u" option available for "update" mode.  If you specify it, the script will generate midi files where none was pre-existing, and it will regenerate midi files where the pre-existing midi file was older than the corresponding nwc file.  It will not touch midi files that appear to be "up to date" already (according to the file modify timestamp).

Above all else, this script will only (re)generate midi files, and will not change nwc/nwctxt files in any way.  And this script will only operate on the current working directory (and downward if recursion).

To answer your question, simply create a new (empty) directory, and copy any test nwc file(s) into it.  Then from a DOS command prompt, run NWC's PHP, specifying the path to the script (which should be placed in the same directory as nwc-conv.exe), for example:
Quote
"C:\Program Files\Noteworthy Software\NoteWorthy Composer 2\PHP\php.exe" "C:\Program Files\Noteworthy Software\NoteWorthy Composer 2\nwc2midi.php" -t -n -i -b -u

One can easily create a shortcut, which contains the above as the target, and the desired root NWC directory (or subdirectory thereof) as the "start in".  Then a double-click (re)generates all the midi files it finds.

Re: Quickly (re)generate MIDI files for your entire NWC library

Reply #3
Quote
Fermatas and breath marks must be accumulated and be reflected in all tracks.

Agreed - I'd already seen this in my testing.  I was hoping that the tool would still be useful as is, since I felt that most people might put "parallel" fermatas in across all staffs (e.g. see the very end of the 1812 sample).  I feel like the only time one shouldn't already have parallel fermatas is on the auxilliary staffs of a layer?  (I guess there's the case of a pianist technically not needing a fermata duplicated from right hand staff to left hand staff.)  I also feel like most folks might not be aware that NWC applies a fermata from one staff across all staffs (ala tempos and MPCs).  Users can add parallel fermatas if they need to and don't mind, or I was already planning on this (and other) enhancements to fermatas, once I had some folks interested in at least discussing the implications.  [For example, note what happens when measure X of one staff has a half note followed by a half note with fermata, and measure X of another staff has a whole rest with fermata.  Musically, I'd treat those as one logical fermata, but NWC treats them as 2!]

Quote
They often occur on triplets.

I'm sure it can happen, but "often"?!  As you may or may not have noticed, my script already considers the possibility, but for now, it does not try to expand fermatas over triplets.  It has a placeholder to add in the future, if there is interest.

Quote
In adding beats, a decision about correcting Time Signatures needs to be made. If TimeSigs are not changed, the resulting MIDI will import badly. Correcting TimeSigs is not trivial, especially around triplets.

Certainly my initial technique for emulating fermatas can be enhanced in the future, if there is interest.  I'm not sure I'll ever be worried about what happens on an import of midi files generated by my script though.  The fermata can never be restored (I believe), so why would I want to encourage trying to regenerate the original nwc file from the exported midi file?!  [And again, as my script already notes, and codes, I am purposely staying away from triplets for now.  :-]

Re: Quickly (re)generate MIDI files for your entire NWC library

Reply #4
I also feel like most folks might not be aware that NWC applies a fermata from one staff across all staffs (ala tempos and MPCs).
I hope that no folks are "aware" of it, since that is not what NWC does. NWC stops processing MIDI events for the period representing the Tempo Variance Command's delay. NWC (and the Viewer) most definitely do not implement Tempo Variances with "tempos and MPCs". I know this because I have spent hours looking at NWC's MIDI output with MIDI OX.

Please do not add to the mistaken impressions of many that "Fermatas and Breath Marks can be simulated with Tempo changes." Some can be simulated that way but many cannot. In any case, it would be a hack. As implemented by NWC, 'Tempo Variance delays' represent an addition of beats, not a decrease in tempo.

(e.g. see the very end of the 1812 sample).
There are no delays associated with the fermatas, so I fail to see this piece as a relevent example.
Registered user since 1996

Re: Quickly (re)generate MIDI files for your entire NWC library

Reply #5
Quote
I hope that no folks are "aware" of it, since that is not what NWC does. NWC stops processing MIDI events for the period representing the Tempo Variance Command's delay. NWC (and the Viewer) most definitely do not implement Tempo Variances with "tempos and MPCs". I know this because I have spent hours looking at NWC's MIDI output with MIDI OX.

Sorry Rick, but I guess I wasn't clear here.  I did not emulate fermatas with tempos or MPCs, and never plan to!  I only mentioned those 2 in the context of NWC applying their respective functionalities (which are totally different from each other) across all staffs, even though they only appear in one staff.  (My "ala" was meant to be "in the manner of", not "using".)  My current script implementation is simply to increase the duration of the note, chord, or rest that follows the fermata (I don't support fermatas over split-chords or rest-chords yet).  Sorry for the confusion.

Quote
Please do not add to the mistaken impressions of many that "Fermatas and Breath Marks can be simulated with Tempo changes." Some can be simulated that way but many cannot. In any case, it would be a hack. As implemented by NWC, 'Tempo Variance delays' represent an addition of beats, not a decrease in tempo.

Agreed.  Did not mean to add to such a mistaken impression, however I did.

Quote
There are no delays associated with the fermatas, so I fail to see this piece as a relevent example.

It was specifically an example of folks being used to entering "parallel" fermatas across all staffs (for the visual of all parts individually seeing the fermata, irrelevant of the pause for playback).  My point was that any fermata in one staff (with whatever pause, if any) was likely to be copied to all other staffs, thus likely avoiding the problem we foresaw of a fermata in one staff failing to automatically propagate to the corresponding spot in another staff (where one was missing).  Again, sorry I led you to believe that I was trying to show specifically a fermata with non-zero pause - that was not my intent.

Re: Quickly (re)generate MIDI files for your entire NWC library

Reply #6
Thanks for the clarification. Sorry for being harsh.
Registered user since 1996

 

Re: Quickly (re)generate MIDI files for your entire NWC library

Reply #7
Quote
note what happens when measure X of one staff has a half note followed by a half note with fermata, and measure X of another staff has a whole rest with fermata.  Musically, I'd treat those as one logical fermata, but NWC treats them as 2!

I stumbled on it many times.
At first I was a little surprised, but the workaround is straightforward.