Soundtouch bpm iPhone

发布于 2024-12-17 16:03:24 字数 120 浏览 2 评论 0原文

我正在尝试集成一种机制来计算 iPod 库(也在 iphone 上)中歌曲的 BPM。 在网上搜索我发现最常用和最可靠的库来做这件事是soundtouch。有人有这个库的经验吗?让它在iPhone硬件上运行在计算上是可能的吗?

I'm trying to integrate a mechanism to calculate the BPM of the song in the iPod library(also on iphone).
Searching on the web I found that the most used and reliable libraries to do this things is soundtouch.Anyone has experience with this library? It is computationally possible to make it run on the iPhone hardware?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

洛阳烟雨空心柳 2024-12-24 16:03:24

我最近成功使用了 soundtouch 库的 BPMDetect 类中的代码。最初在C++上编译它,后来将代码翻译为C#,最近我一直在Android上使用C++代码 通过 JNI 应用程序。我不太熟悉 iOS 中的开发,但我几乎可以肯定您正在尝试做的事情是可能的。

您应该使用 soundtouch 源代码中的唯一文件如下:

C++ 文件

  • BPMDetect.cpp
  • FIFOSampleBuffer.cpp
  • PeakFinder.cpp

头文件

  • BPMDetect.h
  • FIFOSampleBuffer.h
  • FIFOSamplePipe.h
  • PeakFinder.h
  • soundtouch_config.h
  • STTypes.h

至少这些是我必须使用的唯一文件使其发挥作用。

BPMDetect 类通过其 inputSamples() 方法接收原始样本,即使整个文件尚未加载到其缓冲区中,它也能够计算 bpm 值。我发现这些中间值与加载整个文件后获得的值不同,根据我的经验,后者更准确。

希望这有帮助。

编辑:

在评论中解释这是一个复杂的过程,因此我将编辑答案。

其要点是您需要 Android 应用程序来使用本机代码。为此,您需要使用 Android NDK 工具集。

这将为您留下能够处理原始声音数据的本机代码,但您仍然需要从声音文件中获取数据,我认为您可以通过多种方式执行此操作。我这样做的方式是使用 Android 的 FMOD 库,这是一个很好的例子即:Android 版 FMOD

假设您在 C 代码中声明了这样的方法:

void Java_your_package_YourClassName_cPlay(JNIEnv *env, jobject thiz)
{
    sound->play();
}

在 Android 应用程序上,您按以下方式使用本机方法:

public class Sound {
    // Native method declaration
    private native void cPlay();

    public void play()
    {
        cPlay();
    }
}

为了使用更友好的 API,您可以围绕这些函数调用创建包装器。

我将我使用的本机 C 代码放在 此处 中。

希望这有帮助。

I have recently been using the code from the BPMDetect class of the soundtouch library succesfully. Initially compiled it on C++, later on translated the code to C# and lately I've been using the C++ code on an Android app through JNI. I'm not really familiar with development in iOS but I'm almost certain that it is possible what you're trying to do.

The only files you should use from the soundtouch source code are the following:

C++ files

  • BPMDetect.cpp
  • FIFOSampleBuffer.cpp
  • PeakFinder.cpp

Header files

  • BPMDetect.h
  • FIFOSampleBuffer.h
  • FIFOSamplePipe.h
  • PeakFinder.h
  • soundtouch_config.h
  • STTypes.h

At least these are the only ones I had to use to make it work.

The BPMDetect class recieves raw samples through its inputSamples() method, it's capable of calculating a bpm value even when the whole file is not yet loaded into its buffer. I have found that these intermediate values differ from the one obtained once the whole file is loaded, which is more accurate, in my experience.

Hope this helps.

EDIT:

It's a kind of complex process to explain in a comment so I'm going to edit the answer.

The gist of it is that you need your android app to consume native code. In order to do that, you need to compile the files listed above from the soundtouch library with the Android NDK toolset.

That will leave you with native code that will be able to process raw sound data, but you still need to get the data from the sound file, which you can do several ways, I think. The way I was doing it was using the FMOD library for Android, here's a nice example for that: FMOD for Android.

Supposing you declared a method like this in your C code:

void Java_your_package_YourClassName_cPlay(JNIEnv *env, jobject thiz)
{
    sound->play();
}

On the Android app you use your native methods in the following way:

public class Sound {
    // Native method declaration
    private native void cPlay();

    public void play()
    {
        cPlay();
    }
}

In order to have a friendlier API to work with you can create wrappers around these function calls.

I put the native C code I was using in a gist here.

Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文