2
$\begingroup$

I am programming a voice changer (in c++). I need only to change the pitch of the voice. Unfortunately, I absolutely lack theoretical knowledge and hence I could not find information on the Internet :( I am asking after theory (mathematics?) lying under pitch changing. Consider, I already have .wav audiofile converted into array of samples. Thanks in advance!

P.S. After changing the pitch, the duration of the audiofile should remain the same.

$\endgroup$
5
  • 2
    $\begingroup$ Well, if it's a single human voice, you shouldn't need to do this with a phase vocoder. How far are you shifting the pitch of the vocal track? If less than 200 cents, then you won't need to do formant-preserving pitch shifting (which requires a damn good pitch detector). Otherwise, if you're shifting the pitch by a third or fourth or fifth, you need to implement Lent's algorithm (also credited to Hamon). That requires a really good pitch detector. $\endgroup$ Commented Oct 18, 2023 at 19:52
  • $\begingroup$ @robertbristow-johnson thanks for theoretical hints! Yes, it is a single human voice. Mainly, I am interested in making the voice lower or higher. For example: female -> male / male -> female. According to your comment, should I study Lent's algorithm and implement a really good pitch detector? $\endgroup$
    – ONamaeWa
    Commented Oct 18, 2023 at 20:42
  • $\begingroup$ I think you'll need to shift pitch and formants independently. A quarter century ago, I had developed DSP code for a product called PurePitch in which there were separate controls for pitch shift amount and formant shift. We had presets called "estrogen" and "testosterone" that were meant for changing the apparent gender of the speaker. We also had a control for reducing or increasing expression. We could turn your voice into a monotone. And could increase inflections of pitch also. $\endgroup$ Commented Oct 19, 2023 at 14:14
  • $\begingroup$ @robertbristow-johnson thanks, your experience and PurePitch description are relevant. So, TODO list: 1) decompose the signal into frequences (Fourier transform) and formants 2) shift the frequences (Lent's algorithm) and shift the formants 3) Somehow compose the signal back. I could use Inverse Fourier transform for frequences, but how to deal with formants? Unfortunatelly, I have never worked with formants $\endgroup$
    – ONamaeWa
    Commented Oct 19, 2023 at 15:47
  • $\begingroup$ PurePitch did not do that. What you're describing is sinusoidal modeling, which you can do. Lent's algorithm is NOT frequency-domain. It's a time-domain algorithm, so no Fourier Transform. But you need a really good pitch detector. $\endgroup$ Commented Oct 19, 2023 at 17:49

1 Answer 1

4
$\begingroup$

Well Well Well lol ...

Reading your comments, if do you want change the voice gender you will need pitch shift and change the fomants too, I know some ways to do it!

Completly based time domain codes:

  • (Keith Lent, PSOLA, Hamon) They are all based on the same principle - Based on the pitch of each grain analyzed, it is possible to alter the pitch while maintaining the formant or not, to do it adjust the frequency at which the grains are emitted crossfading between the two grains to prevent clicks . For higher pitches, you may need to repeat grains, while for lower pitches, you may need to eliminate some grains. To modify the formant while maintaining the pitch, maintain the grain rate constant but alter the grain's playback speed. Higher speeds will produce higher formants, while lower speeds will produce lower formants. (you will need a very good pitch track) how do it here
  • Source Filter (Physical modeling) - The human voice can be conceptualized as a source-filter model, the physical model represents the vocal signal as a time-domain glottal signal (with a flat spectral envelope) combined with a vocal tract filter containing formant information. Where the source is the vocal cords and the filter is the vocal tract. Physical modeling involves analyzing the vocal signal to separate the glottal information (source) from the vocal tract information (filter). Since we can manipulate the glottal signal and the vocal tract model independently. One way to do it is using LPC, one more time you will need a very good pitch track to generate an pulse train (keep the original pitch or change) to resynth the signal with original formant or not ... but there is still another way to do this here, we can time stretch and resample the extrated glottal signal and then apply a filter to the pitch-shifted excitation signal using the original spectral envelope as a reference (here you don't necessarily need a pitch track, just autocorrelation to time strech can solve).

Based in Frequency Domain

$\endgroup$
1
  • $\begingroup$ Thanks, exactly what was needed. Helped me :) $\endgroup$
    – ONamaeWa
    Commented Oct 24, 2023 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.