{-# 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.InputChannelLevel
-- 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.InputChannelLevel where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Input Channel Level
--
-- /See:/ 'newInputChannelLevel' smart constructor.
data InputChannelLevel = InputChannelLevel'
  { -- | The index of the input channel used as a source.
    InputChannelLevel -> Natural
inputChannel :: Prelude.Natural,
    -- | Remixing value. Units are in dB and acceptable values are within the
    -- range from -60 (mute) and 6 dB.
    InputChannelLevel -> Int
gain :: Prelude.Int
  }
  deriving (InputChannelLevel -> InputChannelLevel -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InputChannelLevel -> InputChannelLevel -> Bool
$c/= :: InputChannelLevel -> InputChannelLevel -> Bool
== :: InputChannelLevel -> InputChannelLevel -> Bool
$c== :: InputChannelLevel -> InputChannelLevel -> Bool
Prelude.Eq, ReadPrec [InputChannelLevel]
ReadPrec InputChannelLevel
Int -> ReadS InputChannelLevel
ReadS [InputChannelLevel]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InputChannelLevel]
$creadListPrec :: ReadPrec [InputChannelLevel]
readPrec :: ReadPrec InputChannelLevel
$creadPrec :: ReadPrec InputChannelLevel
readList :: ReadS [InputChannelLevel]
$creadList :: ReadS [InputChannelLevel]
readsPrec :: Int -> ReadS InputChannelLevel
$creadsPrec :: Int -> ReadS InputChannelLevel
Prelude.Read, Int -> InputChannelLevel -> ShowS
[InputChannelLevel] -> ShowS
InputChannelLevel -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InputChannelLevel] -> ShowS
$cshowList :: [InputChannelLevel] -> ShowS
show :: InputChannelLevel -> String
$cshow :: InputChannelLevel -> String
showsPrec :: Int -> InputChannelLevel -> ShowS
$cshowsPrec :: Int -> InputChannelLevel -> ShowS
Prelude.Show, forall x. Rep InputChannelLevel x -> InputChannelLevel
forall x. InputChannelLevel -> Rep InputChannelLevel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InputChannelLevel x -> InputChannelLevel
$cfrom :: forall x. InputChannelLevel -> Rep InputChannelLevel x
Prelude.Generic)

-- |
-- Create a value of 'InputChannelLevel' 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:
--
-- 'inputChannel', 'inputChannelLevel_inputChannel' - The index of the input channel used as a source.
--
-- 'gain', 'inputChannelLevel_gain' - Remixing value. Units are in dB and acceptable values are within the
-- range from -60 (mute) and 6 dB.
newInputChannelLevel ::
  -- | 'inputChannel'
  Prelude.Natural ->
  -- | 'gain'
  Prelude.Int ->
  InputChannelLevel
newInputChannelLevel :: Natural -> Int -> InputChannelLevel
newInputChannelLevel Natural
pInputChannel_ Int
pGain_ =
  InputChannelLevel'
    { $sel:inputChannel:InputChannelLevel' :: Natural
inputChannel = Natural
pInputChannel_,
      $sel:gain:InputChannelLevel' :: Int
gain = Int
pGain_
    }

-- | The index of the input channel used as a source.
inputChannelLevel_inputChannel :: Lens.Lens' InputChannelLevel Prelude.Natural
inputChannelLevel_inputChannel :: Lens' InputChannelLevel Natural
inputChannelLevel_inputChannel = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputChannelLevel' {Natural
inputChannel :: Natural
$sel:inputChannel:InputChannelLevel' :: InputChannelLevel -> Natural
inputChannel} -> Natural
inputChannel) (\s :: InputChannelLevel
s@InputChannelLevel' {} Natural
a -> InputChannelLevel
s {$sel:inputChannel:InputChannelLevel' :: Natural
inputChannel = Natural
a} :: InputChannelLevel)

-- | Remixing value. Units are in dB and acceptable values are within the
-- range from -60 (mute) and 6 dB.
inputChannelLevel_gain :: Lens.Lens' InputChannelLevel Prelude.Int
inputChannelLevel_gain :: Lens' InputChannelLevel Int
inputChannelLevel_gain = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputChannelLevel' {Int
gain :: Int
$sel:gain:InputChannelLevel' :: InputChannelLevel -> Int
gain} -> Int
gain) (\s :: InputChannelLevel
s@InputChannelLevel' {} Int
a -> InputChannelLevel
s {$sel:gain:InputChannelLevel' :: Int
gain = Int
a} :: InputChannelLevel)

instance Data.FromJSON InputChannelLevel where
  parseJSON :: Value -> Parser InputChannelLevel
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"InputChannelLevel"
      ( \Object
x ->
          Natural -> Int -> InputChannelLevel
InputChannelLevel'
            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
"inputChannel")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"gain")
      )

instance Prelude.Hashable InputChannelLevel where
  hashWithSalt :: Int -> InputChannelLevel -> Int
hashWithSalt Int
_salt InputChannelLevel' {Int
Natural
gain :: Int
inputChannel :: Natural
$sel:gain:InputChannelLevel' :: InputChannelLevel -> Int
$sel:inputChannel:InputChannelLevel' :: InputChannelLevel -> Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
inputChannel
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
gain

instance Prelude.NFData InputChannelLevel where
  rnf :: InputChannelLevel -> ()
rnf InputChannelLevel' {Int
Natural
gain :: Int
inputChannel :: Natural
$sel:gain:InputChannelLevel' :: InputChannelLevel -> Int
$sel:inputChannel:InputChannelLevel' :: InputChannelLevel -> Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Natural
inputChannel
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
gain

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