Jump to content

Removing a range of unwanted notes from a MIDI file


Don Johnson

Recommended Posts

MIDI files are increasingly being used with mechanical pipe organs, which have different ranges of playable notes.  The number of notes varies (20, 26, 31 etc), and so does the lowest playable.  To create a suitable MIDI file with fewer notes from one with more can be achieved using Piano Roll in Cakewalk by SHIFT/Clicking on those not needed on the keyboard display, then using DELETE to remove all those which have changed colour.  A different lowest note can initially be set using Track transpose - MIDI files for organs usually use just Track1 on MIDI Format 0.

It would be very convenient if a pattern of playable notes could be applied to a tune, so that all those NOT within the pattern could be eliminated together.   

Is there any way that this is possible, or am I asking too much?

DonOrgan.jpg

Link to comment
Share on other sites

15 hours ago, David Baay said:

I use a Drum Map to pass only notes that can be played by a physical music box when composing for that instrument using a VSTi.

That sounds like what I want to do, but as a Cakewalk novice, can you give me some hints on how to go about it, please?   

 

Edited by Don Johnson
Link to comment
Share on other sites

If you want to delete notes outside a specific range, you can use the event filter. 

- select all the notes -- easiest way is probably to click on the clip header in track view
- then choose Edit, Select, By Filter
- in the dialog box uncheck everything except "Note" -- click the None button at the bottom and then check "Note"
- then check "exc" and set Min and Max to the playable range
- it should select everything outside the playable range which you can then delete

If you're going to need this regularly you can save the criteria as a preset at the top of the dialog before you click OK.

Link to comment
Share on other sites

Given that you just want to be able to pass a contiguous range of notes in the center and save it as a preset filter that can be applied to multiple files, I second  musekamp's approach.

The drum map solution was needed in my case because the passed notes weren't a contiguous range, and I didn't plan to delete anything. I just wanted be able to hear what was missing, and then transpose/re-orchestrate to preserve as much of a performance as possible.

 

Link to comment
Share on other sites

14 hours ago, David Baay said:

Given that you just want to be able to pass a contiguous range of notes in the center and save it as a preset filter that can be applied to multiple files, I second  musekamp's approach.

The drum map solution was needed in my case because the passed notes weren't a contiguous range, and I didn't plan to delete anything. I just wanted be able to hear what was missing, and then transpose/re-orchestrate to preserve as much of a performance as possible.

 

Thanks for the replies, but I too do NOT have a contiguous range of notes - different organs use different selections of notes - they are not chromatic (if that is the correct term).

Link to comment
Share on other sites

In this case, something like the free NoteMapper from Code FN42 may be a good solution.

It appears as a synth to the DAW.

Pass the MIDI through this plug-in setting the probability to 100% only for the notes needed and use this plug-in as the input to the MIDI tracks for the organs.

Link to comment
Share on other sites

13 minutes ago, scook said:

In this case, something like the free NoteMapper from Code FN42 may be a good solution.

It appears as a synth to the DAW.

Pass the MIDI through this plug-in setting the probability to 100% only for the notes needed and use this plug-in as the input to the MIDI tracks for the organs.

The 'Filter out unwanted notes' option looks like what I am seeking.   Thanks for the suggestion, which I will investigate.

However, as a novice, like Captain Oates, 'I may be some time'  ?

Link to comment
Share on other sites

Well, I must confess I'm stumped.   I seem to have successfully installed the Note Mapper plugin into Cakewalk, but I cannot find any info' on using Note mapper in Cakewalk.  I had hoped that I might be able to use this plugin without becoming fully conversant with Cakewalk, which I am using just to transpose and delete notes in a Piano Roll view - most of the rest in beyond me.  I am also possibly hampered by not being a musician - I'm using a mechanical organ, not playing one!   I was hoping to just pick out selected instructions for using the Filter function, but cannot even find general help anywhere.

I'm grateful for the responses I have received so far, but unless I can find some sort of idiot's guide, I think this is all beyond me.   I was involved in computing for about 30 years, but now my 82-year-old brain is struggling.

Link to comment
Share on other sites

NoteMapper may not be the solution.

Since this is not about using the data in the DAW, I might use a different approach.

If I had a bunch of MIDI files that I wanted to delete notes from I might create a CAL script for each filter then

  1. Load a MIDI file
  2. Select All using CTRL+A
  3. Process > Run CAL and select the CAL script filter to run
  4. Use "Save Copy As" to rename the filtered file
  5. If I had more than one CAL script, hit CTRL+Z to undo the first script then repeat steps 3,4 and 5 using the different CAL scripts until done with the MIDI file
  6. Close the MIDI file
  7. Repeat all steps until all the MIDI files are processed.

Here is a sample  CAL script that

  • deletes all notes values above 77
  • deletes all notes value below 60
  • deletes all note values 61, 70 and 75
  • deletes all non-note events
Quote

; this script deletes all non-note events, notes that are outside the high/low range in addition
; to the notes defined in the switch statement

