# How would I use a sound bank with a few notes to create a full range of notes?

I am looking to create a software in which a key from the keyboard would play a note. So I downloaded a sound bank and I was surprised when I noticed only a few notes were there.

Salamander Grand Piano: A0 to A7 (meaning A0, A1, A2...), C1 to C8, D#1 to D#7, F#1 to F#7.
Upright Piano KW: A3 to A7, B1, B2, B7, C1, C4 to C7, D#2 to D#7, F#1 to F#7.

I do not believe this a mistake from the website, it's probably a misunderstanding on my part because of my very small knowledge of music. My guess is that someone could get any note from one or two of those notes by changing the pitch.

So my question is: Assuming I know how to change the pitch, how could I use those notes to create a full range of notes? I guess from A0 to G8.

I know there are MIDI interface that would allow me to do that but I am not looking for this or SF2 formats, I just want to use WAV files where a WAV is a note.

Keep in mind you are talking to someone illiterate in music with only a very basic understanding of it. Feel free to suggest rewording and tags for future readers.

As you've noted, playing a sample faster increases the pitch. How much faster? Under equal temperament, multiply by 2n/12, where n is the number of semitones higher. (212/12 = 2, which is an octave).

Wikipedia has more details.

For the first set of samples, you can play these samples at (12th root of 2)x speed (1.05946x speed) to get the notes A#, C#, E, and G. You can play these samples (1/(12th root of 2))x speed (0.94387x speed) to get the notes Ab, B, D, and F. This will cover the entire range from Ab0 through G7.

The general formula for pitch shifting the notes is 2^(n/12) for an n-semitone pitch shift, as given by Kelvin in his answer. Note that n can be negative for a lower pitch.

You will notice that pitch-shifting the samples like this changes the sound in more ways than just pitch. Ideally, you'd have a sample for each note, although using one sample for 3 notes like this is not uncommon in cheaper digital pianos, or for the non-piano sounds in digital pianos. You can get a passable full piano sound. However, since you are missing samples higher than F#7, and you have huge gaps in the samples for the upright piano (as stated in the question), you may not be able to play certain notes convincingly- for example, your best available D#1 for the upright piano would be either the C1 sample +3 semitones or the F#1 sample -3 semitones, which would both sound quite unnatural.

I guess that without changing the speed, you can decompose the frequencies using the Fourier Transform, change the pitch an then add up your frequencies to have the pitch you want. I'm not an expert, but this idea sounds great to me.

Fast Fourier Transform

Descrete Fourier Transform

• If you take the fourier transform of the entire signal and shift all frequencies up by the same factor, isn't that just speeding it up with extra steps? There are time stretching algorithms that do the same thing but with windowed segments of the signal, but then you're sacrificing sound quality to preserve the length of the note decay, which is not a great tradeoff. Mar 3 at 23:19