比較高級(jí)的音頻播放API.
1.管理所有的音頻節(jié)點(diǎn)(audio nodes) 2.連接所有的音頻節(jié)點(diǎn)使其運(yùn)作形成鏈條(active chains) 3.動(dòng)態(tài)的獲取(attach)和配置所有音頻的節(jié)點(diǎn)。
4.開(kāi)啟和停止API
涉及的類AVAudioPlayerNode
尘盼、AVAudioUnitTimePitch
、AVAudioUnitVarispeed
艰额、AVAudioUnitDelay
功能:
設(shè)置音量可以使用AVAudioPlayerNode
中volume屬性0~1,也可以使用AVAudioUnitTimePitch
速率:
AVAudioUnitTimePitch
:rate:1/32~32.0
AVAudioUnitVarispeed
: rate:0.25 -> 4.0
AVAudioUnit
繼承AVAudioNode
AVAudioUnitEffect
繼承AVAudioUnit
AVAudioUnitDelay
繼承AVAudioUnitEffect
AVAudioPlayerNode
繼承
AVAudioPlayerNode
播放節(jié)點(diǎn)椒涯,繼承自AVAudioNode
柄沮,實(shí)現(xiàn)了AVAudioMixing
協(xié)議
@available(iOS 8.0, *)
open class AVAudioPlayerNode : AVAudioNode, AVAudioMixing {
public init()
音效框架
iOS的AVAudioUnit提到的音效包括:混響,延遲废岂,失真祖搓,混衡器,變速湖苞,變調(diào)等
按照類型分為Audio effect
和time effect
AVAudioUnitEffect
音效節(jié)點(diǎn)拯欧,繼承自AVAudioUnit
@interface AVAudioUnitEffect : AVAudioUnit
@end
AVAudioUnitDistortion
失真
@available(iOS 8.0, *)
open class AVAudioUnitDistortion : AVAudioUnitEffect {
/** @method loadFactoryPreset:
@abstract Load a distortion preset.
Default: AVAudioUnitDistortionPresetDrumsBitBrush
*/
open func loadFactoryPreset(_ preset: AVAudioUnitDistortionPreset)
/** @property preGain
@abstract 失真前增益
Range: -80 -> 20
Default: -6
Unit: dB
*/
open var preGain: Float
/** 干濕比
Range: 0 (all dry) -> 100 (all distorted)
Default: 50
Unit: Percent
*/
open var wetDryMix: Float
}
AVAudioUnitReverb
混響增強(qiáng)音質(zhì),混響支持預(yù)設(shè)環(huán)境
@available(iOS 8.0, *)
open class AVAudioUnitReverb : AVAudioUnitEffect {
/** @method loadFactoryPreset:
@abstract load a reverb preset
Default: AVAudioUnitReverbPresetMediumHall
*/
open func loadFactoryPreset(_ preset: AVAudioUnitReverbPreset)
/** @property wetDryMix
@abstract
Blend of the wet and dry signals
Range: 0 (all dry) -> 100 (all wet)
Unit: Percent
*/
open var wetDryMix: Float
}
AVAudioUnitDelay
一個(gè)實(shí)現(xiàn)延遲效果的AVAudioUnitEffect,延時(shí)單元按規(guī)定的時(shí)間間隔延時(shí)輸入信號(hào),然后將其與輸入信號(hào)混合
還可以控制滾降袒啼,以模擬的效果,磁帶延遲哈扮。
@available(iOS 8.0, *)
open class AVAudioUnitDelay : AVAudioUnitEffect {
/** 延遲時(shí)間
Range: 0 -> 2
Default: 1
Unit: Seconds
*/
open var delayTime: TimeInterval
/** 衰減系數(shù)
Range: -100 -> 100
Default: 50
Unit: Percent
*/
open var feedback: Float
/** 低通截?cái)? Range: 10 -> (samplerate/2)
Default: 15000
Unit: Hertz
*/
open var lowPassCutoff: Float
/** 干濕比
Range: 0 (all dry) -> 100 (all wet)
Default: 100
Unit: Percent
*/
open var wetDryMix: Float
}
AVAudioUnitTimeEffect
時(shí)間音效節(jié)點(diǎn)纬纪,繼承自AVAudioUnit
- AVAudioUnitTimePitch
變速變調(diào)效果器蚓再,調(diào)整聲音音高
@available(iOS 8.0, *)
open class AVAudioUnitTimePitch : AVAudioUnitTimeEffect {
/** 輸入信號(hào)的播放速率
Range: 1/32 -> 32.0
Default: 1.0
Unit: Generic
*/
open var rate: Float
/** @property pitch
@abstract amount by which the input signal is pitch shifted
@discussion
1 octave = 1200 cents
1 musical semitone = 100 cents
Range: -2400 -> 2400
Default: 0.0
Unit: Cents
*/
open var pitch: Float
}
- AVAudioUnitVarispeed
調(diào)節(jié)播放速率
@available(iOS 8.0, *)
open class AVAudioUnitVarispeed : AVAudioUnitTimeEffect {
//因?yàn)檫@個(gè)單元重新采樣輸入信號(hào),改變播放率也改變音高包各。
/**Range: 0.25 -> 4.0
Default: 1.0
Unit: Generic
*/
open var rate: Float
}