We consider the problem of determining a localized tonal context in a musical composition. Our method is based in part on a key-finding algorithm developed by Krumhansl and Schmuckler (Krumhansl, 1990) and is applied in a sliding-window fashion, producing a sequence of key assignments. These assignments constitute so-called class data in that they possess no natural numerical properties and can be considered as arising from a classification process. A new approach for smoothing such class data using graph theoretic norm estimates is applied to the sequence of key assignments. The effectiveness of the proposed method is evaluated by comparing it with judgments made by experts. Then, the problem is placed in the context of machine recognition of music patterns. We discuss a music pattern recognition system proposed by Coyle and Shmulevich (1998) that relies on robust determination of localized tonal context. This, in turn, allows the system to incorporate perceptual error criteria.