{-# 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.AudioNormalizationSettings
-- 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.AudioNormalizationSettings 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.AudioNormalizationAlgorithm
import Amazonka.MediaLive.Types.AudioNormalizationAlgorithmControl
import qualified Amazonka.Prelude as Prelude

-- | Audio Normalization Settings
--
-- /See:/ 'newAudioNormalizationSettings' smart constructor.
data AudioNormalizationSettings = AudioNormalizationSettings'
  { -- | Audio normalization algorithm to use. itu17701 conforms to the CALM Act
    -- specification, itu17702 conforms to the EBU R-128 specification.
    AudioNormalizationSettings -> Maybe AudioNormalizationAlgorithm
algorithm :: Prelude.Maybe AudioNormalizationAlgorithm,
    -- | When set to correctAudio the output audio is corrected using the chosen
    -- algorithm. If set to measureOnly, the audio will be measured but not
    -- adjusted.
    AudioNormalizationSettings
-> Maybe AudioNormalizationAlgorithmControl
algorithmControl :: Prelude.Maybe AudioNormalizationAlgorithmControl,
    -- | Target LKFS(loudness) to adjust volume to. If no value is entered, a
    -- default value will be used according to the chosen algorithm. The CALM
    -- Act (1770-1) recommends a target of -24 LKFS. The EBU R-128
    -- specification (1770-2) recommends a target of -23 LKFS.
    AudioNormalizationSettings -> Maybe Double
targetLkfs :: Prelude.Maybe Prelude.Double
  }
  deriving (AudioNormalizationSettings -> AudioNormalizationSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AudioNormalizationSettings -> AudioNormalizationSettings -> Bool
$c/= :: AudioNormalizationSettings -> AudioNormalizationSettings -> Bool
== :: AudioNormalizationSettings -> AudioNormalizationSettings -> Bool
$c== :: AudioNormalizationSettings -> AudioNormalizationSettings -> Bool
Prelude.Eq, ReadPrec [AudioNormalizationSettings]
ReadPrec AudioNormalizationSettings
Int -> ReadS AudioNormalizationSettings
ReadS [AudioNormalizationSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AudioNormalizationSettings]
$creadListPrec :: ReadPrec [AudioNormalizationSettings]
readPrec :: ReadPrec AudioNormalizationSettings
$creadPrec :: ReadPrec AudioNormalizationSettings
readList :: ReadS [AudioNormalizationSettings]
$creadList :: ReadS [AudioNormalizationSettings]
readsPrec :: Int -> ReadS AudioNormalizationSettings
$creadsPrec :: Int -> ReadS AudioNormalizationSettings
Prelude.Read, Int -> AudioNormalizationSettings -> ShowS
[AudioNormalizationSettings] -> ShowS
AudioNormalizationSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AudioNormalizationSettings] -> ShowS
$cshowList :: [AudioNormalizationSettings] -> ShowS
show :: AudioNormalizationSettings -> String
$cshow :: AudioNormalizationSettings -> String
showsPrec :: Int -> AudioNormalizationSettings -> ShowS
$cshowsPrec :: Int -> AudioNormalizationSettings -> ShowS
Prelude.Show, forall x.
Rep AudioNormalizationSettings x -> AudioNormalizationSettings
forall x.
AudioNormalizationSettings -> Rep AudioNormalizationSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AudioNormalizationSettings x -> AudioNormalizationSettings
$cfrom :: forall x.
AudioNormalizationSettings -> Rep AudioNormalizationSettings x
Prelude.Generic)

-- |
-- Create a value of 'AudioNormalizationSettings' 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:
--
-- 'algorithm', 'audioNormalizationSettings_algorithm' - Audio normalization algorithm to use. itu17701 conforms to the CALM Act
-- specification, itu17702 conforms to the EBU R-128 specification.
--
-- 'algorithmControl', 'audioNormalizationSettings_algorithmControl' - When set to correctAudio the output audio is corrected using the chosen
-- algorithm. If set to measureOnly, the audio will be measured but not
-- adjusted.
--
-- 'targetLkfs', 'audioNormalizationSettings_targetLkfs' - Target LKFS(loudness) to adjust volume to. If no value is entered, a
-- default value will be used according to the chosen algorithm. The CALM
-- Act (1770-1) recommends a target of -24 LKFS. The EBU R-128
-- specification (1770-2) recommends a target of -23 LKFS.
newAudioNormalizationSettings ::
  AudioNormalizationSettings
