MIT License

项目介绍

Martenfur/FmodForFoxes 是一个托管在 GitHub 上的开源项目,主要使用 C# 编写,采用 MIT License 许可证,目前获得 141 个 Star、17 次 Fork。

仓库全名
Martenfur/FmodForFoxes
开源许可证
MIT License
Star 数
141
Fork 数
17
未关闭 Issue
1

README 摘要

Current FMOD version target: 2.02.25 Join our Discord The time has come. You're finally witnessing a high-level cross-platform C# library, which makes Monogame and FMOD best friends. In case you've come here and the only thing you've understood so far was the doge meme, FMOD is a powerful cross-platform audio engine, which is pretty much the only hope to have any decent audio in Monogame. The catch is - FMOD is…

完整内容见 GitHub 原始 README 或本页 。

常见问题

FmodForFoxes 用什么语言开发?

主要使用 C# 编写,采用 MIT License 许可证,目前有 141 个 Star。

FmodForFoxes 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 FmodForFoxes 的源码?

可以直接克隆仓库:git clone https://github.com/Martenfur/FmodForFoxes.git,默认分支为 develop;安装与运行步骤见仓库 README。

FmodForFoxes 最近还在维护吗?

仓库最近一次更新为 2024年11月22日,当前有 1 个未关闭 Issue;Star 数为 141,可作为社区活跃度的参考。

关于

Cross-platform C# FMOD wrapper.

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

简要分析

热度分
180
价值分
90
活跃状态
活跃

语言占比

C#

Release

README

header

nuget

Current FMOD version target: 2.02.25

Join our Discord

The time has come. You’re finally witnessing a high-level cross-platform C# library, which makes Monogame and FMOD best friends.

In case you’ve come here and the only thing you’ve understood so far was the doge meme, FMOD is a powerful cross-platform audio engine, which is pretty much the only hope to have any decent audio in Monogame.

The catch is - FMOD is written in C++, and unless you’re using Unity, you’re only getting a bare-bones C# wrapper. No tutorials, no setup guides. Only you and DllImport.

send help

That’s why this library exists. It does the tough part for you and provides a basic high-level interface.

Also note that even though the primary target of this library is Monogame, you can easily adapt it for any other C#-based project.

Setup

The initial setup is a little fiddly. Here’s the thing - the FMOD license prohibits me from distributing their libraries in my Nuget package - so you have to download them yourself. But fear not, I’ve put together a detailed guide. With pictures.

Preparations

Visit the FMOD Download page (accessing it requires registration), find the FMOD Studio API downloads and get APIs for Windows, Linux and Android (in case you want all three). If you’re going to set up all three, of course.

NOTE: Current version of the library was tested on FMOD v2.02.19. I really recommend getting it. Later versions will probably also work, but I have no guarantee.

Windows API requires installation, Linux and Android don’t. You can drop them near the Windows API just to have everything in one place.

setup1

Common logic

In your crossplatform project, install 2. Install FmodForFoxes NuGet package. It contains the API.

Windows & Linux

  1. Open your DesktopGL or WindowsDX Monogame project.
  2. Install the NuGet package FmodForFoxes.Desktop. Alternatively, you can plug this repo as a submodule and reference projects directly.
  3. Navigate to your FMOD Windows API installation. From there navigate to \api\core\lib. You will see two directories: x64 and x86. Each one will contain this:

setup2

Out of all the files you’ll need only fmod.dll and fmodL.dll from either x86 or x64 directories (x64 highly recommended). The files engine with L mean that the library supports logging. They are used for debugging andf shoudl not be included into the final release. Copy fmod.dll and fmodL.dll to the root of your DesktopGL or WindowsDX project. Do the same for \api\studio\lib libs and you should end up with it looking like this:

setup3

Make sure dll files will be copied to the output directory:

setup4

  1. Navigate to your FMOD Linux API installation. From there navigate to \api\core\lib. This time you will see four directories:

setup5

You’ll need only x64 or x86.

Each directory contains this:

setup6

You will need all libfmod files from here. Copy fmod files from x86 or x64 directory the root of your project, same as on Windows. Do the same for \api\studio\lib libs and you’ll end up with this:

setup7

NOTE: DesktopGL project works on both Linux and Windows, so you need to add the dll files there too.

Again, make sure all the files you’ve just added will be copied to the output directory:

setup4

And that’s it - you’ve gotten yourself cross-platform desktop FMOD!

Android

  1. Open your Monogame Android project.
  2. Install NuGet package FmodForFoxes.Android. Alternatively, you can plug repo as a submodule and reference projects directly.
  3. Create libs directory in the root of your project.
  4. Navigate to your FMOD Android API installation. From there navigate to \api\core\lib. You will see this:

setup8

  1. Each folder contains libfmod.so and libfmodL.so. Copy everything except .jar file over to your libs directory. Don’t lose this jar, tho. We’ll need it later. Do the same for \api\studio\lib libs and you should end up with this:

setup9

  1. Select each .so file you’ve just copied, open their Properties and set their Build Action to AndroidNativeLibrary.

setup10

  1. Create an NET6 Android Bindings Project.

    setup12

    Remember that jar from earlier? Now you need to copy it into the Jars directory and make sure its Build Action is set to AndroidLibrary.

    setup13

    Now reference Bindings project to your main Android project - and you’re golden.

    setup14

Studio setup

FMOD Studio setup process is exactly the same, but you’ll need to look into studio instead of core directories. It’s also extremely important that ALL your binaries are the exact same version. FMOD doesn’t like version mixup. Foxes don’t like version mixup. Nobody does.

If you still have questions, take a look at the Samples project that has everything set up for all platforms.

Playing some tunes!

So, after you’ve set everything up, it’s time to bop some pops, as kids say these days.

  1. Find a sound file and import it into the Content Pipeline.
  2. Select the sound file and set its Build Action to Copy.

setup11

  1. Include the FmodForFoxes namespace and paste the following code into your Initialize() method:
FmodManager.Init(_nativeLibrary, FMODMode.CoreAndStudio, "Content");

var sound = CoreSystem.LoadStreamedSound("test.mp3");
var channel = sound.Play();
channel.Looping = true;

_nativeLibrary is an instance of INativeFmodLibrary that you have to create separately in your platform-specific projects. Samples project already has this set up.

And lastly, do note that FmodManager has to be properly updated and unloaded. Your main gameloop class has to have this added:

/// <summary>
/// UnloadContent will be called once per game and is the place to unload
/// game-specific content.
/// </summary>
protected override void UnloadContent()
{
	FmodManager.Unload();
}

/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update(GameTime gameTime)
{
	FmodManager.Update();
	base.Update(gameTime);
}
  1. Compile and hope that you (and me) did everything right.

You can also check out the included Samples project.

But what about other platforms?

I’d like to make console versions of the library - but currently I have no ability to do so, and probably won’t have for a long time. As for UWP and Apple platforms, I just don’t care about them enough.

If you want to be a hero and expand the library with any of those platforms yourself - contact me and we’ll figure something out.

This library is licensed under MIT, so you can use it and its code in any shenanigans you want. Free games, commercial games, anything - no payment or royalties required. Just leave a credit. ; - )

But the show’s main star is a bit different. FMOD has its own license, which is much less permissive than mine.

Demo music is provided by Agrofox and FMOD team.

Also big thanque to StinkBrigade who helped a ton in adding FMOD Studio support.

don’t forget to pet your foxes

评论

暂无评论