Skip to main content
Topic: searching for succession of notes (Read 4436 times) previous topic - next topic

searching for succession of notes

Hello,
Can anyone help, please? Quite often I want to change parts of an nwc score which I've found on the www, where the person has used two dotted semiquavers and a semiquaver to represent a triplet, and I want to change it to a triplet.  Is there a quick way to search for a succession of notes such as this, maybe by using some sort of macro?
Thanks, in advance for any help.

Re: searching for succession of notes

Reply #1
If I were to want to do this, I would save the file as nwctxt, then use a text editor which supports regular expressions to do the find and replace.

Re: searching for succession of notes

Reply #2
Thanks Phil, I'll give it a try.  Never done this before so not quite sure about regular expressions.  Also, if and when I manage to make the changes, do I then save it with the nwc extension?

Re: searching for succession of notes

Reply #3
I haven't tested it, but this User Tool may help:
When NWC imports a MIDI file it does not faithfully represent triplets; correcting them manually is a tedious business so I have written a User Tool to do this.
Registered user since 1996

Re: searching for succession of notes

Reply #4
For what its worth:
In the past I've used the 'tripletise' user tool,
available at:

http://nwc-scriptorium.org/nwc2scripts_trip.html

to correct NWC's import of triplets.
This can be quite tedious, especially if more than one voice is involved.

Nowadays, I would import the midi into
MuseScore (free) and export it as a *.xml (or *.mxl)
and import it into NWC using the Niversoft convertor.

My experience has been that both MuseScore  and
Notation Composer (NOT Free)
import *.midi MUCH better than NWC does.

 

Re: searching for succession of notes

Reply #5
This is a quick tool to fix midi triplets.  First save the file on your computer (remember the location).  Open NWC with the file you want to convert and do Alt/F8.  Choose New and pick a group and a name for it.  Browse for the file you saved.  In the command line insert "wscript " at the beginning of the line (note trailing space after wscript).  Now you can select Run.
Code: [Select · Download]
/* Midi triplet conversion by Warren Porter "MidiTriplets.js"
   After downloading this file, when setting it up in NWC User Tools create this command line:
  
   wscript "'Browse can insert the path for you' \MidiTriplets.js"
  
   This can convert "midi triplets" (16th, dotted; 16th, dotted; 16th) into a set of 8th, triplets
 */
var rc=0, errMsg=""
function calculate(clip) {
  var i, j=0, dsi;
  var lines = new Array(), result = new Array(), mt=0, measureTab = new Array, beatletCount=0, targetMeasure = 768;
  var thisDur, thisNote, durSplit;
  lines = clip.split("\r\n");
  var lineLength3 = lines.length - 3;
  for (i=0; i < lineLength3; i++) {  
    if (/Dur:16th,Dotted/.test(lines[i]) && !/Dur2/.test(lines[i]) && /Dur:16th,Dotted/.test(lines[i+1]) && !/Dur2/.test(lines[i+1]) &&
      !/Dur2/.test(lines[i+2]) && /Dur:16th/.test(lines[i+2]) && !/Dotted/.test(lines[i+2])) {
  lines[i] = lines[i].replace("Dur:16th,Dotted","Dur:8th,Triplet=First");
  lines[i+1]= lines[i+1].replace("Dur:16th,Dotted","Dur:8th,Triplet");
  lines[i+2]=lines[i+2].replace("Dur:16th","Dur:8th,Triplet=End");
  i+=2; }
  }  //End main processing loop  
  return lines;
}

var myLines=calculate(WScript.StdIn.ReadAll()).join("\r\n")
 
if (rc == 0)
  WScript.StdOut.Write(myLines);
else
  WScript.StdErr.Write(errMsg);
WScript.quit(rc);
 
Since 1998

Re: searching for succession of notes

Reply #6
Amazing!  Very many thanks, Warren, it worked a treat!  I must study your macro to try to understand how it works.
Thanks again for your help.

Re: searching for succession of notes

Reply #7
Sorry, thank, too, to Rick and Haymo, I read Warren's solution before I realised that you had also offered one.  Thanks for your help, too, this forum is so useful!

Re: searching for succession of notes

Reply #8
I must study your macro to try to understand how it works.
Thanks again for your help.

You're welcome.  That script was a modification of an existing script framework and has a number of variables that could be safely deleted.  I think the only ones it really needs are i, lines, and lineLength3 within the calculate function.  If it finds a specific pattern of durations on three consecutive notes/rests/chords, it replaces them on clipboard/nwctxt data like this:
Code: (nwc) [Select · Download]
!NoteWorthyComposerClip(2.5,Single)
|Rest|Dur:16th,Dotted
|Note|Dur:16th,Dotted|Pos:-2|Opts:Stem=Up,Beam=First
|Note|Dur:16th|Pos:-1|Opts:Stem=Up,Beam=End
|Note|Dur:16th,Dotted|Pos:0|Opts:Stem=Down,Beam=First
|Note|Dur:16th,Dotted|Pos:2|Opts:Stem=Down,Beam
|Note|Dur:16th|Pos:1|Opts:Stem=Down,Beam=End
|Note|Dur:16th,Dotted|Pos:1|Opts:Stem=Down,Beam=First
|Note|Dur:16th,Dotted|Pos:3|Opts:Stem=Down,Beam
|Note|Dur:16th|Pos:2|Opts:Stem=Down,Beam=End
!NoteWorthyComposerClip-End
Since 1998