Cross Platform Application to allow control with a MIDI controller
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
1002 B

// Author: Gockner, Simon
// Created: 2021-04-08
// Copyright(c) 2021 SimonG. All Rights Reserved.
using System.Collections.Generic;
using System.Linq;
using Lib.Audio.Factories;
using Lib.Audio.Interfaces;
using NAudio.CoreAudioApi;
namespace Lib.Audio
{
public class ControllableCollector : IControllableCollector
{
private readonly IControllableFactory _controllableFactory;
public ControllableCollector(IControllableFactory controllableFactory) => _controllableFactory = controllableFactory;
public List<IControllable> Controllables => CreateControllables();
private List<IControllable> CreateControllables()
{
MMDeviceEnumerator deviceEnumerator = new();
MMDeviceCollection? audioDevices = deviceEnumerator.EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active);
return audioDevices.Select(a => _controllableFactory.Create(a.AudioSessionManager.AudioSessionControl)).ToList();
}
}
}