Skip to content

Instantly share code, notes, and snippets.

@danielcweber
danielcweber / AlsaVolumeControl.cs
Last active May 18, 2020 17:35
Based on the answer at https://stackoverflow.com/questions/6787318/set-alsa-master-volume-from-c-code/6787957#6787957 and the native interop code from alsa-sharp (https://github.com/atsushieno/alsa-sharp/) by @atsushieno, the code in this gist presents a solution for "how to set the volume on Linux in C# through Alsa" that works for me.
using System;
using System.Runtime.InteropServices;
namespace Alsa
{
public sealed class VolumeControl : IDisposable
{
private readonly long _min;
private readonly long _max;
private readonly IntPtr _sid;