Sethares [21] implemented software that automatically retunes a MIDI stream (in a file or in real-time) based on knowledge of the spectra produced by the MIDI device and a mathematical model of human dissonance perception. The goal was to minimize the dissonance of the output audio, where dissonance was defined according to the model of Plomp and Levelt [16]. This algorithm does not avoid any of the melodic artifacts associated with just intonation, but it automates intonation decisions. In addition, it can handle sounds with inharmonic spectra, such as bells, which cannot be tuned using conventional theories of just intonation. As Sethares admits, a shortcoming of his approach is that consonance is not a globally desirable property in music. This algorithm would probably be best applied in a selective fashion to chords for which consonance is most appropriate.