0

I am looking to pitch shift the audio contained in the sample variable to a specific frequency without changing the speed of the audio.

Here is the code I have so far.

import sounddevice as sd

SAMPLE_RATE = 48000

def record_sample():
    print("recording...")
    recording = sd.rec(int(3 * SAMPLE_RATE))
    sd.wait()
    print("done recording.")
    return recording

def init():
    sd.default.samplerate = SAMPLE_RATE
    sd.default.channels = 1

init()
sample = record_sample()
sd.play(sample)
sd.wait()

How would I go about doing this?

Thanks in advance.

joe
  • 463
  • 4
  • 17
  • Does https://stackoverflow.com/questions/6326822/python-audio-frame-pitch-change help? What exactly do you mean by shift to a specific frequency? – Ali Rasim Kocal Sep 17 '19 at 13:13
  • Thanks. No that doesn't quite do what I want. By shift to a specific frequency, I mean shift the sample to a frequency such as 440hz so I can play the sample musically. – joe Sep 17 '19 at 13:24
  • Then you would follow a very similar approach, the only different being, you have to calculate how much shifting you need to do. This is also easy because after FFT, you know the dominant frequency of your signal, which means you need to shift as much as the difference. – Ali Rasim Kocal Sep 17 '19 at 14:29
  • Cheers. I will try that. – joe Sep 17 '19 at 14:37

0 Answers0