I play and now teach ancient style rudimental snare drum, which has all kinds of screwy tempo things that happen and weird technique that makes certain patterns want to drag.
Generally, the biggest hurdle to keeping a steady beat is fluency - your body gets in the way of what you're trying to do.
To demonstrate this, can you clap to a beat? If you can, then your brain can follow a beat, and it's probably your technique getting in the way. If you can't...practice clapping along to music, then come back.
If the metronome isn't working for you, chances are you're using it too early or too fast. You need to be able to play the difficult passages BEFORE trying to match them to a speed - otherwise your tempo will be at the mercy of physics. Even ambient keyboards have technical issues - the quick changes between chords, for example.
So here's few exercises I do to improve my students' technique. These are all things we do independent of specific music.
- Clap along with another person who's playing.
- Mark Time (we're a marching group), or tap your foot to the music other people are playing. Always tap your foot while playing anything, especially easy stuff.
- Play something with someone else on the same part, and listen to each other.
- Play the same (easy) pattern while I'm clapping at different speeds. Usually we start with 8th notes, then add some different rhythms. You can also accomplish this with a metronome.
- Sightread dead simple music with a metronome. When you mess up, do a line over. I made a "dictionary" of 4 measure lines of common patterns that we work through.
As for particular passages:
- Use check patterns. Check patterns are simplified versions with the same rhythmic skeleton. Alternate between the check pattern and what you're actually trying to play and make sure they sound the same. For a
flamacue
(accent on beat two with several grace notes and retrograde hand motion), we just play 16th notes. With runs on wind instruments, we play the key notes at the right times, and then add the inner notes.
- Play it slower. Avoid doing things like half speed, pick a totally unrelated tempo. Try to make your brain focus on the rhythm, rather than on the technique or how it "sounds".
- Practice small chunks until they're fluent (easy), then group them into larger sections, with a metronome.
- In all cases, get away from playing by ear, and instead play from knowledge. This will increase your confidence - if it's mechanical and not subjective, you'll be more confident.
I'm a fan of making things easy. There's no point in doing something hard if you can find an easier way that takes 50% longer. Your increased stamina will more than make up for the extra time it takes. So break your hard parts down into manageable chunks that you can easily do in a sitting.
The metronome and foot tapping really are your friends, and while it takes some time to get used to (one more thing to think about), focus on learning to do those things with easy music at low speeds. Eventually it will become natural, but it does take time.