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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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' {$sel:outputChannels:ChannelMapping' :: Maybe [OutputChannelMapping]
outputChannels = 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 :: Lens' ChannelMapping (Maybe [OutputChannelMapping])
channelMapping_outputChannels = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON ChannelMapping where
  parseJSON :: Value -> Parser ChannelMapping
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ChannelMapping"
      ( \Object
x ->
          Maybe [OutputChannelMapping] -> ChannelMapping
ChannelMapping'
            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
"outputChannels"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable ChannelMapping where
  hashWithSalt :: Int -> ChannelMapping -> Int
hashWithSalt Int
_salt ChannelMapping' {Maybe [OutputChannelMapping]
outputChannels :: Maybe [OutputChannelMapping]
$sel:outputChannels:ChannelMapping' :: ChannelMapping -> Maybe [OutputChannelMapping]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [OutputChannelMapping]
outputChannels

instance Prelude.NFData ChannelMapping where
  rnf :: ChannelMapping -> ()
rnf ChannelMapping' {Maybe [OutputChannelMapping]
outputChannels :: Maybe [OutputChannelMapping]
$sel:outputChannels:ChannelMapping' :: ChannelMapping -> Maybe [OutputChannelMapping]
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe [OutputChannelMapping]
outputChannels

instance Data.ToJSON ChannelMapping where
  toJSON :: ChannelMapping -> Value
toJSON ChannelMapping' {Maybe [OutputChannelMapping]
outputChannels :: Maybe [OutputChannelMapping]
$sel:outputChannels:ChannelMapping' :: ChannelMapping -> Maybe [OutputChannelMapping]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"outputChannels" 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 [OutputChannelMapping]
outputChannels
          ]
      )