ttuegel / alsa-mixer

Haskell bindings to the ALSA mixer API
BSD 3-Clause "New" or "Revised" License
7 stars 3 forks source link

A function that finds a mixer control by index and name #9

Open crocket opened 4 years ago

crocket commented 4 years ago

My USB DAC exposes two controls with the same name but different index numbers to ALSA.

I created the following function to find a mixer control by index and name.

import qualified Sound.ALSA.Mixer as AM

getMixerControl :: AM.Mixer -> AM.CUInt -> String -> IO (Maybe AM.Control)
getMixerControl m i n = do
  cs <- AM.controls m
  return $ foldr helper Nothing cs
  where helper c cs =
          if (AM.index c == i) && (AM.name c == n)
          then Just c
          else cs