在移植的C ++ code写的libsndfile Android中我应该怎么使用? [英] What should I use in Android when porting C++ code written with libsndfile?

查看:288
本文介绍了在移植的C ++ code写的libsndfile Android中我应该怎么使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我移植的小(小于10个班),C ++项目到Java。该项目操纵声音文件,并在C ++中使用这是否 libsndfile 。在code包含的东西,如:

I'm porting a small (<10 classes) C++ project to Java. The project manipulates sound files, and in C++ does this using libsndfile. The code includes stuff like:

const int channels = audioFileInfo.channels;
...
sf_readf_double( audioFile, inputBuffer, MAX_ECHO );
...
sf_writef_double( outputAudioFile, &currentAudioBuffer[WINDOW_SIZE * channels], SEGMENTATION_LENGTH );

在Java中,什么是操纵在低级别的声音文件的最好方法是什么?我说的东西,如正火,加入回声等。

In Java, what's the best way to manipulate sound files on a low level? I'm talking about stuff like normalizing, adding echoes etc.

进展报告

在一个有点挖我发现的 javax.sound.sampled中,它看起来像它可能做的工作。

After a bit of digging I've found javax.sound.sampled, which looks like it might do the job.

编辑2 在仔细检查,这是不行的(或至少没有任何可用的方法),因为它依赖于 com.sun.sound 包。

Edit 2 On closer inspection, it won't work (or at least not in any usable way), since it relies on the com.sun.sound package.

修改3 在更多的检查和试验,在 com.sun.sound sun.misc 包在GNU GPLv2的释放,我已经下载了他们到我的项目。已经更名为 javax.sound.sampled中的 imp.javax.sound.sampled ,该项目编译,我可以创造 AudioFileFormat 对象,而无需任何异常被抛出,但。我还没有机会玩多了,但是我会及时向大家发布。

Edit 3 On even more inspection, and experimentation, the com.sun.sound and sun.misc packages are released under the GNU GPLv2, and I've downloaded them into my project. Having renamed javax.sound.sampled to imp.javax.sound.sampled, the project compiles, and I can create AudioFileFormat objects without any exceptions being thrown, yet. I haven't had a chance to play around much yet but I'll keep you updated.

修改4 确定,有些事情似乎与javax.sound.sampled中的工作,有的则没有。例如,调用,如:

Edit 4 Ok, Some things appear to work with javax.sound.sampled, others do not. For example, calls such as:

AudioInputStream stream = AudioSystem.getAudioInputStream(waveFile));

不工作,但是我可以通过做解决这个问题:

do not work, however I can get around this by doing:

WaveFileReader wfr = new WaveFileReader();
AudioInputStream stream = wfr.getAudioInputStream(waveFile);

在一般情况下,呼吁像 AudioSystem.getAudioFileTypes()返回空列表。我可以深入到包和看到它的是与供应商,但我不知如何来解决这个问题。已经得到了我的反对它正确地报告它的编码等,这是令人鼓舞的。

In general, calls to things like AudioSystem.getAudioFileTypes() return empty lists. I can delve into the packages and see it's something to do with providers, but I'm at a loss how to remedy this. Having got my stream object it does report its encoding etc. correctly, which is encouraging.

我目前最大的问题是建立一个剪辑对象。这需要用一个线对象,这通常来自AudioSystem创建。任何人都可以想办法解决此问题?

My big problem at the moment is creating a Clip object. This needs to be created with a Line object, which would normally come from AudioSystem. Can anyone think of a way around this?

推荐答案

libsndfile可以使用原生开发套件编译为Android。一旦你有了编译为Android库,你应该能够使用JNI从Java访问它。

libsndfile can be compiled for Android using the Native Development Kit. Once you have the library compiled for Android, you should be able to use JNI to access it from Java.

这篇关于在移植的C ++ code写的libsndfile Android中我应该怎么使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