Self-oscillatory flow in the Hartmann resonator is numerically calculated within the framework of ideal (inviscid and non-heat-conducting) gasdynamics. The calculations are performed for the case of a sonic jet impinging on a tube varying from that with a sealed inlet (rod) to a fairly deep cavity. The spacing between the tube and the nozzle and the nozzle pressure ratio are also varied in the calculations. On the basis of the calculated results the oscillation process is described in detail and its mechanism is revealed for both shallow and deep tubes. For shallow tubes and a rod it is due to an imbalance in the flow rate and momentum between two regions in the jet that impinges on the obstacle. For deep tubes the oscillations are due to the tube filling and evacuation somewhat reminiscent of the process occurring in a one-quarter-wave resonator. In any case no signature of a feedback loop in the external acoustic field of the jet was detected. The results of the calculations are in good agreement with experimental data. The effects of mounting a lip on the tube (transition from a low- to high-frequency operation mode) and heating in the Hartmann tube are also discussed.