I'm currently writing a program for analysing tonal music, and ran into something I didn't know the answer to.
Basically, this has to do with scalar transpositions, i.e., transposing a given pitch P up or down by n scale degrees relative to some given scale S. For pitches that belong to that scale, this is trivial, of course.
But where things become complicated is when P has an accidental relative to the prevailing scale. For example, there may be an F# in the music in the prevailing scale of C major, as a modification of F (the 4th scale degree). My current approach to handling this is to first measure the interval from the tonic to the given pitch, in this case, C to F#, which is an augmented 4th. Then suppose we want to transpose up by 1 degree, which corresponds to an augmented 5th from C, so the result is G#. So far so good.
But where problems arise is when the number of steps in the transposition crosses perfect/imperfect intervals, for example, if, under the same transposition (up by 1 degree relative to C major) I have a note Eb, which is a minor 3rd from the tonic C, then what interval should be formed when I transpose it to a 4th? Should it be a perfect 4th, or a diminished 4th? If a perfect 4th, does that mean both E and Eb would transpose to F under this transposition?
(P.S. Just to be clear, I'm talking here about scalar transposition, not chromatic transposition where the relative semitone distances between notes are maintained. By scalar transposition I mean that transposing, say, C-D-E up by 2 degrees (relative to C) would yield E-F-G, not E-F#-G#.)