如何播放声音以创建弹奏效果?
我想实现一把简单的吉他。如您所知,吉他有六根弦,当您拨动其中一根弦时,就会发出相应的声音。为了解决这个问题,我在 viewDidLoad
中初始化了六个 avaudioplayers
并使用了一个 mp3 文件。在 touchesMoved
中,我检查哪个字符串被触摸,然后播放相应的声音。但当我将手指从第二弦快速移动到第六弦时,结果不太好。仅播放第一个声音(即第二根弦)。有人可以分享任何想法吗?
I want to implement a simple guitar. As you know, a guitar has six strings and when you pluck one of them, the corresponding sound will play. To address the problem, I initialized six avaudioplayers
in viewDidLoad
and used an mp3 file. In touchesMoved
, I check which string is touched and then play the corresponding sound. But the result is not so good when I move my finger from the second string to the sixth string quickly. Only the first 1st sound plays (i.e. the second string). Can anyone share any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
iOS 在硬件加速播放中仅同时处理一种 MP4/MP3 声音 - 另外一种声音将使用软件解码器播放。
OpenAL 易于使用,文档齐全,并且在 iOS 上可以同时处理 (AFAIK) 32 个语音,没有更大的缺点。
iOS handles only one MP4/MP3 sound concurrently in hardware accelerated playback - additional one would be played using a software decoder.
OpenAL is easy to use, well documented and on iOS handles (AFAIK) 32 voices concurrently without bigger drawbacks.