objective-c - 使用 AVAudioEngine for MPMediaItem 音质不佳
问题描述
我正在尝试使用 AVAudioEngine 将过滤器应用于从苹果音乐库中获取的声音:
首先,我得到 AVAudioFile:
NSURL *assetURL = [song valueForProperty:MPMediaItemPropertyAssetURL];
NSError *error;
AVAudioFile *audioFile = [[AVAudioFile alloc] initForReading:assetURL error:&error];
然后我尝试将其转换为 AVAudioPCMBuffer:
AVAudioFormat *format = audioFile.processingFormat;
AVAudioFrameCount capacity = (AVAudioFrameCount)audioFile.length;
AVAudioPCMBuffer *buffer = [[AVAudioPCMBuffer alloc] initWithPCMFormat:format frameCapacity:capacity];
[audioFile readIntoBuffer:buffer error:nil];
最后我尝试使用 AVAudioEngine 连接所有内容并安排缓冲区:
[engine attachNode:audioEQ];
[engine attachNode:avHighPassFilter];
[engine attachNode:audioPlayerNode];
[engine connect:audioPlayerNode to:mainMixer format:[mainMixer outputFormatForBus:0]];
[engine connect: audioPlayerNode to:audioEQ format:buffer.format];
[engine connect: audioEQ to:avHighPassFilter format:buffer.format];
[engine connect:avHighPassFilter to:mainMixer format:buffer.format];
[audioPlayerNode scheduleBuffer:buffer atTime:nil options:AVAudioPlayerNodeBufferLoops completionHandler:nil];
它播放这首歌,但质量很差。当我尝试先将 MPMediaItem 导出到我的文档目录时,声音质量稍微好一点,但仍然不够好。
谁能帮我解决它?“com.apple.m4a-audio”格式有问题吗?
解决方案
推荐阅读
- oracle - Oracle 18c 监听器无法启动
- docker - 在 EC2 实例上设置 docker 注册表
- java - Java 9 中的 2 个依赖项中的 SLF4J
- firebase - 找不到 Firebase 导入导出 JSON
- excel - 在 Pandas 中转换数据框
- stata - 在Stata中复制最佳对数伪似然
- javascript - JavaScript 密码生成器数值问题
- azure-sqldw - Azure SQLDW 中的 tempdb 使用情况
- python - 如何使用 Dockerfile 访问我的下载文件夹?
- airflow - CeleryExecutor 或 LocalExecutor 用于周期性的大容量和可能长时间运行的任务?