Is there any automated way to determine the lowest quality encoding a music file went through? I sometimes get tracks from random websites and I suspect some audio files have some re-encoding history. I would like to ensure that the sound quality is OK (e.g. the quality could be expressed in bitrate + format: File A.mp3 has an AAC 256 kbps quality or a 320 Kbps MP3 quality).
You are talking about "transcodes".
The easiest way to determine the quality of the track is by looking at spectrograms. The higher the quality of the sound, the higher will the spectrogram "peak". When analysing MP3s, you will get 16kHz for 128 CBR and around 19-20kHz for V0 (VBR) and 320 CBR.
Here's how a spectrogram looks like:
Bear in mind however that this just gives you a general idea of the quality of the track. If the track is not mastered well, or is an ambient track without much detail, or is based on lossy samples, or is simply a shoddy production, even when you download a track from an official source, it might not have a great spectrogram.
So in general there is no automated way of determining the exact history of the file, however the above way allows you to get a general idea of the sound quality of the song and perhaps see whether the file is an obvious transcode.
Safe answer might be "can't determine'.
Except a few special lossless codecs, all digital audio codecs use perceptual coding which is basically deleting non-human-hearable sound samples from the original.
As mentioned by MMM, if the file has been encoded with any lossy codec it may show smoothed spectrogram (can't be the case always) but we can't determine how many times, how lossy conditions it has been through.