# Continuously changing pitch of stable-pitch audio sample

Signal Processing Asked on January 4, 2022

I have an 44100-rate 4 second sample of a legato violin playing at 440 Hz. I would like to modulate this sample so that it starts at 440 Hz, then transforms its frequency continuously and exponentially to 660 Hz, while maintaining the original timbre.

I have tried pitch shifting directly from 440 to 660 and this works fine, but trying to simply cut the sample into extremely short bits and increase the pitch shift for each consecutive bit resulted in a lot of artifacts.

Do you have any suggestions?

Bonus points if it would be easy to implement in python!

You're trying to do the time warp dance. If you were copying the samples point by point, your playback time (destination) and your look up time (source) would be the same. If you wanted to speed it up by a factor of two(one octave), your lookup time (source location in the array) would be moving twice as fast as your sample time (location in your output buffer). For variable speed time, you have to figure out where in the lookup table to grab the next value (function range). Where you are going to write it to is the next spot in the buffer, as in uniform time (function domain). When you calculate the location to get your signal value, it may not land on an integer. You could get some rough sound if you just use the nearest one.

So, you got two choices for better quality.

1. Increase the density of your lookup table

2. Use some method (called interpolation) to figure out what the value should be

A. Linear interpolation means draw a line between the two nearest samples and use that height whereever your fraction takes you

B. Polynomial interpolation means use the nearby samples to draw a nice smooth curve, and use that height

C. Sinc interpolation means use the sinc function as a weighted average of many nearby points to get the value

Your musician friends will tell you it doesn't sound right. Instruments are complicated and their timbre varies by frequency and the middle name of the nearest bartender.

That's really the precursor to DSP. Trying to fix the sound so it sounds right is a challenge you can have hours of fun pursuing, as others are. There is lots of material if you look for it. I am not really an expert on that at all.

In a synthesizer wavetable the source location just goes round and round and round... how much faster each step is related to the frequency.

Keep a steady tone by not changing the step size.

Linear growth in time. Add the same amount to each step.

Exponential growth in time. Add a multiple of the previous step size.
For instance,

ThisStep = 1.00001 * PreviousStep

SourceLocation += ThisStep

The step size grows exponentially and so does its accumulation.

Speeding up by a factor of $$2^{1/12}$$ is one semitone.

There's math problem and solution in there somewhere, I'm sure you'll spot it and solve it to get this done. Or maybe two.

Answered by Cedron Dawg on January 4, 2022

## Related Questions

### Estimation algorithms for Multi-User MIMO

0  Asked on December 12, 2021

### Signal bandwidth and channel bandwidth

1  Asked on December 12, 2021 by user51576

### porting matlab code on to TI OMAP L138

1  Asked on December 10, 2021

### When does the narrowband model in array processing fail?

0  Asked on December 10, 2021 by murtpid1

### Choppy output when trying play through a callback buffer

1  Asked on December 7, 2021 by halbe

### How do you perform range compression of SAR data on a 2D matrix?

0  Asked on December 7, 2021 by level2fast

### How to make signal smooth using filter?

1  Asked on December 6, 2021

### Realtime sample rate conversion

2  Asked on December 6, 2021 by nuno-santos

### Discrete wavelet center frequency

0  Asked on December 6, 2021

### How do software equalizers work?

2  Asked on December 4, 2021 by kevin-sullivan

### What is the difference between the PSD of a deterministic and stochastic signal?

2  Asked on November 30, 2021 by user2796729

### Sum of correlated exponential random variables

1  Asked on November 30, 2021

### Possible to get transfer function coefficients from window?

1  Asked on November 30, 2021

### Is real-time signal processing possible under Windows?

4  Asked on November 28, 2021

### How to calculate DTFT of cosine function divided by n

1  Asked on November 28, 2021 by jhon-margalit

### Understanding MFCC

0  Asked on November 28, 2021 by naveen-gabriel

### How to determine the original size of the FFT used in unknown OFDM symbol

3  Asked on November 25, 2021 by sensen

### Fourier transform of a damped cosine wave with a linear frequency chirp

1  Asked on November 25, 2021

### How well can discrete wavelet packet transform reduce noises that are similar to the input signal in the same frequency band?

0  Asked on November 25, 2021

### Does the FFT size matter in OFDM demodulation?

1  Asked on November 25, 2021