A rules engine acquires sensor data from sensors applied to the heart and determines whether an electrical waveform should be applied to the heart and, if so, the type of electrical waveform. A multi-phase cardiac stimulus generator generates waveforms in response to the rules engine from waveform data stored in a memory. The electrical waveform is applied to one or more electrodes implanted in or on the heart.