newAudioNormalizationSettings :: AudioNormalizationSettings
newAudioNormalizationSettings =
  AudioNormalizationSettings'
    { $sel:algorithm:AudioNormalizationSettings' :: Maybe AudioNormalizationAlgorithm
algorithm =
        forall a. Maybe a
Prelude.Nothing,
      $sel:algorithmControl:AudioNormalizationSettings' :: Maybe AudioNormalizationAlgorithmControl
algorithmControl = forall a. Maybe a
Prelude.Nothing,
      $sel:targetLkfs:AudioNormalizationSettings' :: Maybe Double
targetLkfs = forall a. Maybe a
Prelude.Nothing
    }

-- | Audio normalization algorithm to use. itu17701 conforms to the CALM Act
-- specification, itu17702 conforms to the EBU R-128 specification.
audioNormalizationSettings_algorithm :: Lens.Lens' AudioNormalizationSettings (Prelude.Maybe AudioNormalizationAlgorithm)
audioNormalizationSettings_algorithm :: Lens'
  AudioNormalizationSettings (Maybe AudioNormalizationAlgorithm)
audioNormalizationSettings_algorithm = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AudioNormalizationSettings' {Maybe AudioNormalizationAlgorithm
algorithm :: Maybe AudioNormalizationAlgorithm
$sel:algorithm:AudioNormalizationSettings' :: AudioNormalizationSettings -> Maybe AudioNormalizationAlgorithm
algorithm} -> Maybe AudioNormalizationAlgorithm
algorithm) (\s :: AudioNormalizationSettings
s@AudioNormalizationSettings' {} Maybe AudioNormalizationAlgorithm
a -> AudioNormalizationSettings
s {$sel:algorithm:AudioNormalizationSettings' :: Maybe AudioNormalizationAlgorithm
algorithm = Maybe AudioNormalizationAlgorithm
a} :: AudioNormalizationSettings)

-- | When set to correctAudio the output audio is corrected using the chosen
-- algorithm. If set to measureOnly, the audio will be measured but not
-- adjusted.
audioNormalizationSettings_algorithmControl :: Lens.Lens' AudioNormalizationSettings (Prelude.Maybe AudioNormalizationAlgorithmControl)
audioNormalizationSettings_algorithmControl :: Lens'
  AudioNormalizationSettings
  (Maybe AudioNormalizationAlgorithmControl)
audioNormalizationSettings_algorithmControl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AudioNormalizationSettings' {Maybe AudioNormalizationAlgorithmControl
algorithmControl :: Maybe AudioNormalizationAlgorithmControl
$sel:algorithmControl:AudioNormalizationSettings' :: AudioNormalizationSettings
-> Maybe AudioNormalizationAlgorithmControl
algorithmControl} -> Maybe AudioNormalizationAlgorithmControl
algorithmControl) (\s :: AudioNormalizationSettings
s@AudioNormalizationSettings' {} Maybe AudioNormalizationAlgorithmControl
a -> AudioNormalizationSettings
s {$sel:algorithmControl:AudioNormalizationSettings' :: Maybe AudioNormalizationAlgorithmControl
algorithmControl = Maybe AudioNormalizationAlgorithmControl
a} :: AudioNormalizationSettings)

-- | Target LKFS(loudness) to adjust volume to. If no value is entered, a
-- default value will be used according to the chosen algorithm. The CALM
-- Act (1770-1) recommends a target of -24 LKFS. The EBU R-128
-- specification (1770-2) recommends a target of -23 LKFS.
audioNormalizationSettings_targetLkfs :: Lens.Lens' AudioNormalizationSettings (Prelude.Maybe Prelude.Double)
audioNormalizationSettings_targetLkfs :: Lens' AudioNormalizationSettings (Maybe Double)
audioNormalizationSettings_targetLkfs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AudioNormalizationSettings' {Maybe Double
targetLkfs :: Maybe Double
$sel:targetLkfs:AudioNormalizationSettings' :: AudioNormalizationSettings -> Maybe Double
targetLkfs} -> Maybe Double
targetLkfs) (\s :: AudioNormalizationSettings
s@AudioNormalizationSettings' {} Maybe Double
a -> AudioNormalizationSettings
s {$sel:targetLkfs:AudioNormalizationSettings' :: Maybe Double
targetLkfs = Maybe Double
a} :: AudioNormalizationSettings)

