sunkin351 / fmodaudio Goto Github PK
View Code? Open in Web Editor NEWC# .NET 5+ Wrapper for the Fmod audio library
License: MIT License
C# .NET 5+ Wrapper for the Fmod audio library
License: MIT License
Hello:
I want to try to run the example project in this repo.
I downloaded the repo souce code, unzip it, and open it with Visual Studio 2022.
I set up Example project as the "Set as Startup project", I can see the console window displayed.
But when I press return key, I got the following error:
System.DllNotFoundException: Unable to load DLL 'fmod.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)
at System.Runtime.InteropServices.NativeLibrary.LoadFromPath(String libraryName, Boolean throwOnError)
at System.Runtime.InteropServices.NativeLibrary.Load(String libraryPath)
at FmodAudio.Fmod.<>c.<.cctor>b__35_0() in D:\GitHubRepos\FmodAudio-master\FmodAudio\Fmod.cs:line 114
at System.Lazy1.ViaFactory(LazyThreadSafetyMode mode) at System.Lazy
1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy1.CreateValue() at System.Lazy
1.get_Value()
at FmodAudio.Fmod.get_Library() in D:\GitHubRepos\FmodAudio-master\FmodAudio\Fmod.cs:line 117
at FmodAudio.Fmod.CreateSystem() in D:\GitHubRepos\FmodAudio-master\FmodAudio\Fmod.cs:line 200
at Examples.Base.Example.Initialize() in D:\GitHubRepos\FmodAudio-master\Examples\Base\LibraryExample.cs:line 32
at Examples._3DExample.Initialize() in D:\GitHubRepos\FmodAudio-master\Examples_3D_Example.cs:line 41
at Examples.Program.StartExample(Type exampleType) in D:\GitHubRepos\FmodAudio-master\Examples\Program.cs:line 158
D:\GitHubRepos\FmodAudio-master\Examples\bin\Debug\net5.0\Examples.exe (process 36340) exited with code 0.
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .
Let me know how I can fix this issue.
By the way, I am using Windows 10 (Version 21H2).
Besides, can I use the repo to merge/concat mutliple audio files (aac format)?
Thanks,
Could you please implement some more parameter describing properties from original library class DSP_PARAMETER_DESC? I would much appreciate these:
Below are a couple of snippets in my code.
internal SfxSystem()
{
_fmodSystem = Fmod.CreateSystem();
_fmodSystem.Init(MaxChannels);
}
Channel? channel = _fmodSystem.PlaySound(sfx.Sound);
if (channel is null) throw new Exception("Sound channel wasn't properly created");
if (randomPitch) channel.Pitch = _rng.Range(0.9f, 1.1f);
When I play the same sound repeatedly, what I hear is different depending on the MaxChannels value. If it's 16, I hear the sound effect playing repeatedly just fine. If it's 64, the sound will play normally at first, but it will eventually stop overlapping with itself and only play when the previous sound is done playing. When I set MaxChannels to 128, the sound plays fine for a few seconds and then cuts out completely, leaving me with total silence.
In many cases we want to take the raw values from the object ParameterFFT* fftData = (ParameterFFT*) ptr; and extrapolate them into another format. I didn't feel that it is clear if the values from this call already come processed using Complex number class, or if it has to be done manually.
In the case of manually, the current design recommends we first store the value in the base Complex class (double), then use that as a parameter for the Fmod_Complex (float).
When we get the FFT spectrum using floatspectrum = fftData->GetSpectrum(channel); it's in float, however since Fmod_Complex is made to work with Base Complex, no constructor taking the raw float values, there are some extra operations that probably can be bypassed if the Fmod_Complex class receive some updates such as constructor for taking the float, method for getting Magnitude etc.
Or, am I totally misunderstanding the use of this interface?
Not finding a way in the lib to load Fmod bank files.
In my case, l'd like to use the Bank file with a "Programmer Instrument" so I can load the audio stream on demand during program execution and apply the appropriate audio effects.
Background:
In my case, I'm apply audio effects to dynamically generated speech. I can certainly craft the effects via code but was hoping to take advantage to a Bank file that can be updated outside the code.
Hi, I try to use this lib with .NET6 MAUI
It works fine in windows, but on android it says
System.PlatformNotSupportedException: 'Operation is not supported on this platform.'
Could this be because it can't find the fmod libs for android?
First off, very cool library!
Wondering if you've explored generating the necessary abstractions for FMOD to support a cross platform implementation?
I've seen posts that talk about using the native FMOD Libs in that manner.
Hi, I wanted to ask if there are big changes necessary to get it to work with 2.02.
Right now it throws a version mismatch with the DLLs. If its possible to remove the version check, do you know if it will run with 2.02?
Btw I need 2.02 since I am working on armv8 and 2.01 only supports up to armv6 as far as I know.
I also know about the default included wrapper but I would really like to use yours.
Couldn't find any examples that showed how to do this in the Examples or general source.
I need to access the spectral data e.g. fftDsp.GetParameterData(..) -> to find ParameterFFT.Spectrum, but the examples from the official FMOD source does not match the syntax of the FmodAudio implementation, so I wanted to ask directly.
Any help would be appreciated, thanks.
Just thought I'd let you know that the ADL license doesn't allow static linking, which means that iOS can't be supported without breaching the license. If this is an issue, please contact Firwood Softwar eto discuss purchasing a commercial license/open-source grant similar to those given to OpenTK and Silk.NET.
Not finding the abstractions for channel callbacks.
In the native C# Language, you would implement the call back function this way:
// Define the channel callback function
private static RESULT ChannelCallback(IntPtr channelControlRaw,
CHANNELCONTROL_TYPE controlType,
CHANNELCONTROL_CALLBACK_TYPE callbackType,
IntPtr commandData1,
IntPtr commandData2)
{
if (controlType == CHANNELCONTROL_TYPE.CHANNEL &&
callbackType == CHANNELCONTROL_CALLBACK_TYPE.END)
{
// The sound has reached its end point
// Write your notification logic here
Console.WriteLine("The sound has completed playing.");
return RESULT.OK;
}
return RESULT.OK;
}
Looking through your lib, I'm not finding the corollary types. Of course, you could have implemented this in a different manner like Events but don't see that either.
There's a problem with optaining parameter descriptions of a nested DSP plugin. It should contain 13 parameters but I can get descriptions just for parameter 0 to parameter 10. When I access parameter 11 then exception is thrown. I used FMOD 2.0 and Resonance Audio DSP plugin and I was exploring a nested plugin called Source.
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows;
using FmodAudio;
using FmodAudio.Dsp;
namespace FmodResonanceExperiment
{
public static class ResonanceAudio
{
public static readonly ReadOnlyDictionary<string, Sound> Sounds;
private static readonly Dictionary<string, Sound> _sounds;
private static Plugin _basePlugin;
private static FmodSystem _fmodSystem;
private static DSP _listenerDSP;
private static Plugin _listenerPlugin;
private static ChannelGroup _masterChannelGroup;
private static Plugin _nearFieldPlugin;
private static Plugin _sourcePlugin;
private static ChannelGroup _spatialChannelGroup;
static ResonanceAudio()
{
_sounds = new Dictionary<string, Sound>();
Sounds = new ReadOnlyDictionary<string, Sound>(_sounds);
}/*mtd*/
public static void AddSound(string fileName, bool loop = false)
{
Sound sound = new Sound(fileName, loop, _sourcePlugin, _nearFieldPlugin, _fmodSystem, _spatialChannelGroup);
_sounds[sound.Name] = sound;
}
public static void Free()
=> _fmodSystem.Release();
public static void Init()
{
_fmodSystem = Fmod.CreateSystem();
_fmodSystem.Init(32);
_basePlugin = _fmodSystem.LoadPlugin("resonanceaudio.dll");
_listenerPlugin = _fmodSystem.GetNestedPlugin(_basePlugin, 0);
_listenerDSP = _fmodSystem.CreateDSPByPlugin(_listenerPlugin);
_nearFieldPlugin = _fmodSystem.GetNestedPlugin(_basePlugin, 1);
_sourcePlugin = _fmodSystem.GetNestedPlugin(_basePlugin, 2);
_masterChannelGroup = _fmodSystem.MasterChannelGroup;
_spatialChannelGroup = _fmodSystem.CreateChannelGroup("spatial");
_masterChannelGroup.AddGroup(_spatialChannelGroup, false);
_spatialChannelGroup.AddDSP(ChannelControlDSPIndex.DSPTail, _listenerDSP);
}
public static void ShowPluginsInfo()
{
// Local function
void pluginInfo(DSP plugin)
{
Span<char> pluginName = new Span<char>();
plugin.GetInfo(pluginName, out FmodVersion a, out int b, out int c, out int d);
string msg = $"Displaying parameters of {new string(pluginName)} plugin.{Environment.NewLine} Parameter count: {plugin.ParameterCount.ToString()}{Environment.NewLine}";
for (int paramIndex = 0; paramIndex < plugin.ParameterCount; paramIndex++)
{
ParameterDescription description = plugin.GetParameterInfo(paramIndex);
msg += $"Parameter index: {paramIndex.ToString() + Environment.NewLine}";
msg += $"Name: {description.Name + Environment.NewLine}";
msg += $"Short description: {description.Label + Environment.NewLine}";
}/*for*/
Clipboard.SetText(msg);
MessageBox.Show(msg);
}/*fnc*/
pluginInfo(_fmodSystem.CreateDSPByPlugin(_sourcePlugin));
}/*mtd*/
/*mtd*/
/*mtd*/
} /*cls*/
}/*nspc*/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.