The invention relates to an X-ray source (2) for an imaging device comprising at least three electrodes a power supply configured to provide a primary gap voltage between a first (13) and a second (12) electrode among said at least three electrodes, said primary gap voltage having an AC component, causing a transport of electrons from the first electrode toward the second electrode and a controller configured to supply a variable potential on a third electrode (14) among said at least three electrodes, wherein the X-ray source is configured to generate an X-ray beam with an energy spectrum based on the voltage difference between the first electrode and the second electrode, and wherein the controller is configured to set the variable potential on the third electrode to a value causing at least a partial blocking of said transport of electrons, whenever a predetermined condition is met.