I had the EXACT same problem last year with my 2004 950s and it was the Voltage Regulator. Headlight would turn off when I accelerated, then once after a short ride around town an insane amount of heat was emanating from the engine area, despite the thermostat marking 4 bars only, there was the high pitched alarm (overheating sensor alarm, I think), and my bike smelled mildly of burning potato salad.
Could not figure it out. Things eventually went back to normal.
Then I set off for a 4.5 week tour with my girlfriend to Botswana and back (from Arusha, Tanzania, where I live) and on day 1 the bike backfired and shut off from fuel starvation on the road. Same symptoms - whine, smell, but this time it didn't start back up.
Devastated, I put it on a truck, took it back and we realized it was the voltage regulator. The battery was cooked but miraculously, the rest of the electronics were not fried. The fuel pump had shut down because of the voltage overload so that is why the bike died on the road. We fitted on a voltage regulator and battery from a Yamaha 660R (same bolt pattern), took a spare dry cell battery and cables in case we needed to boost the little Yamaha battery in the mornings, and set off.
9,000 kilometers, 5 weeks, and 7 countries later, we returned to Arusha on that same Yamaha voltage regulator and battery. Never had to boost it with the dry cell.
Have an OEM voltage regulator on the way and have the right battery in there now. We'll see how they work!