Is pitch and speed the same thing in audio programming context?
Pitch means "perceived frequency". Nice. But when I make pitch very low in OpenAL, sound plays a lot of times longer. If I make it very high, sound开发者_开发知识库 plays very short but with high frequency. For me, logically the consequence of making slower or faster.
Or is pitch != speed?
Paul R has a pretty good answer, but I'd like to expand on it a bit. If you think of the sound as a series of pulses (and it kind of is), then a higher pitch will have more pulses per second (higher frequency) and a lower pitch will have fewer (lower frequency). To lower the pitch of an existing sound, you have to spread those pulses out (make them further apart from each other). As a result, the duration of the sound will increase because you haven't reduced the number of pulses, you've just made them further apart (fewer per second). The opposite happens if you try to increase the pitch: the pulses are closer together, thus making the sound shorter in duration.
If you want the duration to remain constant regardless of changes to the recorded pitch, you have to either throw information away (lower pitch) or manufacture information (higher pitch). This is where the fancy processing comes in. What can be safely discarded? What can be safely duplicated or constructed?
It's relatively easy to vary pitch
and rate
together, since all you need to do is vary the rate at which you play back samples. If you play samples back at half their intended rate then pitch will be halved and the sound will come out at half speed (think about a tape deck running at the wrong speed). Conversely playing samples back faster than intended will increase pitch and make everything faster.
You can vary pitch
and rate
independently, but it takes a lot more processing to do this, typically using some kind of analysis and re-synthesis algorithm (e.g. PSOLA for speech).
Using the algorithm you're describing in OpenAL, pitch = f(speed), and speed = f'(pitch).
It is possible to vary these parameters somewhat independently using a different algorithm. There are a variety of algorithms for doing this.
The algorithms in question can exist in the frequency domain (vocoder, frequency domain convolution) or in the time domain (PSOLA, WSOLA, extended WSOLA) or in both at the same time (hybrid models that use time-domain methods for transient sections and vocoder methods for tonal sections).
精彩评论