Pitch Shifting with changing the temp/speed

  • Thread starter Thread starter btb4198
  • Start date Start date
  • Tags Tags
    Pitch
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
3 replies · 1K views
btb4198
Messages
570
Reaction score
10
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?
 
Engineering news on Phys.org
If i play set my wav file to a sampling rate of 44100hz and 2 channels but i generate point using

buffer[n] = Amplitude * (2 * rnd1.NextDouble() - 1) * Math.Sin(Math.PI * Frequency * n2 / 88200D);

88200 hz is 2 time bigger than 44100hz that would be one octave below middle C? so the sound would be lower right? and it pitch shift white noise or pink noise lower after fitler between 2000hz - 500hz you should get thunder right ? is that correct ? or am i just wrong ?
 
ok i just did this test. 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 .
but 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?