{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.MediaLive.Types.RemixSettings
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MediaLive.Types.RemixSettings where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaLive.Types.AudioChannelMapping
import qualified Amazonka.Prelude as Prelude

-- | Remix Settings
--
-- /See:/ 'newRemixSettings' smart constructor.
data RemixSettings = RemixSettings'
  { -- | Number of input channels to be used.
    RemixSettings -> Maybe Natural
channelsIn :: Prelude.Maybe Prelude.Natural,
    -- | Number of output channels to be produced. Valid values: 1, 2, 4, 6, 8
    RemixSettings -> Maybe Natural
channelsOut :: Prelude.Maybe Prelude.Natural,
    -- | Mapping of input channels to output channels, with appropriate gain
    -- adjustments.
    RemixSettings -> [AudioChannelMapping]
channelMappings :: [AudioChannelMapping]
  }
  deriving (RemixSettings -> RemixSettings -> Bool
(RemixSettings -> RemixSettings -> Bool)
-> (RemixSettings -> RemixSettings -> Bool) -> Eq RemixSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RemixSettings -> RemixSettings -> Bool
$c/= :: RemixSettings -> RemixSettings -> Bool
== :: RemixSettings -> RemixSettings -> Bool
$c== :: RemixSettings -> RemixSettings -> Bool
Prelude.Eq, ReadPrec [RemixSettings]
ReadPrec RemixSettings
Int -> ReadS RemixSettings
ReadS [RemixSettings]
(Int -> ReadS RemixSettings)
-> ReadS [RemixSettings]
-> ReadPrec RemixSettings
-> ReadPrec [RemixSettings]
-> Read RemixSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RemixSettings]
$creadListPrec :: ReadPrec [RemixSettings]
readPrec :: ReadPrec RemixSettings
$creadPrec :: ReadPrec RemixSettings
readList :: ReadS [RemixSettings]
$creadList :: ReadS [RemixSettings]
readsPrec :: Int -> ReadS RemixSettings
$creadsPrec :: Int -> ReadS RemixSettings
Prelude.Read, Int -> RemixSettings -> ShowS
[RemixSettings] -> ShowS
RemixSettings -> String
(Int -> RemixSettings -> ShowS)
-> (RemixSettings -> String)
-> ([RemixSettings] -> ShowS)
-> Show RemixSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RemixSettings] -> ShowS
$cshowList :: [RemixSettings] -> ShowS
show :: RemixSettings -> String
$cshow :: RemixSettings -> String
showsPrec :: Int -> RemixSettings -> ShowS
$cshowsPrec :: Int -> RemixSettings -> ShowS
Prelude.Show, (forall x. RemixSettings -> Rep RemixSettings x)
-> (forall x. Rep RemixSettings x -> RemixSettings)
-> Generic RemixSettings
forall x. Rep RemixSettings x -> RemixSettings
forall x. RemixSettings -> Rep RemixSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RemixSettings x -> RemixSettings
$cfrom :: forall x. RemixSettings -> Rep RemixSettings x
Prelude.Generic)

-- |
-- Create a value of 'RemixSettings' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'channelsIn', 'remixSettings_channelsIn' - Number of input channels to be used.
--
-- 'channelsOut', 'remixSettings_channelsOut' - Number of output channels to be produced. Valid values: 1, 2, 4, 6, 8
--
-- 'channelMappings', 'remixSettings_channelMappings' - Mapping of input channels to output channels, with appropriate gain
-- adjustments.
newRemixSettings ::
  RemixSettings
newRemixSettings :: RemixSettings
newRemixSettings =
  RemixSettings' :: Maybe Natural
-> Maybe Natural -> [AudioChannelMapping] -> RemixSettings
RemixSettings'
    { $sel:channelsIn:RemixSettings' :: Maybe Natural
channelsIn = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:channelsOut:RemixSettings' :: Maybe Natural
channelsOut = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:channelMappings:RemixSettings' :: [AudioChannelMapping]
channelMappings = [AudioChannelMapping]
forall a. Monoid a => a
Prelude.mempty
    }

-- | Number of input channels to be used.
remixSettings_channelsIn :: Lens.Lens' RemixSettings (Prelude.Maybe Prelude.Natural)
remixSettings_channelsIn :: (Maybe Natural -> f (Maybe Natural))
-> RemixSettings -> f RemixSettings
remixSettings_channelsIn = (RemixSettings -> Maybe Natural)
-> (RemixSettings -> Maybe Natural -> RemixSettings)
-> Lens RemixSettings RemixSettings (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemixSettings' {Maybe Natural
channelsIn :: Maybe Natural
$sel:channelsIn:RemixSettings' :: RemixSettings -> Maybe Natural
channelsIn} -> Maybe Natural
channelsIn) (\s :: RemixSettings
s@RemixSettings' {} Maybe Natural
a -> RemixSettings
s {$sel:channelsIn:RemixSettings' :: Maybe Natural
channelsIn = Maybe Natural
a} :: RemixSettings)

