{-# 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.MediaConvert.Types.ChannelMapping
-- 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.MediaConvert.Types.ChannelMapping where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaConvert.Types.OutputChannelMapping
import qualified Amazonka.Prelude as Prelude

-- | Channel mapping (ChannelMapping) contains the group of fields that hold
-- the remixing value for each channel, in dB. Specify remix values to
-- indicate how much of the content from your input audio channel you want
-- in your output audio channels. Each instance of the InputChannels or
-- InputChannelsFineTune array specifies these values for one output
-- channel. Use one instance of this array for each output channel. In the
-- console, each array corresponds to a column in the graphical depiction
-- of the mapping matrix. The rows of the graphical matrix correspond to
-- input channels. Valid values are within the range from -60 (mute)
-- through 6. A setting of 0 passes the input channel unchanged to the
-- output channel (no attenuation or amplification). Use InputChannels or
-- InputChannelsFineTune to specify your remix values. Don\'t use both.
--
-- /See:/ 'newChannelMapping' smart constructor.
data ChannelMapping = ChannelMapping'
  { -- | In your JSON job specification, include one child of OutputChannels for
    -- each audio channel that you want in your output. Each child should
    -- contain one instance of InputChannels or InputChannelsFineTune.
    ChannelMapping -> Maybe [OutputChannelMapping]
outputChannels :: Prelude.Maybe [OutputChannelMapping]
  }
  deriving (ChannelMapping -> ChannelMapping -> Bool
(ChannelMapping -> ChannelMapping -> Bool)
-> (ChannelMapping -> ChannelMapping -> Bool) -> Eq ChannelMapping
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChannelMapping -> ChannelMapping -> Bool
$c/= :: ChannelMapping -> ChannelMapping -> Bool
== :: ChannelMapping -> ChannelMapping -> Bool
$c== :: ChannelMapping -> ChannelMapping -> Bool
Prelude.Eq, ReadPrec [ChannelMapping]
ReadPrec ChannelMapping
Int -> ReadS ChannelMapping
ReadS [ChannelMapping]
(Int -> ReadS ChannelMapping)
-> ReadS [ChannelMapping]
-> ReadPrec ChannelMapping
-> ReadPrec [ChannelMapping]
-> Read ChannelMapping
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ChannelMapping]
$creadListPrec :: ReadPrec [ChannelMapping]
readPrec :: ReadPrec ChannelMapping
$creadPrec :: ReadPrec ChannelMapping
readList :: ReadS [ChannelMapping]
$creadList :: ReadS [ChannelMapping]
readsPrec :: Int -> ReadS ChannelMapping
$creadsPrec :: Int -> ReadS ChannelMapping
Prelude.Read, Int -> ChannelMapping -> ShowS
[ChannelMapping] -> ShowS
ChannelMapping -> String
(Int -> ChannelMapping -> ShowS)
-> (ChannelMapping -> String)
-> ([ChannelMapping] -> ShowS)
-> Show ChannelMapping
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChannelMapping] -> ShowS
$cshowList :: [ChannelMapping] -> ShowS
show :: ChannelMapping -> String
$cshow :: ChannelMapping -> String
showsPrec :: Int -> ChannelMapping -> ShowS
$cshowsPrec :: Int -> ChannelMapping -> ShowS
Prelude.Show, (forall x. ChannelMapping -> Rep ChannelMapping x)
-> (forall x. Rep ChannelMapping x -> ChannelMapping)
-> Generic ChannelMapping
forall x. Rep ChannelMapping x -> ChannelMapping
forall x. ChannelMapping -> Rep ChannelMapping x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ChannelMapping x -> ChannelMapping
$cfrom :: forall x. ChannelMapping -> Rep ChannelMapping x
Prelude.Generic)

-- |
-- Create a value of 'ChannelMapping' 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:
--
-- 'outputChannels', 'channelMapping_outputChannels' - In your JSON job specification, include one child of OutputChannels for
-- each audio channel that you want in your output. Each child should
-- contain one instance of InputChannels or InputChannelsFineTune.
newChannelMapping ::
  ChannelMapping
