ios - AVPlayer : change rate with NO pitch correction?
<p><p>我正在使用 AVPlayer 的 <strong>rate</strong> 属性来更改音频样本的播放速度。它似乎总是应用音高校正,但我不想要音高校正,这样当它加速时它会像唱片或旧磁带播放器一样变得更高。有没有办法在 AVPLayer 中完全关闭音高校正?</p>
<p>我目前正在使用 Swift 3,但也欢迎使用 Objective C 的答案。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>不确定这是否可以使用 AVPlayer,但如果您只是使用它来播放音频,您可以使用 AVAudioEngine 轻松做到这一点:</p>
<pre class="lang-swift prettyprint-override"><code>var audioPlayer = AVAudioPlayerNode()
var engine = AVAudioEngine()
var speedControl = AVAudioUnitVarispeed()
// engine setup:
do {
let file = try AVAudioFile(forReading: "myFile.mp3")
engine.attach(audioPlayer)
engine.attach(speedControl)
engine.connect(audioPlayer, to: speedControl, format: nil)
engine.connect(speedControl, to: engine.mainMixerNode, format: nil)
audioPlayer.scheduleFile(file, at: nil)
try engine.start()
} catch {
print(error)
}
// changing rate without pitch correction:
speedControl.rate = 0.91
</code></pre></p>
<p style="font-size: 20px;">关于ios - AVPlayer : change rate with NO pitch correction?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/36223632/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/36223632/
</a>
</p>
页:
[1]