{-# 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.AudioChannelMapping
-- 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.AudioChannelMapping 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.InputChannelLevel
import qualified Amazonka.Prelude as Prelude

-- | Audio Channel Mapping
--
-- /See:/ 'newAudioChannelMapping' smart constructor.
data AudioChannelMapping = AudioChannelMapping'
  { -- | The index of the output channel being produced.
    AudioChannelMapping -> Natural
outputChannel :: Prelude.Natural,
    -- | Indices and gain values for each input channel that should be remixed
    -- into this output channel.
    AudioChannelMapping -> [InputChannelLevel]
inputChannelLevels :: [InputChannelLevel]
  }
  deriving (AudioChannelMapping -> AudioChannelMapping -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AudioChannelMapping -> AudioChannelMapping -> Bool
$c/= :: AudioChannelMapping -> AudioChannelMapping -> Bool
== :: AudioChannelMapping -> AudioChannelMapping -> Bool
$c== :: AudioChannelMapping -> AudioChannelMapping -> Bool
Prelude.Eq, ReadPrec [AudioChannelMapping]
ReadPrec AudioChannelMapping
Int -> ReadS AudioChannelMapping
ReadS [AudioChannelMapping]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AudioChannelMapping]
$creadListPrec :: ReadPrec [AudioChannelMapping]
readPrec :: ReadPrec AudioChannelMapping
$creadPrec :: ReadPrec AudioChannelMapping
readList :: ReadS [AudioChannelMapping]
$creadList :: ReadS [AudioChannelMapping]
readsPrec :: Int -> ReadS AudioChannelMapping
$creadsPrec :: Int -> ReadS AudioChannelMapping
Prelude.Read, Int -> AudioChannelMapping -> ShowS
[AudioChannelMapping] -> ShowS
AudioChannelMapping -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AudioChannelMapping] -> ShowS
$cshowList :: [AudioChannelMapping] -> ShowS
show :: AudioChannelMapping -> String
$cshow :: AudioChannelMapping -> String
showsPrec :: Int -> AudioChannelMapping -> ShowS
$cshowsPrec :: Int -> AudioChannelMapping -> ShowS
Prelude.Show, forall x. Rep AudioChannelMapping x -> AudioChannelMapping
forall x. AudioChannelMapping -> Rep AudioChannelMapping x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AudioChannelMapping x -> AudioChannelMapping
$cfrom :: forall x. AudioChannelMapping -> Rep AudioChannelMapping x
Prelude.Generic)

-- |
-- Create a value of 'AudioChannelMapping' 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:
--
-- 'outputChannel', 'audioChannelMapping_outputChannel' - The index of the output channel being produced.
--
-- 'inputChannelLevels', 'audioChannelMapping_inputChannelLevels' - Indices and gain values for each input channel that should be remixed
-- into this output channel.
newAudioChannelMapping ::
  -- | 'outputChannel'
  Prelude.Natural ->
  AudioChannelMapping
newAudioChannelMapping :: Natural -> AudioChannelMapping
newAudioChannelMapping Natural
pOutputChannel_ =
  AudioChannelMapping'
    { $sel:outputChannel:AudioChannelMapping' :: Natural
outputChannel =
        Natural
pOutputChannel_,
      $sel:inputChannelLevels:AudioChannelMapping' :: [InputChannelLevel]
inputChannelLevels = forall a. Monoid a => a
Prelude.mempty
    }

-- | The index of the output channel being produced.
audioChannelMapping_outputChannel :: Lens.Lens' AudioChannelMapping Prelude.Natural
audioChannelMapping_outputChannel :: Lens' AudioChannelMapping Natural
audioChannelMapping_outputChannel = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AudioChannelMapping' {Natural
outputChannel :: Natural
$sel:outputChannel:AudioChannelMapping' :: AudioChannelMapping -> Natural
outputChannel} -> Natural
outputChannel) (\s :: AudioChannelMapping
s@AudioChannelMapping' {} Natural
a -> AudioChannelMapping
s {$sel:outputChannel:AudioChannelMapping' :: Natural
outputChannel = Natural
a} :: AudioChannelMapping)

-- | Indices and gain values for each input channel that should be remixed
-- into this output channel.
audioChannelMapping_inputChannelLevels :: Lens.Lens' AudioChannelMapping [InputChannelLevel]
audioChannelMapping_inputChannelLevels :: Lens' AudioChannelMapping [InputChannelLevel]
audioChannelMapping_inputChannelLevels = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AudioChannelMapping' {[InputChannelLevel]
inputChannelLevels :: [InputChannelLevel]
$sel:inputChannelLevels:AudioChannelMapping' :: AudioChannelMapping -> [InputChannelLevel]
inputChannelLevels} -> [InputChannelLevel]
inputChannelLevels) (\s :: AudioChannelMapping
s@AudioChannelMapping' {} [InputChannelLevel]
a -> AudioChannelMapping
s {$sel:inputChannelLevels:AudioChannelMapping' :: [InputChannelLevel]
inputChannelLevels = [InputChannelLevel]
a} :: AudioChannelMapping) 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 AudioChannelMapping where
  parseJSON :: Value -> Parser AudioChannelMapping
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AudioChannelMapping"
      ( \Object
x ->
          Natural -> [InputChannelLevel] -> AudioChannelMapping
AudioChannelMapping'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"outputChannel")
            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
"inputChannelLevels"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable AudioChannelMapping where
  hashWithSalt :: Int -> AudioChannelMapping -> Int
hashWithSalt Int
_salt AudioChannelMapping' {Natural
[InputChannelLevel]
inputChannelLevels :: [InputChannelLevel]
outputChannel :: Natural
$sel:inputChannelLevels:AudioChannelMapping' :: AudioChannelMapping -> [InputChannelLevel]
$sel:outputChannel:AudioChannelMapping' :: AudioChannelMapping -> Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
outputChannel
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [InputChannelLevel]
inputChannelLevels

instance Prelude.NFData AudioChannelMapping where
  rnf :: AudioChannelMapping -> ()
rnf AudioChannelMapping' {Natural
[InputChannelLevel]
inputChannelLevels :: [InputChannelLevel]
outputChannel :: Natural
$sel:inputChannelLevels:AudioChannelMapping' :: AudioChannelMapping -> [InputChannelLevel]
$sel:outputChannel:AudioChannelMapping' :: AudioChannelMapping -> Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Natural
outputChannel
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [InputChannelLevel]
inputChannelLevels

instance Data.ToJSON AudioChannelMapping where
  toJSON :: AudioChannelMapping -> Value
toJSON AudioChannelMapping' {Natural
[InputChannelLevel]
inputChannelLevels :: [InputChannelLevel]
outputChannel :: Natural
$sel:inputChannelLevels:AudioChannelMapping' :: AudioChannelMapping -> [InputChannelLevel]
$sel:outputChannel:AudioChannelMapping' :: AudioChannelMapping -> Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"outputChannel" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
outputChannel),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"inputChannelLevels" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [InputChannelLevel]
inputChannelLevels)
          ]
      )