instance Data.FromJSON AudioNormalizationSettings where
  parseJSON :: Value -> Parser AudioNormalizationSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AudioNormalizationSettings"
      ( \Object
x ->
          Maybe AudioNormalizationAlgorithm
-> Maybe AudioNormalizationAlgorithmControl
-> Maybe Double
-> AudioNormalizationSettings
AudioNormalizationSettings'
            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
"algorithm")
            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
"algorithmControl")
            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
"targetLkfs")
      )

instance Prelude.Hashable AudioNormalizationSettings where
  hashWithSalt :: Int -> AudioNormalizationSettings -> Int
hashWithSalt Int
_salt AudioNormalizationSettings' {Maybe Double
Maybe AudioNormalizationAlgorithm
Maybe AudioNormalizationAlgorithmControl
targetLkfs :: Maybe Double
algorithmControl :: Maybe AudioNormalizationAlgorithmControl
algorithm :: Maybe AudioNormalizationAlgorithm
$sel:targetLkfs:AudioNormalizationSettings' :: AudioNormalizationSettings -> Maybe Double
$sel:algorithmControl:AudioNormalizationSettings' :: AudioNormalizationSettings
-> Maybe AudioNormalizationAlgorithmControl
$sel:algorithm:AudioNormalizationSettings' :: AudioNormalizationSettings -> Maybe AudioNormalizationAlgorithm
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AudioNormalizationAlgorithm
algorithm
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AudioNormalizationAlgorithmControl
algorithmControl
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
targetLkfs

instance Prelude.NFData AudioNormalizationSettings where
  rnf :: AudioNormalizationSettings -> ()
rnf AudioNormalizationSettings' {Maybe Double
Maybe AudioNormalizationAlgorithm
Maybe AudioNormalizationAlgorithmControl
targetLkfs :: Maybe Double
algorithmControl :: Maybe AudioNormalizationAlgorithmControl
algorithm :: Maybe AudioNormalizationAlgorithm
$sel:targetLkfs:AudioNormalizationSettings' :: AudioNormalizationSettings -> Maybe Double
$sel:algorithmControl:AudioNormalizationSettings' :: AudioNormalizationSettings
-> Maybe AudioNormalizationAlgorithmControl
$sel:algorithm:AudioNormalizationSettings' :: AudioNormalizationSettings -> Maybe AudioNormalizationAlgorithm
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AudioNormalizationAlgorithm
algorithm
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe AudioNormalizationAlgorithmControl
algorithmControl
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
targetLkfs

instance Data.ToJSON AudioNormalizationSettings where
  toJSON :: AudioNormalizationSettings -> Value
toJSON AudioNormalizationSettings' {Maybe Double
Maybe AudioNormalizationAlgorithm
Maybe AudioNormalizationAlgorithmControl
targetLkfs :: Maybe Double
algorithmControl :: Maybe AudioNormalizationAlgorithmControl
algorithm :: Maybe AudioNormalizationAlgorithm
$sel:targetLkfs:AudioNormalizationSettings' :: AudioNormalizationSettings -> Maybe Double
$sel:algorithmControl:AudioNormalizationSettings' :: AudioNormalizationSettings
-> Maybe AudioNormalizationAlgorithmControl
$sel:algorithm:AudioNormalizationSettings' :: AudioNormalizationSettings -> Maybe AudioNormalizationAlgorithm
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"algorithm" 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 AudioNormalizationAlgorithm
algorithm,
            (Key
"algorithmControl" 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 AudioNormalizationAlgorithmControl
algorithmControl,
            (Key
"targetLkfs" 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 Double
targetLkfs
          ]
      )