{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MediaLive.Types.WavSettings where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(WavSettings -> WavSettings -> Bool)
-> (WavSettings -> WavSettings -> Bool) -> Eq WavSettings
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]
(Int -> ReadS WavSettings)
-> ReadS [WavSettings]
-> ReadPrec WavSettings
-> ReadPrec [WavSettings]
-> Read 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
(Int -> WavSettings -> ShowS)
-> (WavSettings -> String)
-> ([WavSettings] -> ShowS)
-> Show WavSettings
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. WavSettings -> Rep WavSettings x)
-> (forall x. Rep WavSettings x -> WavSettings)
-> Generic WavSettings
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' :: Maybe Double -> Maybe WavCodingMode -> Maybe Double -> WavSettings
WavSettings'
    { $sel:bitDepth:WavSettings' :: Maybe Double
bitDepth = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:codingMode:WavSettings' :: Maybe WavCodingMode
codingMode = Maybe WavCodingMode
forall a. Maybe a
Prelude.Nothing,
      $sel:sampleRate:WavSettings' :: Maybe Double
sampleRate = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | Bits per sample.
wavSettings_bitDepth :: Lens.Lens' WavSettings (Prelude.Maybe Prelude.Double)
wavSettings_bitDepth :: (Maybe Double -> f (Maybe Double)) -> WavSettings -> f WavSettings
wavSettings_bitDepth = (WavSettings -> Maybe Double)
-> (WavSettings -> Maybe Double -> WavSettings)
-> Lens WavSettings WavSettings (Maybe Double) (Maybe Double)
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 :: (Maybe WavCodingMode -> f (Maybe WavCodingMode))
-> WavSettings -> f WavSettings
wavSettings_codingMode = (WavSettings -> Maybe WavCodingMode)
-> (WavSettings -> Maybe WavCodingMode -> WavSettings)
-> Lens
     WavSettings WavSettings (Maybe WavCodingMode) (Maybe WavCodingMode)
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 :: (Maybe Double -> f (Maybe Double)) -> WavSettings -> f WavSettings
wavSettings_sampleRate = (WavSettings -> Maybe Double)
-> (WavSettings -> Maybe Double -> WavSettings)
-> Lens WavSettings WavSettings (Maybe Double) (Maybe Double)
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 Core.FromJSON WavSettings where
  parseJSON :: Value -> Parser WavSettings
parseJSON =
    String
-> (Object -> Parser WavSettings) -> Value -> Parser WavSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"WavSettings"
      ( \Object
x ->
          Maybe Double -> Maybe WavCodingMode -> Maybe Double -> WavSettings
WavSettings'
            (Maybe Double
 -> Maybe WavCodingMode -> Maybe Double -> WavSettings)
-> Parser (Maybe Double)
-> Parser (Maybe WavCodingMode -> Maybe Double -> WavSettings)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"bitDepth")
            Parser (Maybe WavCodingMode -> Maybe Double -> WavSettings)
-> Parser (Maybe WavCodingMode)
-> Parser (Maybe Double -> WavSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe WavCodingMode)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"codingMode")
            Parser (Maybe Double -> WavSettings)
-> Parser (Maybe Double) -> Parser WavSettings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"sampleRate")
      )

instance Prelude.Hashable WavSettings

instance Prelude.NFData WavSettings

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"bitDepth" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Double -> Pair) -> Maybe Double -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
bitDepth,
            (Text
"codingMode" Text -> WavCodingMode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (WavCodingMode -> Pair) -> Maybe WavCodingMode -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe WavCodingMode
codingMode,
            (Text
"sampleRate" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Double -> Pair) -> Maybe Double -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
sampleRate
          ]
      )