Skip to main content
Topic: changing notes to rests (Read 4571 times) previous topic - next topic

changing notes to rests

Is there a quick way of changing a note to a rest witout having to delete a note and key a rest in its place?  I ask this because I sometimes have to do a whole batch, either down several staves or across several bars

Re: changing notes to rests

Reply #1
Take the following text and save it on your computer with a name ending in .htm, for example "note2rest.htm".  Open the file with your browser at the same time NWC is open.  When you want to change notes to rests, cut (Cntl/X) the selected part of the NWC file to the clipboard and paste it into the page's textarea.  Click on Read, do a Cntl/C and paste it back into your NWC file.

HTH
Code: [Select · Download]
<html>
<head>
<title>Replace notes with rests</title>
<!-- This is a simple structure to create a "do it yourself" webpage to manipulate NWC clipboard data.  The page takes the data you
     pasted into the textarea and splits it into an array of string data.  It is examined one line at a time and either the original
     text is added back to the OutText area with a newline character "\n" at the end or new text is inserted instead.

     To modify this script do a simple replacement of "Replace notes with rests" with its new function. First note the
     line the "slice" function is on.  Change the literal (enclosed in double quotes) and the second parameter to the length of the
     literal.  It is to be replaced with the literal on the next line.  Change globally the text on the 3rd line to whatever is
     appropriate and save it with a name ending with ".htm" or ".html".  Learn how to display the error console of your browser.

     Misc. "under the hood" facts: "=" changes the variable on the left to the expression on the right while "==" determines if
     two expressions are equal (used in "if" statement).  "+=" appends new expression or string to the end of the existing one.
     Note the zeroth occurance of an array item or character in a string is actually the first one.  "++" adds 1 to a numeric variable.
     If all parts of an expression are numeric, + does addition but with string data it is concatenation such as "Happy " + "Birthday".
     "2" + 3 creates a string with the value "23".

     You can immediately display variables with alert(string data here), e.g., alert("lines[" + i + "]= " + lines[i]);
-->
<script language="JavaScript">
function calculate() {
 
  var i, OutText = "";
  var lines = new Array();
  var result = new Array()
  lines = document.nwcform.OutputField.value.split("\n");
  for (i=0; i < lines.length; i++) {
if ((lines[i].slice(0,5) == "|Note") || (lines[i].slice(0,6) == "|Chord") || (lines[i].slice(0,10) == "|RestChord")){  //In case your browser puts extra characters at the end, slice ignores them.
      result = lines[i].match(/Dur:([^\|]+)\|/)
    if (result == null)
  alert(lines[i] + " crashed");
else
  OutText += "|Rest|Dur:" + result[1] + "\n"; } //Ends with \n.  This examples adds 4 lines.
else
     { OutText += lines[i];
    if ((i+1) < lines.length)    //No need to add a newline character to last line
      OutText += "\n";   }
  }

  document.nwcform.OutputField.value = OutText;  //Replaces original data with what was created in OutText
  document.nwcform.OutputField.select();   //Output is pre-selected, just Cntl/C to put on clipboard
}
</script>
</head>
<body>
<form name="nwcform" onSubmit="calculate();return false;">
  <table width="782" height="350">
    <tr>
      <td colspan="4" width="1000" height="24">
        <b><big>Replace notes with rests</big></b>
      </td>

      <td height="27"  width="100"><input type="button" id="bClick2" value="Read" onclick="calculate()"></td>
     
    </tr>
    <tr>
    <td colspan=5 width="1044" height="200">
      <textarea name="OutputField" rows="16" cols="120"></textarea></td></tr>
  </table>
</form>
<br>
Copy the above to your clipboard (it's pre-selected) and paste it into a song you have already open in <b>NoteWorthy Composer</b>.
</body>
</html>
Since 1998

Re: changing notes to rests

Reply #2
I think Warren's macro is probably the way to go, but if, like me, you're nervous about automating the editing process, I'd just go with copy/paste. 

If, for instance, you have 10 staves with a quarter note on beat 3 of measure 25 and you want to change them all to rests, change the top line occurence as you would normally.  Then highlight that new rest, and press Ctrl-C for copy.

Move down a staff, and you'll find the note you want is highlighted.  Press Ctrl-V, and it's done.  Continue down the page, but after moving down the first time, you will have to highlight the targeted note in each staff.

You can do much the same thing horizontally as well.  If you enter the target note into the search menu (control-F), then "find" it again, it will be highlighted.  Make the change, and copy the result to the clipboard.  Press F3 and you'll highlight the next occurence; simply press Ctrl-V to replace it, then find the next one with F3.


Re: changing notes to rests

Reply #3
Thanks both for your help.  Warren I think I understood all except this -

Quote
and paste it into the page's textarea.  Click on Read,

 Is the page you refer to, the htm file opened as a browser window?.  If so I am not sure what the text area is. And then I am not sure where to go to click on Read.

And David.  I was a bit stuck here
Quote
Move down a staff, and you'll find the note you want is highlighted.
because when I move down a staff, the note isnt always highlighted and I end up inserting an additional rest instead of replacing the note.

Jennifer

Re: changing notes to rests

Reply #4
Is the page you refer to, the htm file opened as a browser window?.  If so I am not sure what the text area is. And then I am not sure where to go to click on Read.

When you double click on its entry in Windows Explorer, it will open your browser and you may have to enable javascript.  The text area is the large box under Replace notes with rests.  Keep the browser open while you are running NWC.  Cut the measures you want changed to rests and paste into that text area.  When you click on Read the text area will have the notes changed to rests.  Press Cntl/C to copy it to the clipboard, press Alt/Tab (maybe more than once if you have several windows open) to get back to NWC w/o changing the cursor position then Cntl/V to get the converted textarea back to your NWC work.  If you need to do this more than once, keep your browser open.

HTH
Since 1998

Re: changing notes to rests

Reply #5
Quote
And David.  I was a bit stuck here "Move down a staff, and you'll find the note you want is highlighted "
because when I move down a staff, the note isnt always highlighted and I end up inserting an additional rest instead of replacing the note.

Hi Jennifer
For some reason, when you move down the first time after some edit operations, the range on the destination staff is highlighted.  However, when you move down the next time, to a third staff, it isn't.  I don't know why NWC2 differentiates between edit operations and between the number of downward moves.  

I put it down to magic.  

I'm happy when it happens, but I don't find it terribly inconvenient when it doesn't because I grew up with this program before it did it at all.