JAJ.Packages.MiniAudioEx
1.7.2
dotnet add package JAJ.Packages.MiniAudioEx --version 1.7.2
NuGet\Install-Package JAJ.Packages.MiniAudioEx -Version 1.7.2
<PackageReference Include="JAJ.Packages.MiniAudioEx" Version="1.7.2" />
paket add JAJ.Packages.MiniAudioEx --version 1.7.2
#r "nuget: JAJ.Packages.MiniAudioEx, 1.7.2"
// Install JAJ.Packages.MiniAudioEx as a Cake Addin #addin nuget:?package=JAJ.Packages.MiniAudioEx&version=1.7.2 // Install JAJ.Packages.MiniAudioEx as a Cake Tool #tool nuget:?package=JAJ.Packages.MiniAudioEx&version=1.7.2
MiniAudioExNET
A .NET wrapper for MiniAudioEx. MiniAudioEx is a a modified version of MiniAudio, see this repository. The goal of MiniAudioExNET is to make it easy to add audio playback to .NET applications. I've tried several libraries in the past and none of them could offer all of the things I was looking for:
- Easy to set up and interact with.
- Spatial audio.
- Cross platform.
- A permissive license.
This library ticks all these boxes. There are some (in my opinion) minor things missing such as more audio format decoders, but at least 3 widely used formats are supported which is sufficient for my needs. If you would like to have support for more formats, then please make your request here.
Features
- Playback and decoding of various audio formats such as WAV/MP3/FLAC.
- Stream audio from disk or from memory.
- Callbacks for effects processing and generating audio.
- Spatial properties like doppler effect, pitching, distance attenuation and panning.
- Utilities for audio generation.
Platforms
MiniAudio was designed to work on every major platform, however I do not have a Mac so I can not build a library for Mac OS. As a result only Windows and Linux libraries are currently available.
Installation
dotnet add package JAJ.Packages.MiniAudioEx --version 1.7.2
Changes in 1.7.2
- Add global device data processing callback.
Changes in 1.7.1
- Reuse memory if multiple audio clips use the same data.
Changes in 1.7.0
- Renamed
MiniAudioExNET
namespace toMiniAudioEx
. - Renamed
MiniAudioEx
class toAudioContext
. - Got rid of
Span<T>
in favor ofAudioBuffer<T>
.
General gotchas
- Reuse audio clips. If you have loaded an AudioClip from memory, then the library allocates memory that the garbage collector doesn't free. All memory is freed after calling AudioContext.Deinitialize. It is perfectly fine to reuse audio clips across multiple audio sources, so you don't have to load multiple clips with the same sound. A good strategy is to store your audio clips in an array or a list for the lifetime of your application.
- Call AudioContext.Update from your main thread loop. This method calculates a delta time, and is responsible for moving messages from the audio thread to the main thread. If not called (regularly), the
End
callback will never be able to run. - The
Process
andRead
event run on a separate thread as well. You should not call any MiniAudioEx API functions from these callbacks. - It can happen that I change things over the course of time. The examples always reflect the use of the API as of the latest available Nuget package so please refer to them if things are different.
Basic Example
Initializing MiniAudioEx and playing audio from a file on disk.
using System;
using System.Threading;
using MiniAudioEx;
namespace MiniAudioExExample
{
class Program
{
static readonly uint SAMPLE_RATE = 44100;
static readonly uint CHANNELS = 2;
static void Main(string[] args)
{
Console.CancelKeyPress += OnCancelKeyPress;
AudioContext.Initialize(SAMPLE_RATE, CHANNELS);
AudioSource source = new AudioSource();
AudioClip clip = new AudioClip("some_audio.mp3");
source.Play(clip);
while(true)
{
AudioContext.Update();
Thread.Sleep(10);
}
}
static void OnCancelKeyPress(object sender, ConsoleCancelEventArgs e)
{
AudioContext.Deinitialize();
}
}
}
See links below for more examples. These use the AudioApp
class which is suitable for simple console based applications.
Playing audio from a file on disk
Using the 'Read' callback to generate sound
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
-
net7.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on JAJ.Packages.MiniAudioEx:
Package | Downloads |
---|---|
Bliss
A fast, Cross-platform .NET 8 C# 12 Render Framework. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.7.2 | 270 | 7/25/2024 |
1.7.1 | 123 | 5/27/2024 |
1.7.0 | 120 | 5/22/2024 |
1.6.4 | 119 | 5/20/2024 |
1.6.3 | 125 | 5/19/2024 |
1.6.2 | 111 | 5/18/2024 |
1.6.1 | 125 | 5/17/2024 |
1.6.0 | 119 | 5/16/2024 |
1.5.4 | 119 | 5/15/2024 |
1.5.3 | 111 | 5/15/2024 |
1.5.2 | 110 | 5/13/2024 |
1.5.1 | 97 | 5/13/2024 |
1.5.0 | 107 | 5/13/2024 |
1.4.2 | 113 | 5/12/2024 |
1.3.0 | 108 | 5/11/2024 |
1.2.0 | 113 | 5/10/2024 |
1.1.0 | 116 | 5/9/2024 |
1.0.3 | 127 | 4/24/2024 |
1.0.2 | 127 | 4/23/2024 |
1.0.1 | 138 | 2/3/2024 |
1.0.0 | 199 | 12/16/2023 |