我正在使用return realm.where(Conversation.class)
.equalTo("id",conversationId)
.findFirstAsync() // maybe use findAllAsync instead?
.asFlowable()
.filter(RealmResults::isLoaded)
.switchMap(conversation ->
conversation.getMessages().where().findAllSortedAsync("receivedDate", Sort.DESCENDING)
.asFlowable()
.filter(RealmResults::isLoaded));
而我正试图以16000Hz输出AVAudioEngine
,但我似乎无法让它工作。这就是我正在做的事情:
.pcmFormatInt16
如上所述,当我访问缓冲区时,它总是全0,静默。
答案 0 :(得分:1)
AVAudioEngine不支持更改采样率。 您可以使用AVAudioConverter来更改样本率
let inputFormat = input.outputFormat(forBus: 0)
let recordingFormat = AVAudioFormat(commonFormat: .pcmFormatInt16, sampleRate: 16000.0, channels: 1, interleaved: true)
converter = AVAudioConverter(from: inputFormat, to: recordingFormat)
mixer.installTap(onBus: 0, bufferSize: 2048, format: inputFormat) { [weak self] (buffer, _) in
let convertedBuffer = self?.converter.convertBuffer(additionalBuffer: buffer)
}