(do
 (int high 77)
 (int low 60)
 (forEachEvent
    (if (&& (== Event.Kind NOTE) (&& (<= Note.Key high) (>= Note.Key low)))
      (switch Note.Key
          61 (delete)
          70 (delete)
          75 (delete)

          )
    (delete)
    )
  )
 )

Copy the script and paste it into notepad or any text editor

Adjust the high, low values (values in green) and add as many notes to delete in the switch statement (lines in blue) as necessary

Save to "C:\Cakewalk Content\Cakewalk Core\CAL Scripts" with a meaningful name such as organFilter1.CAL

The name can be anything but the ".CAL" extension is important 

Create as many scripts as needed adjusting the values for each organ.

Link to comment
Share on other sites

3 hours ago, scook said:

NoteMapper may not be the solution.

Since this is not about using the data in the DAW, I might use a different approach.

If I had a bunch of MIDI files that I wanted to delete notes from I might create a CAL script for each filter then

  1. Load a MIDI file
  2. Select All using CTRL+A
  3. Process > Run CAL and select the CAL script filter to run
  4. Use "Save Copy As" to rename the filtered file
  5. If I had more than one CAL script, hit CTRL+Z to undo the first script then repeat steps 3,4 and 5 using the different CAL scripts until done with the MIDI file
  6. Close the MIDI file
  7. Repeat all steps until all the MIDI files are processed.

 

Ah!   This looks like something I would have used in my programming years, and although I do not know the language, the syntax is familiar.

I did not mention that there may be notes outside the high/low range so the sample file looks ideal for removing those as well as unwanted ones within the desired range.

My own 20 note organ uses these notes:   F4 Bb5 C D Eb E F G A6 Bb C D Eb E F G A7 Bb C D so I'll substitute the MIDI numbers for those missing and the top and bottom notes 

BTW - I think that your line "delete all note values 60, 71 and 75" should actually read "delete all note values 61, 70 and 75"

What's more - especially if the line above is correct -  I DO understand it!  ? and should be able to create scripts for any organ type.

Thanks to you, scook, and all the others who tried to help.

I look forward to writing some code again!

Link to comment
Share on other sites

55 minutes ago, Don Johnson said:

Ah!   This looks like something I would have used in my programming years, and although I do not know the language, the syntax is familiar.

The scripting language looks like LISP but is very limited in what it can do.  I use LISP mode in EMACS to handle syntax highlighting and paren matching.

55 minutes ago, Don Johnson said:

BTW - I think that your line "delete all note values 60, 71 and 75" should actually read "delete all note values 61, 70 and 75"

Yeah, it's a typo 

I'll fix it along with making the IF condition a little safer.

 

BTW, once the scripts are created, it is possible to save some typing by binding the scripts to keyboard shortcuts.

To bind CAL scripts to shortcuts use Preferences > Customization > Keyboard Shortcuts.

The CAL scripts are near the bottom of the Global Bindings area functions list.

Link to comment
Share on other sites

12 hours ago, scook said:

Here are a couple of CAL resources

CAL Editor - I am not a fan of dedicated tools like this but it comes with a very useful CAL reference in Windows help format (chm).

CAL Programming Guide.pdf

 

Thanks scook, I worked with many languages during my career, but at the age of 82, I don't think I want to start learning another - my memory is not what it was!   I'm happy to just modify your sample script.

Just to let you know, I have successfully modified your script to suit my organ and it did exactly what I wanted.   I did have to play with the MIDI numbers since mechanical organs do not always actually play notes from the key that the music file contains, and it still confuses me  - and lots of others - but I got there eventually after finding the correct number of 12's to add or subtract.. 

Link to comment
Share on other sites

Glad it worked for you.

Remember there is no one standard for mapping MIDI note numbers to pitches.

There is a setting in CbB to adjust the pitch display called Base Octave for Pitches

Usually, I just toggle the label frame (keyboard display) next to the notes pane in the PRV between note numbers and pitches

  •  Right-click the keyboard to display the Note Names dialog 
  • Select the "Use these Note Names Instead" radio button then
  • Select 0..127 to display note numbers or Select Diatonic to revert to the keyboard
Link to comment
Share on other sites

I couldn't "remember there is no one standard for mapping MIDI note numbers to pitches" as I know so little I didn't know that!

The display alternative setting guide would have been helpful, but although I may have actually stumbled on those options before, I never would never have guessed that 0..127 referred to MIDI numbers.

But another thing shows how unfamiliar I am with Cakewalk in the fact that I had to use Google to find out that PRV meant Piano Roll View  ? Doh!

 

Link to comment
Share on other sites

  • 1 year later...

Just saw your question about removing unwanted notes. I am as well well over 80 and I don't need too much complication. What I use is a program called   gnmidi  you can do batch conversions of hundreds of files at one time There is a function called note replace. Just replace all The Unwanted notes with something very high  for example midi numbers 100 to 127 . You can go back there into Cakewalk and delete all of those very easily

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...