{-# 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.MediaConvert.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.MediaConvert.Types.WavSettings where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaConvert.Types.WavFormat
import qualified Amazonka.Prelude as Prelude

-- | Required when you set (Codec) under (AudioDescriptions)>(CodecSettings)
-- to the value WAV.
--
-- /See:/ 'newWavSettings' smart constructor.
data WavSettings = WavSettings'
  { -- | Specify Bit depth (BitDepth), in bits per sample, to choose the encoding
    -- quality for this audio track.
    WavSettings -> Maybe Natural
bitDepth :: Prelude.Maybe Prelude.Natural,
    -- | Specify the number of channels in this output audio track. Valid values
    -- are 1 and even numbers up to 64. For example, 1, 2, 4, 6, and so on, up
    -- to 64.
    WavSettings -> Maybe Natural
channels :: Prelude.Maybe Prelude.Natural,
    -- | The service defaults to using RIFF for WAV outputs. If your output audio
    -- is likely to exceed 4 GB in file size, or if you otherwise need the
    -- extended support of the RF64 format, set your output WAV file format to
    -- RF64.
    WavSettings -> Maybe WavFormat
format :: Prelude.Maybe WavFormat,
    -- | Sample rate in Hz.
    WavSettings -> Maybe Natural
sampleRate :: Prelude.Maybe Prelude.Natural
  }
  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' - Specify Bit depth (BitDepth), in bits per sample, to choose the encoding
-- quality for this audio track.
--
-- 'channels', 'wavSettings_channels' - Specify the number of channels in this output audio track. Valid values
-- are 1 and even numbers up to 64. For example, 1, 2, 4, 6, and so on, up
-- to 64.
--
-- 'format', 'wavSettings_format' - The service defaults to using RIFF for WAV outputs. If your output audio
-- is likely to exceed 4 GB in file size, or if you otherwise need the
-- extended support of the RF64 format, set your output WAV file format to
-- RF64.
--
-- 'sampleRate', 'wavSettings_sampleRate' - Sample rate in Hz.
newWavSettings ::
  WavSettings
newWavSettings :: WavSettings
newWavSettings =
  WavSettings' :: Maybe Natural
-> Maybe Natural -> Maybe WavFormat -> Maybe Natural -> WavSettings
WavSettings'
    { $sel:bitDepth:WavSettings' :: Maybe Natural
bitDepth = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:channels:WavSettings' :: Maybe Natural
channels = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:format:WavSettings' :: Maybe WavFormat
format = Maybe WavFormat
forall a. Maybe a
Prelude.Nothing,
      $sel:sampleRate:WavSettings' :: Maybe Natural
sampleRate = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | Specify Bit depth (BitDepth), in bits per sample, to choose the encoding
-- quality for this audio track.
wavSettings_bitDepth :: Lens.Lens' WavSettings (Prelude.Maybe Prelude.Natural)
wavSettings_bitDepth :: (Maybe Natural -> f (Maybe Natural))
-> WavSettings -> f WavSettings
wavSettings_bitDepth = (WavSettings -> Maybe Natural)
-> (WavSettings -> Maybe Natural -> WavSettings)
-> Lens WavSettings WavSettings (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WavSettings' {Maybe Natural
bitDepth :: Maybe Natural
$sel:bitDepth:WavSettings' :: WavSettings -> Maybe Natural
bitDepth} -> Maybe Natural
bitDepth) (\s :: WavSettings
s@WavSettings' {} Maybe Natural
a -> WavSettings
s {$sel:bitDepth:WavSettings' :: Maybe Natural
bitDepth = Maybe Natural
a} :: WavSettings)

-- | Specify the number of channels in this output audio track. Valid values
-- are 1 and even numbers up to 64. For example, 1, 2, 4, 6, and so on, up
-- to 64.
wavSettings_channels :: Lens.Lens' WavSettings (Prelude.Maybe Prelude.Natural)
wavSettings_channels :: (Maybe Natural -> f (Maybe Natural))
-> WavSettings -> f WavSettings
wavSettings_channels = (WavSettings -> Maybe Natural)
-> (WavSettings -> Maybe Natural -> WavSettings)
-> Lens WavSettings WavSettings (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WavSettings' {Maybe Natural
channels :: Maybe Natural
$sel:channels:WavSettings' :: WavSettings -> Maybe Natural
channels} -> Maybe Natural
channels) (\s :: WavSettings
s@WavSettings' {} Maybe Natural
a -> WavSettings
s {$sel:channels:WavSettings' :: Maybe Natural
channels = Maybe Natural
a} :: WavSettings)