-- | Number of output channels to be produced. Valid values: 1, 2, 4, 6, 8
remixSettings_channelsOut :: Lens.Lens' RemixSettings (Prelude.Maybe Prelude.Natural)
remixSettings_channelsOut :: (Maybe Natural -> f (Maybe Natural))
-> RemixSettings -> f RemixSettings
remixSettings_channelsOut = (RemixSettings -> Maybe Natural)
-> (RemixSettings -> Maybe Natural -> RemixSettings)
-> Lens RemixSettings RemixSettings (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemixSettings' {Maybe Natural
channelsOut :: Maybe Natural
$sel:channelsOut:RemixSettings' :: RemixSettings -> Maybe Natural
channelsOut} -> Maybe Natural
channelsOut) (\s :: RemixSettings
s@RemixSettings' {} Maybe Natural
a -> RemixSettings
s {$sel:channelsOut:RemixSettings' :: Maybe Natural
channelsOut = Maybe Natural
a} :: RemixSettings)

-- | Mapping of input channels to output channels, with appropriate gain
-- adjustments.
remixSettings_channelMappings :: Lens.Lens' RemixSettings [AudioChannelMapping]
remixSettings_channelMappings :: ([AudioChannelMapping] -> f [AudioChannelMapping])
-> RemixSettings -> f RemixSettings
remixSettings_channelMappings = (RemixSettings -> [AudioChannelMapping])
-> (RemixSettings -> [AudioChannelMapping] -> RemixSettings)
-> Lens
     RemixSettings
     RemixSettings
     [AudioChannelMapping]
     [AudioChannelMapping]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemixSettings' {[AudioChannelMapping]
channelMappings :: [AudioChannelMapping]
$sel:channelMappings:RemixSettings' :: RemixSettings -> [AudioChannelMapping]
channelMappings} -> [AudioChannelMapping]
channelMappings) (\s :: RemixSettings
s@RemixSettings' {} [AudioChannelMapping]
a -> RemixSettings
s {$sel:channelMappings:RemixSettings' :: [AudioChannelMapping]
channelMappings = [AudioChannelMapping]
a} :: RemixSettings) (([AudioChannelMapping] -> f [AudioChannelMapping])
 -> RemixSettings -> f RemixSettings)
-> (([AudioChannelMapping] -> f [AudioChannelMapping])
    -> [AudioChannelMapping] -> f [AudioChannelMapping])
-> ([AudioChannelMapping] -> f [AudioChannelMapping])
-> RemixSettings
-> f RemixSettings
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([AudioChannelMapping] -> f [AudioChannelMapping])
-> [AudioChannelMapping] -> f [AudioChannelMapping]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON RemixSettings where
  parseJSON :: Value -> Parser RemixSettings
parseJSON =
    String
-> (Object -> Parser RemixSettings)
-> Value
-> Parser RemixSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RemixSettings"
      ( \Object
x ->
          Maybe Natural
-> Maybe Natural -> [AudioChannelMapping] -> RemixSettings
RemixSettings'
            (Maybe Natural
 -> Maybe Natural -> [AudioChannelMapping] -> RemixSettings)
-> Parser (Maybe Natural)
-> Parser (Maybe Natural -> [AudioChannelMapping] -> RemixSettings)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"channelsIn")
            Parser (Maybe Natural -> [AudioChannelMapping] -> RemixSettings)
-> Parser (Maybe Natural)
-> Parser ([AudioChannelMapping] -> RemixSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"channelsOut")
            Parser ([AudioChannelMapping] -> RemixSettings)
-> Parser [AudioChannelMapping] -> Parser RemixSettings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe [AudioChannelMapping])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"channelMappings"
                            Parser (Maybe [AudioChannelMapping])
-> [AudioChannelMapping] -> Parser [AudioChannelMapping]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [AudioChannelMapping]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable RemixSettings

instance Prelude.NFData RemixSettings

instance Core.ToJSON RemixSettings where
  toJSON :: RemixSettings -> Value
toJSON RemixSettings' {[AudioChannelMapping]
Maybe Natural
channelMappings :: [AudioChannelMapping]
channelsOut :: Maybe Natural
channelsIn :: Maybe Natural
$sel:channelMappings:RemixSettings' :: RemixSettings -> [AudioChannelMapping]
$sel:channelsOut:RemixSettings' :: RemixSettings -> Maybe Natural
$sel:channelsIn:RemixSettings' :: RemixSettings -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"channelsIn" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
channelsIn,
            (Text
"channelsOut" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
channelsOut,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"channelMappings" Text -> [AudioChannelMapping] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [AudioChannelMapping]
channelMappings)
          ]
      )