如何在android中使用fmod播放midi文件

发布于 2024-11-29 06:08:58 字数 257 浏览 5 评论 0原文

我正在尝试使用 fmod 播放 midi 文件。但有一个错误说:找不到插件所需的资源(即用于MIDI播放的DLS文件)

我已经搜索了类似问题的结果,并参考了fmod.h文件。似乎我需要一个名为“gs_instrument.dls”的文件,但我在我的 Mac 和 Android 模拟器文件系统中找不到它。我也在网上搜索了资源,也没有结果。

那么如果我想在android中使用fmod播放midi文件该怎么办呢?

希望你能帮助我!

谢谢!

I am trying to play midi file using fmod. But there is an error says that :a resource that the plugin requires cannot be found,(ie the DLS file for MIDI playback)

I have searched results for problems like this,and referred to the fmod.h files. It seems that I need a file named "gs_instrument.dls" but I cannot find it in my mac as well as the android simulator filesystem. I have also searched the resources in the web,no result either.

So what should I do if I want to play midi file in android using fmod.

Hope you can help me!

Thanks!

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

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

发布评论

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

评论(3

抱猫软卧 2024-12-06 06:08:58

我不知道 fmod,但 Android 可以直接播放 MIDI 文件。这是对我有用的简化版本:

MediaPlayer mediaPlayer = new MediaPlayer();
File f = [... my MIDI file ...];
FileInputStream fis = new FileInputStream(f);
FileDescriptor fd = fis.getFD();
mediaPlayer.setDataSource( fd );
mediaPlayer.prepare();
mediaPlayer.start();

I don't know about fmod, but Android can play MIDI files right out of the box. Here's a simplified version of what works for me:

MediaPlayer mediaPlayer = new MediaPlayer();
File f = [... my MIDI file ...];
FileInputStream fis = new FileInputStream(f);
FileDescriptor fd = fis.getFD();
mediaPlayer.setDataSource( fd );
mediaPlayer.prepare();
mediaPlayer.start();
爱你不解释 2024-12-06 06:08:58

您可以使用传递到 System::createSound 的 FMOD_CREATESOUNDEXINFO 结构的 dlsname 成员来指定 DLS 文件的位置。

您必须自己提供实际文件并将其放在 SD 卡上,以便您可以传递它的位置。在 Windows 上,默认 DLS 文件位于“C:\Windows\System32\drivers\gm.dls”或“C:\Windows\System32\drivers\etc\gm.dls”。或者在 Mac 上,它位于“/System/Library/Components/CoreAudio.component/Contents/Resources/gs_instruments.dls”。话虽如此,我无法谈论在 Android 项目中使用这些文件的合法性,您可能需要从其他地方获取您自己的“免费”dls 文件。

You specify the location of the DLS file with the dlsname member of the FMOD_CREATESOUNDEXINFO structure passed into System::createSound.

You must provide the actual file yourself and put it on the sdcard so you can pass in the location of it. On Windows the default DLS file is located at "C:\Windows\System32\drivers\gm.dls" or "C:\Windows\System32\drivers\etc\gm.dls". Alternatively on Mac it is located at "/System/Library/Components/CoreAudio.component/Contents/Resources/gs_instruments.dls". This being said I cannot speak to the legality of using these files in an Android project, you may need to source your own "free" dls file from somewhere else.

守不住的情 2024-12-06 06:08:58

你可以像这样使用。您可以在要播放 midi 文件的地方调用以下方法。

public void  myRingCtone()
        {
            Uri path = Uri.parse("android.resource://com.PackageName/raw/MIDI_RingToneName");
            RingtoneManager.setActualDefaultRingtoneUri(getApplicationContext(), 
                                                            RingtoneManager.TYPE_RINGTONE, path);
            Log .i("TESTT", "Ringtone Set to Resource: "+ path.toString());
            RingtoneManager.getRingtone(getApplicationContext(), path).play();
        }

You can use like this. You can call following method where you want to play midi file.

public void  myRingCtone()
        {
            Uri path = Uri.parse("android.resource://com.PackageName/raw/MIDI_RingToneName");
            RingtoneManager.setActualDefaultRingtoneUri(getApplicationContext(), 
                                                            RingtoneManager.TYPE_RINGTONE, path);
            Log .i("TESTT", "Ringtone Set to Resource: "+ path.toString());
            RingtoneManager.getRingtone(getApplicationContext(), path).play();
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文