# Pitch Shifting with changing the temp/speed

when I use Audacity Pitch Shifting with changing the temp/speed, it seem to work really well.
but I tried to code one of my know, but IDk why minez is not working like Audacity is. are you doing some different ?
My program make it know files, so I use that same file on both Audcity Pitch Shifting with changing the temp/speed and minez , but IDk my do not work like yours do.

so I have a white, brown, and pink noise generators and i want to shift the pitch up by one octave (12 semitones) from middle C, I need to sample 2 time as fast as I play the sounds correct ?
so in the c# code for my white noise generator I have it playing at 44100 Hz( the standard) but I am sampling the 88200 Hz so it would be this :
buffer[n] = Amplitude * (2 * rnd1.NextDouble() - 1) * Math.Sin(Math.PI * Frequency * n2 / 88200D);
and this should work right ? I have it set to 2 channels and 44100 Hz but I am sampling at 88200 Hz;
so it should move up one Octave from middle C, without changing the speed is this correct ? and if I were to sample at 22050Hz I would be move down one octave from middle C?

ok i did this test with mine. I removes the noise part and just play a normal sine wave so this:
buffer[n]= (float)(Amplitude * Math.Sin(Math.PI * Frequency * n1 / 88200D));
I set my wave file sampling rate to 44100Hz and channel to 2. so I am sampling 2 times faster and I am playing and it seem to be working : middle C (C4) = 261.6 Hz C3 = 130.8 Hz I played 261.6Hz and I got back 129.199 Hz that is really close. C6 = 1047 Hz i played 1047 Hz and I got back 522.180 Hz C5 = 523.3 Hz also very close G4 = 392.0 Hz G3 = 196.0 hz I played 392.0Hz and I got back 193.7988Hz
that is is off more than the others , but still close right? what do you think? oh I used another program i make to do the listening and that it how I know what Frequency i am getting back .

ok it did not work when I added the white noise part. I have tried both : temp3[n] = (Amplitude * Math.Sin(Math.PI * (2 * rnd1.NextDouble() - 1) * n2 / 264600));
and temp3[n] = (Amplitude*(2 * rnd1.NextDouble() - 1) * Math.Sin(Math.PI * Frequency * n2 / 264600));
and I have change 264600Hz to everything I could think of… and it does not work… why? what does Audacity’s change Pitch without changing tempo effect does that my does not?