是否可以改变音频队列的播放音调

发布于 2024-11-07 03:00:08 字数 603 浏览 0 评论 0原文

这应该可以在 Mac OS X 上实现,方法是覆盖 AudioStreamBasicDescription 中的采样率,然后创建一个新的输出队列。

我已经能够检索默认采样率并编写一个新的采样率(即用 48000 替换 44100),但这不会导致输出信号发生任何音高变化。

err = AudioFileGetProperty(mAudioFile, kAudioFilePropertyDataFormat, &size, &mDataFormat);
        if (err != noErr)
            NSLog(@"Couldn't determine the audio file format");
        Float64 mySampleRate = mDataFormat.mSampleRate; //the initial rate
        if (inRate != 1) {
//write a new value
            mDataFormat.mSampleRate = inRate;
            //then 
err = AudioQueueNewOutput etc.

任何建议将不胜感激。

This is supposed to be possible on Mac OS X by overwriting the sample rate in the AudioStreamBasicDescription then create a new output queue.

I've been able to retrieve the default sample rate and write a new one (ie. replace 44100 with 48000) but this is not resulting in any pitch change in the output signal.

err = AudioFileGetProperty(mAudioFile, kAudioFilePropertyDataFormat, &size, &mDataFormat);
        if (err != noErr)
            NSLog(@"Couldn't determine the audio file format");
        Float64 mySampleRate = mDataFormat.mSampleRate; //the initial rate
        if (inRate != 1) {
//write a new value
            mDataFormat.mSampleRate = inRate;
            //then 
err = AudioQueueNewOutput etc.

Any suggestions would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回眸一遍 2024-11-14 03:00:08

更改采样率不会改变音频的音高。您可能会认为播放速度较快的内容音调较高。但这是感知而不是现实。

要更改音高,您需要通过数字信号处理 (DSP) 库处理音频数据。或者,看看通过 AudioUnit 运行它:

音频单元编程指南

Changing the sample rate doesn't change the pitch of the audio. You may perceive that something playing back faster has a higher pitch. However that's perception rather than reality.

To change pitch, you'll need to process the audio data through a Digital Signal Processing (DSP) library. Alternatively, take a look at running it through an AudioUnit:

Audio Unit Programming Guide

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文