-- | The service defaults to using RIFF for WAV outputs. If your output audio
-- is likely to exceed 4 GB in file size, or if you otherwise need the
-- extended support of the RF64 format, set your output WAV file format to
-- RF64.
wavSettings_format :: Lens.Lens' WavSettings (Prelude.Maybe WavFormat)
wavSettings_format :: (Maybe WavFormat -> f (Maybe WavFormat))
-> WavSettings -> f WavSettings
wavSettings_format = (WavSettings -> Maybe WavFormat)
-> (WavSettings -> Maybe WavFormat -> WavSettings)
-> Lens WavSettings WavSettings (Maybe WavFormat) (Maybe WavFormat)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WavSettings' {Maybe WavFormat
format :: Maybe WavFormat
$sel:format:WavSettings' :: WavSettings -> Maybe WavFormat
format} -> Maybe WavFormat
format) (\s :: WavSettings
s@WavSettings' {} Maybe WavFormat
a -> WavSettings
s {$sel:format:WavSettings' :: Maybe WavFormat
format = Maybe WavFormat
a} :: WavSettings)

-- | Sample rate in Hz.
wavSettings_sampleRate :: Lens.Lens' WavSettings (Prelude.Maybe Prelude.Natural)
wavSettings_sampleRate :: (Maybe Natural -> f (Maybe Natural))
-> WavSettings -> f WavSettings
wavSettings_sampleRate = (WavSettings -> Maybe Natural)
-> (WavSettings -> Maybe Natural -> WavSettings)
-> Lens WavSettings WavSettings (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WavSettings' {Maybe Natural
sampleRate :: Maybe Natural
$sel:sampleRate:WavSettings' :: WavSettings -> Maybe Natural
sampleRate} -> Maybe Natural
sampleRate) (\s :: WavSettings
s@WavSettings' {} Maybe Natural
a -> WavSettings
s {$sel:sampleRate:WavSettings' :: Maybe Natural
sampleRate = Maybe Natural
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 Natural
-> Maybe Natural -> Maybe WavFormat -> Maybe Natural -> WavSettings
WavSettings'
            (Maybe Natural
 -> Maybe Natural
 -> Maybe WavFormat
 -> Maybe Natural
 -> WavSettings)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Natural -> Maybe WavFormat -> Maybe Natural -> WavSettings)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"bitDepth")
            Parser
  (Maybe Natural -> Maybe WavFormat -> Maybe Natural -> WavSettings)
-> Parser (Maybe Natural)
-> Parser (Maybe WavFormat -> Maybe Natural -> WavSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"channels")
            Parser (Maybe WavFormat -> Maybe Natural -> WavSettings)
-> Parser (Maybe WavFormat)
-> Parser (Maybe Natural -> WavSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe WavFormat)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"format")
            Parser (Maybe Natural -> WavSettings)
-> Parser (Maybe Natural) -> Parser WavSettings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
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 Natural
Maybe WavFormat
sampleRate :: Maybe Natural
format :: Maybe WavFormat
channels :: Maybe Natural
bitDepth :: Maybe Natural
$sel:sampleRate:WavSettings' :: WavSettings -> Maybe Natural
$sel:format:WavSettings' :: WavSettings -> Maybe WavFormat
$sel:channels:WavSettings' :: WavSettings -> Maybe Natural
$sel:bitDepth:WavSettings' :: WavSettings -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"bitDepth" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
bitDepth,
            (Text
"channels" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
channels,
            (Text
"format" Text -> WavFormat -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (WavFormat -> Pair) -> Maybe WavFormat -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe WavFormat
format,
            (Text
"sampleRate" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
sampleRate
          ]
      )