newChannelMapping :: ChannelMapping
newChannelMapping =
  ChannelMapping' :: Maybe [OutputChannelMapping] -> ChannelMapping
ChannelMapping' {$sel:outputChannels:ChannelMapping' :: Maybe [OutputChannelMapping]
outputChannels = Maybe [OutputChannelMapping]
forall a. Maybe a
Prelude.Nothing}

-- | In your JSON job specification, include one child of OutputChannels for
-- each audio channel that you want in your output. Each child should
-- contain one instance of InputChannels or InputChannelsFineTune.
channelMapping_outputChannels :: Lens.Lens' ChannelMapping (Prelude.Maybe [OutputChannelMapping])
channelMapping_outputChannels :: (Maybe [OutputChannelMapping] -> f (Maybe [OutputChannelMapping]))
-> ChannelMapping -> f ChannelMapping
channelMapping_outputChannels = (ChannelMapping -> Maybe [OutputChannelMapping])
-> (ChannelMapping
    -> Maybe [OutputChannelMapping] -> ChannelMapping)
-> Lens
     ChannelMapping
     ChannelMapping
     (Maybe [OutputChannelMapping])
     (Maybe [OutputChannelMapping])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelMapping' {Maybe [OutputChannelMapping]
outputChannels :: Maybe [OutputChannelMapping]
$sel:outputChannels:ChannelMapping' :: ChannelMapping -> Maybe [OutputChannelMapping]
outputChannels} -> Maybe [OutputChannelMapping]
outputChannels) (\s :: ChannelMapping
s@ChannelMapping' {} Maybe [OutputChannelMapping]
a -> ChannelMapping
s {$sel:outputChannels:ChannelMapping' :: Maybe [OutputChannelMapping]
outputChannels = Maybe [OutputChannelMapping]
a} :: ChannelMapping) ((Maybe [OutputChannelMapping] -> f (Maybe [OutputChannelMapping]))
 -> ChannelMapping -> f ChannelMapping)
-> ((Maybe [OutputChannelMapping]
     -> f (Maybe [OutputChannelMapping]))
    -> Maybe [OutputChannelMapping]
    -> f (Maybe [OutputChannelMapping]))
-> (Maybe [OutputChannelMapping]
    -> f (Maybe [OutputChannelMapping]))
-> ChannelMapping
-> f ChannelMapping
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [OutputChannelMapping]
  [OutputChannelMapping]
  [OutputChannelMapping]
  [OutputChannelMapping]
-> Iso
     (Maybe [OutputChannelMapping])
     (Maybe [OutputChannelMapping])
     (Maybe [OutputChannelMapping])
     (Maybe [OutputChannelMapping])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [OutputChannelMapping]
  [OutputChannelMapping]
  [OutputChannelMapping]
  [OutputChannelMapping]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON ChannelMapping where
  parseJSON :: Value -> Parser ChannelMapping
parseJSON =
    String
-> (Object -> Parser ChannelMapping)
-> Value
-> Parser ChannelMapping
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ChannelMapping"
      ( \Object
x ->
          Maybe [OutputChannelMapping] -> ChannelMapping
ChannelMapping'
            (Maybe [OutputChannelMapping] -> ChannelMapping)
-> Parser (Maybe [OutputChannelMapping]) -> Parser ChannelMapping
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [OutputChannelMapping]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"outputChannels"
                            Parser (Maybe (Maybe [OutputChannelMapping]))
-> Maybe [OutputChannelMapping]
-> Parser (Maybe [OutputChannelMapping])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [OutputChannelMapping]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable ChannelMapping

instance Prelude.NFData ChannelMapping

instance Core.ToJSON ChannelMapping where
  toJSON :: ChannelMapping -> Value
toJSON ChannelMapping' {Maybe [OutputChannelMapping]
outputChannels :: Maybe [OutputChannelMapping]
$sel:outputChannels:ChannelMapping' :: ChannelMapping -> Maybe [OutputChannelMapping]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"outputChannels" Text -> [OutputChannelMapping] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([OutputChannelMapping] -> Pair)
-> Maybe [OutputChannelMapping] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [OutputChannelMapping]
outputChannels
          ]
      )