{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MediaConvert.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.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
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' - 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'
    { $sel:bitDepth:WavSettings' :: Maybe Natural
bitDepth = forall a. Maybe a
Prelude.Nothing,
      $sel:channels:WavSettings' :: Maybe Natural
channels = forall a. Maybe a
Prelude.Nothing,
      $sel:format:WavSettings' :: Maybe WavFormat
format = forall a. Maybe a
Prelude.Nothing,
      $sel:sampleRate:WavSettings' :: Maybe Natural
sampleRate = 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 :: Lens' WavSettings (Maybe Natural)
wavSettings_bitDepth = 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 :: Lens' WavSettings (Maybe Natural)
wavSettings_channels = 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 :: Lens' WavSettings (Maybe WavFormat)
wavSettings_format = 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 :: Lens' WavSettings (Maybe Natural)
wavSettings_sampleRate = 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 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 Natural
-> Maybe Natural -> Maybe WavFormat -> Maybe Natural -> 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
"channels")
            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
"format")
            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 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
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
bitDepth
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
channels
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe WavFormat
format
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
sampleRate

instance Prelude.NFData WavSettings where
  rnf :: WavSettings -> ()
rnf 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
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
bitDepth
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
channels
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe WavFormat
format
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
sampleRate

instance Data.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
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 Natural
bitDepth,
            (Key
"channels" 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 Natural
channels,
            (Key
"format" 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 WavFormat
format,
            (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 Natural
sampleRate
          ]
      )