Someone asked on Discord. Posting an answer here for reference.
I have some mallet sounds when a user types (in the key of A Major), and i need to transpose it based off what song is playing in the background (for example a song in C Major needs to go up 3 semi-tones or half-steps)
An octave means that the ratio between two frequences is 2:1 (e.g. pitch for one octave higher is 2, for 2 = 4, etc.), so the pitch becomes:
pitch = 2 ** octaves;
Say, you have 12 semitones in an octave, then it becomes:
pitch = 2 ** (semitones / 12);
For an absolute pitch, like F4, you can represent it as a MIDI note 64 (you can google those). So, in the end, if you want to find a pitch of MIDI note C4 (60) using a sample of MIDI note D4 (62), it becomes:
I have also solved it in this way! I needed to be able to transpose a note up from like A to C for example, and notes in a scale are not equally divided into 12 even though there are 12 notes in a scale. Its all about the ratios!
with this chart: C5S1_Intervals
you can see the ratios of each note in a chromatic scale compared to the input note. Here is a function to transpose up. So if you are playing an A note in a soundSlot but you want it to play a C you could do