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

-- | Wav Settings
--
-- /See:/ 'newWavSettings' smart constructor.
data WavSettings = WavSettings'
  { -- | Bits per sample.
    WavSettings -> Maybe Double
bitDepth :: Prelude.Maybe Prelude.Double,
    -- | The audio coding mode for the WAV audio. The mode determines the number
    -- of channels in the audio.
    WavSettings -> Maybe WavCodingMode
codingMode :: Prelude.Maybe WavCodingMode,
    -- | Sample rate in Hz.
    WavSettings -> Maybe Double
sampleRate :: Prelude.Maybe Prelude.Double
  }
  deriving (WavSettings -> WavSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WavSettings -> WavSettings -> Bool
$c/= :: WavSettings -> WavSettings -> Bool
== :: WavSettings -> WavSettings -> Bool
$c== :: WavSettings -> WavSettings -> Bool
Prelude.Eq, ReadPrec [WavSettings]
ReadPrec WavSettings
Int -> ReadS WavSettings
ReadS [WavSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WavSettings]
$creadListPrec :: ReadPrec [WavSettings]
readPrec :: ReadPrec WavSettings
$creadPrec :: ReadPrec WavSettings
readList :: ReadS [WavSettings]
$creadList :: ReadS [WavSettings]
readsPrec :: Int -> ReadS WavSettings
$creadsPrec :: Int -> ReadS WavSettings
Prelude.Read, Int -> WavSettings -> ShowS
[WavSettings] -> ShowS
WavSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WavSettings] -> ShowS
$cshowList :: [WavSettings] -> ShowS
show :: WavSettings -> String
$cshow :: WavSettings -> String
showsPrec :: Int -> WavSettings -> ShowS
$cshowsPrec :: Int -> WavSettings -> ShowS
Prelude.Show, forall x. Rep WavSettings x -> WavSettings
forall x. WavSettings -> Rep WavSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WavSettings x -> WavSettings
$cfrom :: forall x. WavSettings -> Rep WavSettings x
Prelude.Generic)

-- |
-- Create a value of 'WavSettings' 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:
--
-- 'bitDepth', 'wavSettings_bitDepth' - Bits per sample.
--
-- 'codingMode', 'wavSettings_codingMode' - The audio coding mode for the WAV audio. The mode determines the number
-- of channels in the audio.
--
-- 'sampleRate', 'wavSettings_sampleRate' - Sample rate in Hz.
newWavSettings ::
  WavSettings
newWavSettings :: WavSettings
newWavSettings =
  WavSettings'
    { $sel:bitDepth:WavSettings' :: Maybe Double
bitDepth = forall a. Maybe a
Prelude.Nothing,
      $sel:codingMode:WavSettings' :: Maybe WavCodingMode
codingMode = forall a. Maybe a
Prelude.Nothing,
      $sel:sampleRate:WavSettings' :: Maybe Double
sampleRate = forall a. Maybe a
Prelude.Nothing
    }

-- | Bits per sample.
wavSettings_bitDepth :: Lens.Lens' WavSettings (Prelude.Maybe Prelude.Double)
wavSettings_bitDepth :: Lens' WavSettings (Maybe Double)
wavSettings_bitDepth = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WavSettings' {Maybe Double
bitDepth :: Maybe Double
$sel:bitDepth:WavSettings' :: WavSettings -> Maybe Double
bitDepth} -> Maybe Double
bitDepth) (\s :: WavSettings
s@WavSettings' {} Maybe Double
a -> WavSettings
s {$sel:bitDepth:WavSettings' :: Maybe Double
bitDepth = Maybe Double
a} :: WavSettings)

-- | The audio coding mode for the WAV audio. The mode determines the number
-- of channels in the audio.
wavSettings_codingMode :: Lens.Lens' WavSettings (Prelude.Maybe WavCodingMode)
wavSettings_codingMode :: Lens' WavSettings (Maybe WavCodingMode)
wavSettings_codingMode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WavSettings' {Maybe WavCodingMode
codingMode :: Maybe WavCodingMode
$sel:codingMode:WavSettings' :: WavSettings -> Maybe WavCodingMode
codingMode} -> Maybe WavCodingMode
codingMode) (\s :: WavSettings
s@WavSettings' {} Maybe WavCodingMode
a -> WavSettings
s {$sel:codingMode:WavSettings' :: Maybe WavCodingMode
codingMode = Maybe WavCodingMode
a} :: WavSettings)

-- | Sample rate in Hz.
wavSettings_sampleRate :: Lens.Lens' WavSettings (Prelude.Maybe Prelude.Double)
wavSettings_sampleRate :: Lens' WavSettings (Maybe Double)
wavSettings_sampleRate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WavSettings' {Maybe Double
sampleRate :: Maybe Double
$sel:sampleRate:WavSettings' :: WavSettings -> Maybe Double
sampleRate} -> Maybe Double
sampleRate) (\s :: WavSettings
s@WavSettings' {} Maybe Double
a -> WavSettings
s {$sel:sampleRate:WavSettings' :: Maybe Double
sampleRate = Maybe Double
a} :: WavSettings)

instance Data.FromJSON WavSettings where
  parseJSON :: Value -> Parser WavSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"WavSettings"
      ( \Object
x ->
          Maybe Double -> Maybe WavCodingMode -> Maybe Double -> WavSettings
WavSettings'
            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
"bitDepth")
            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
"codingMode")
            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
"sampleRate")
      )

instance Prelude.Hashable WavSettings where
  hashWithSalt :: Int -> WavSettings -> Int
hashWithSalt Int
_salt WavSettings' {Maybe Double
Maybe WavCodingMode
sampleRate :: Maybe Double
codingMode :: Maybe WavCodingMode
bitDepth :: Maybe Double
$sel:sampleRate:WavSettings' :: WavSettings -> Maybe Double
$sel:codingMode:WavSettings' :: WavSettings -> Maybe WavCodingMode
$sel:bitDepth:WavSettings' :: WavSettings -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
bitDepth
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe WavCodingMode
codingMode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
sampleRate

instance Prelude.NFData WavSettings where
  rnf :: WavSettings -> ()
rnf WavSettings' {Maybe Double
Maybe WavCodingMode
sampleRate :: Maybe Double
codingMode :: Maybe WavCodingMode
bitDepth :: Maybe Double
$sel:sampleRate:WavSettings' :: WavSettings -> Maybe Double
$sel:codingMode:WavSettings' :: WavSettings -> Maybe WavCodingMode
$sel:bitDepth:WavSettings' :: WavSettings -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
bitDepth
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe WavCodingMode
codingMode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
sampleRate

instance Data.ToJSON WavSettings where
  toJSON :: WavSettings -> Value
toJSON WavSettings' {Maybe Double
Maybe WavCodingMode
sampleRate :: Maybe Double
codingMode :: Maybe WavCodingMode
bitDepth :: Maybe Double
$sel:sampleRate:WavSettings' :: WavSettings -> Maybe Double
$sel:codingMode:WavSettings' :: WavSettings -> Maybe WavCodingMode
$sel:bitDepth:WavSettings' :: WavSettings -> Maybe Double
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"bitDepth" 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
bitDepth,
            (Key
"codingMode" 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 WavCodingMode
codingMode,
            (Key
"sampleRate" 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
sampleRate
          ]
      )