Code Monkey home page Code Monkey logo

Comments (7)

potato04 avatar potato04 commented on June 16, 2024 1

你好,我看了下findMaxAmplitude修改之后的代码,你的目的是想避免 endIndex < startIndex
造成这个问题的原因呢,是因为参数bandWidth与实际的bandWidth不一致。
bandWidth = Float(buffer.format.sampleRate) / Float(self.fftSize),也就是说self.fftSize错了
总之,我们只要确保 RealtimeAnalyzer对象中的fftSize 和 传给analysebufferframeLength是一致的,就不会出问题。
以上就是根本解决的办法。

from audiospectrum.

potato04 avatar potato04 commented on June 16, 2024

你好,我试了一下并没有发现什么问题,动画能正常显示呢。测试环境是 Xcode 10.2.1 模拟器是 iPhone XS 12.2

from audiospectrum.

protosse avatar protosse commented on June 16, 2024

你好,我试了一下并没有发现什么问题,动画能正常显示呢。测试环境是 Xcode 10.2.1 模拟器是 iPhone XS 12.2

你好,我试了下直接播放本地文件是没问题的,我是在线播放fetch AVAudioPCMBuffer的,但是这样得到的buffer的format.sampleRate和前面的不一样,前面的是48000,后面的是32000。
我再好好看下了。

from audiospectrum.

potato04 avatar potato04 commented on June 16, 2024

如果方便的话提供你的代码我们来一起研究下

from audiospectrum.

protosse avatar protosse commented on June 16, 2024

AudioSpectrum02-final.zip
大致改了下

from audiospectrum.

potato04 avatar potato04 commented on June 16, 2024

抱歉,这么晚才回复。我下载代码并运行了,大概听了10多分钟吧,还是没能复现你所说的那个问题
不过,你在buffer的回调函数函数里面的这个语句可以删除:

buffer.frameLength = AVAudioFrameCount(2048)

因为你换了播放器之后,这里的设置肯定就没必要了。这里的buffer.frameLength都是4096,我暂时没找到这个播放器可以设置 tap 这个buffer大小的地方。

from audiospectrum.

protosse avatar protosse commented on June 16, 2024

抱歉,我也现在才看到。没崩是因为findMaxAmplitude这个函数那里的代码我已经修改了
image
怪我没先说,上面注释的代码是之前的。虽说崩溃原因是数组越界,但是我觉得这样并不是从根本解决。

from audiospectrum.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.