{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MediaLive.Types.RemixSettings where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $sel:channelsIn:RemixSettings' :: Maybe Natural
channelsIn = forall a. Maybe a
Prelude.Nothing,
      $sel:channelsOut:RemixSettings' :: Maybe Natural
channelsOut = forall a. Maybe a
Prelude.Nothing,
      $sel:channelMappings:RemixSettings' :: [AudioChannelMapping]
channelMappings = 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 :: Lens' RemixSettings (Maybe Natural)
remixSettings_channelsIn = 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 :: Lens' RemixSettings (Maybe Natural)
remixSettings_channelsOut = 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 :: Lens' RemixSettings [AudioChannelMapping]
remixSettings_channelMappings = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable RemixSettings where
  hashWithSalt :: Int -> RemixSettings -> Int
hashWithSalt Int
_salt 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
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
channelsIn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
channelsOut
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [AudioChannelMapping]
channelMappings

instance Prelude.NFData RemixSettings where
  rnf :: RemixSettings -> ()
rnf 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
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
channelsIn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
channelsOut
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [AudioChannelMapping]
channelMappings

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"channelsIn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
channelsIn,
            (Key
"channelsOut" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
channelsOut,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"channelMappings" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [AudioChannelMapping]
channelMappings)
          ]
      )