I had exactly the same issues with EXISTING MIDI tracks within a project I later applied a tempo map to
What made my issue even more frustrating is that I set the tempo map from the rendered audio of my piano MIDI track - so was convinced the MIDI should be in perfect time with the tempo map (because the tempo map was created from it)
This can get a bit confusing so I hope you follow - it may take a few reads until the penny drops but I think I can explain what is going on...
I wanted to try another piano sound but when I played the MIDI it was all out of sync (even though the tempo map was created from the rendered audio, which was created from the piano MIDI)
I therefore wanted the MIDI piano to "ignore" the tempo map and play exactly as it did before
However, as pointed out when I posted this question in the forum, the MIDI needs to follow the project tempo - if it ignores it how will know when to play the notes!!
It is as if a "paradox" has been created
The original MIDI file was created following a tempo - even if the piano was played completely ignoring "the grid" - there is always a tempo set in Sonar (even without a click) so the MIDI is still recorded relative to this tempo (even if it is not being used by the performer and they are playing completely free form)
When a tempo map is then applied the MIDI has to follow this new tempo map (since MIDI only contains info about when to play a note relative to the tempo of the project, how long to hold the note, the velocity of the note etc.)
Therefore since the project tempo has changed (via the tempo map extracted from the audio) any MIDI tracks have no option but to follow this new tempo map - which is different to the tempo at which they were originally recorded - which is why they now play out of sync!
Phew! It has taken me ages to get my head around this but this is what I think is happening
As a "workaround" for this project my advice would therefore be to create a NEW project at the exact tempo of your existing project BEFORE the tempo map was applied and your MIDI played in sync with the audio
Import your original MIDI file of the piano into this new project
Tweak anything you want to tweak (in my case it was changing the piano VST but you can tweak any MIDI data as well)
Bounce or export this as audio
Put the audio version back in your original project and it should play nicely with everything else
You can insert NEW MIDI tracks and they will happily follow the tempo map (as the the notes will be recorded relative to the tempo map) - so in future if you will be using MIDI make sure the tempo map is set first using the audio you want to play along to - then quantizing etc. will work
I hope this makes sense and helps you and others get over the confusion of how exiting MIDI recordings appear to go "out of sync" when a tempo map has been applied AFTER they have been recorded
This is not an issue with Sonar or Melodyne - it is simply a case that the MIDI file has no option other than to follow the project tempo
If the MIDI was originally recorded at one tempo (I've before the tempo map was applied) it is completely logical (if I have explained it correctly) that the MIDI will now follow the new tempo map if it is applied - therefore it will NOT play as before (as it is now following a different tempo than it was recorded to) so will play out of sync with any audio recorded at the original tempo