-- Copyright 2013 Evan Laforge
-- This program is distributed under the terms of the GNU General Public
-- License 3.0, see COPYING or http://www.gnu.org/licenses/gpl-3.0.txt

module User.Elaforge.Config.Tammananny where
import qualified Cmd.Cmd as Cmd
import qualified App.StaticConfig as StaticConfig
import Global


midi_config :: Cmd.InstrumentDb -> StaticConfig.Midi
midi_config :: InstrumentDb -> Midi
midi_config InstrumentDb
_db = StaticConfig.Midi
    { rdev_map :: Map ReadDevice ReadDevice
rdev_map = [(Text, Text)] -> Map ReadDevice ReadDevice
StaticConfig.make_rdev_map [(Text, Text)]
rdev_map
    , wdev_map :: Map WriteDevice WriteDevice
wdev_map = [(Text, Text)] -> Map WriteDevice WriteDevice
StaticConfig.make_wdev_map [(Text, Text)]
wdev_map
    , read_devices :: Set ReadDevice
read_devices = [Text] -> Set ReadDevice
StaticConfig.make_read_devices [Text]
read_devices
    }

-- | jack1 copies the port name over from ALSA and then truncates it.
-- jack2 just hardcodes to midi_capture_n, which is pretty useless since it
-- depends what order you plugged the things in.
alsa_input :: Text -> Int -> Int -> Text
alsa_input :: Text -> Int -> Int -> Text
alsa_input Text
name Int
device Int
sub =
    Text
"in-hw-" forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> Text
showt Int
device forall a. Semigroup a => a -> a -> a
<> Text
"-0-" forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> Text
showt Int
sub forall a. Semigroup a => a -> a -> a
<> Text
"-" forall a. Semigroup a => a -> a -> a
<> Text
name

alsa_output :: Text -> Int -> Int -> Text
alsa_output :: Text -> Int -> Int -> Text
alsa_output Text
name Int
device Int
sub =
    Text
"out-hw-" forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> Text
showt Int
device forall a. Semigroup a => a -> a -> a
<> Text
"-0-" forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> Text
showt Int
sub forall a. Semigroup a => a -> a -> a
<> Text
"-" forall a. Semigroup a => a -> a -> a
<> Text
name

tapco_name :: Text
tapco_name :: Text
tapco_name = Text
"Tapco-Link-MIDI-USB-Ver-2-2-MID"

tapco_in, tapco_out :: Int -> Text
tapco_in :: Int -> Text
tapco_in Int
n = Text -> Int -> Int -> Text
alsa_input Text
tapco_name Int
3 (Int
nforall a. Num a => a -> a -> a
-Int
1)
tapco_out :: Int -> Text
tapco_out Int
n = Text -> Int -> Int -> Text
alsa_output Text
tapco_name Int
3 (Int
nforall a. Num a => a -> a -> a
-Int
1)

wdev_map :: [(Text, Text)]
wdev_map :: [(Text, Text)]
wdev_map =
    [ (Text
"z1", Int -> Text
tapco Int
1)
    , (Text
"vl1", Int -> Text
tapco Int
2)
    , (Text
"morph", Int -> Text
tapco Int
2)
    , (Text
"pc2496", Int -> Text
tapco Int
3)
    , (Text
"capybara", Int -> Text
tapco Int
4)
    ]
    where tapco :: Int -> Text
tapco = Int -> Text
tapco_out

rdev_map :: [(Text, Text)]
rdev_map :: [(Text, Text)]
rdev_map =
    [ (Int -> Text
tapco Int
1, Text
"z1")
    , (Int -> Text
tapco Int
2, Text
"vl1")
    , (Int -> Text
tapco Int
3, Text
"morpheus")
    , (Int -> Text
tapco Int
4, Text
"continuum")
    ]
    where tapco :: Int -> Text
tapco = Int -> Text
tapco_in

read_devices :: [Text]
read_devices :: [Text]
read_devices = Text -> Int -> Int -> Text
alsa_input Text
"USB-Oxygen-8-v2-MIDI-1" Int
2 Int
0 forall a. a -> [a] -> [a]
: forall a b. (a -> b) -> [a] -> [b]
map Int -> Text
tapco [Int
1..Int
4]
    where tapco :: Int -> Text
tapco = Int -> Text
tapco_in