{-# 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.VorbisSettings
-- 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.VorbisSettings where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Required when you set Codec, under AudioDescriptions>CodecSettings, to
-- the value Vorbis.
--
-- /See:/ 'newVorbisSettings' smart constructor.
data VorbisSettings = VorbisSettings'
  { -- | Optional. Specify the number of channels in this output audio track.
    -- Choosing Mono on the console gives you 1 output channel; choosing Stereo
    -- gives you 2. In the API, valid values are 1 and 2. The default value is
    -- 2.
    VorbisSettings -> Maybe Natural
channels :: Prelude.Maybe Prelude.Natural,
    -- | Optional. Specify the audio sample rate in Hz. Valid values are 22050,
    -- 32000, 44100, and 48000. The default value is 48000.
    VorbisSettings -> Maybe Natural
sampleRate :: Prelude.Maybe Prelude.Natural,
    -- | Optional. Specify the variable audio quality of this Vorbis output from
    -- -1 (lowest quality, ~45 kbit\/s) to 10 (highest quality, ~500 kbit\/s).
    -- The default value is 4 (~128 kbit\/s). Values 5 and 6 are approximately
    -- 160 and 192 kbit\/s, respectively.
    VorbisSettings -> Maybe Int
vbrQuality :: Prelude.Maybe Prelude.Int
  }
  deriving (VorbisSettings -> VorbisSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VorbisSettings -> VorbisSettings -> Bool
$c/= :: VorbisSettings -> VorbisSettings -> Bool
== :: VorbisSettings -> VorbisSettings -> Bool
$c== :: VorbisSettings -> VorbisSettings -> Bool
Prelude.Eq, ReadPrec [VorbisSettings]
ReadPrec VorbisSettings
Int -> ReadS VorbisSettings
ReadS [VorbisSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VorbisSettings]
$creadListPrec :: ReadPrec [VorbisSettings]
readPrec :: ReadPrec VorbisSettings
$creadPrec :: ReadPrec VorbisSettings
readList :: ReadS [VorbisSettings]
$creadList :: ReadS [VorbisSettings]
readsPrec :: Int -> ReadS VorbisSettings
$creadsPrec :: Int -> ReadS VorbisSettings
Prelude.Read, Int -> VorbisSettings -> ShowS
[VorbisSettings] -> ShowS
VorbisSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VorbisSettings] -> ShowS
$cshowList :: [VorbisSettings] -> ShowS
show :: VorbisSettings -> String
$cshow :: VorbisSettings -> String
showsPrec :: Int -> VorbisSettings -> ShowS
$cshowsPrec :: Int -> VorbisSettings -> ShowS
Prelude.Show, forall x. Rep VorbisSettings x -> VorbisSettings
forall x. VorbisSettings -> Rep VorbisSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep VorbisSettings x -> VorbisSettings
$cfrom :: forall x. VorbisSettings -> Rep VorbisSettings x
Prelude.Generic)

-- |
-- Create a value of 'VorbisSettings' 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:
--
-- 'channels', 'vorbisSettings_channels' - Optional. Specify the number of channels in this output audio track.
-- Choosing Mono on the console gives you 1 output channel; choosing Stereo
-- gives you 2. In the API, valid values are 1 and 2. The default value is
-- 2.
--
-- 'sampleRate', 'vorbisSettings_sampleRate' - Optional. Specify the audio sample rate in Hz. Valid values are 22050,
-- 32000, 44100, and 48000. The default value is 48000.
--
-- 'vbrQuality', 'vorbisSettings_vbrQuality' - Optional. Specify the variable audio quality of this Vorbis output from
-- -1 (lowest quality, ~45 kbit\/s) to 10 (highest quality, ~500 kbit\/s).
-- The default value is 4 (~128 kbit\/s). Values 5 and 6 are approximately
-- 160 and 192 kbit\/s, respectively.
newVorbisSettings ::
  VorbisSettings
newVorbisSettings :: VorbisSettings
newVorbisSettings =
  VorbisSettings'
    { $sel:channels:VorbisSettings' :: Maybe Natural
channels = forall a. Maybe a
Prelude.Nothing,
      $sel:sampleRate:VorbisSettings' :: Maybe Natural
sampleRate = forall a. Maybe a
Prelude.Nothing,
      $sel:vbrQuality:VorbisSettings' :: Maybe Int
vbrQuality = forall a. Maybe a
Prelude.Nothing
    }

-- | Optional. Specify the number of channels in this output audio track.
-- Choosing Mono on the console gives you 1 output channel; choosing Stereo
-- gives you 2. In the API, valid values are 1 and 2. The default value is
-- 2.
vorbisSettings_channels :: Lens.Lens' VorbisSettings (Prelude.Maybe Prelude.Natural)
vorbisSettings_channels :: Lens' VorbisSettings (Maybe Natural)
vorbisSettings_channels = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VorbisSettings' {Maybe Natural
channels :: Maybe Natural
$sel:channels:VorbisSettings' :: VorbisSettings -> Maybe Natural
channels} -> Maybe Natural
channels) (\s :: VorbisSettings
s@VorbisSettings' {} Maybe Natural
a -> VorbisSettings
s {$sel:channels:VorbisSettings' :: Maybe Natural
channels = Maybe Natural
a} :: VorbisSettings)

-- | Optional. Specify the audio sample rate in Hz. Valid values are 22050,
-- 32000, 44100, and 48000. The default value is 48000.
vorbisSettings_sampleRate :: Lens.Lens' VorbisSettings (Prelude.Maybe Prelude.Natural)
vorbisSettings_sampleRate :: Lens' VorbisSettings (Maybe Natural)
vorbisSettings_sampleRate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VorbisSettings' {Maybe Natural
sampleRate :: Maybe Natural
$sel:sampleRate:VorbisSettings' :: VorbisSettings -> Maybe Natural
sampleRate} -> Maybe Natural
sampleRate) (\s :: VorbisSettings
s@VorbisSettings' {} Maybe Natural
a -> VorbisSettings
s {$sel:sampleRate:VorbisSettings' :: Maybe Natural
sampleRate = Maybe Natural
a} :: VorbisSettings)

-- | Optional. Specify the variable audio quality of this Vorbis output from
-- -1 (lowest quality, ~45 kbit\/s) to 10 (highest quality, ~500 kbit\/s).
-- The default value is 4 (~128 kbit\/s). Values 5 and 6 are approximately
-- 160 and 192 kbit\/s, respectively.
vorbisSettings_vbrQuality :: Lens.Lens' VorbisSettings (Prelude.Maybe Prelude.Int)
vorbisSettings_vbrQuality :: Lens' VorbisSettings (Maybe Int)
vorbisSettings_vbrQuality = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VorbisSettings' {Maybe Int
vbrQuality :: Maybe Int
$sel:vbrQuality:VorbisSettings' :: VorbisSettings -> Maybe Int
vbrQuality} -> Maybe Int
vbrQuality) (\s :: VorbisSettings
s@VorbisSettings' {} Maybe Int
a -> VorbisSettings
s {$sel:vbrQuality:VorbisSettings' :: Maybe Int
vbrQuality = Maybe Int
a} :: VorbisSettings)

instance Data.FromJSON VorbisSettings where
  parseJSON :: Value -> Parser VorbisSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"VorbisSettings"
      ( \Object
x ->
          Maybe Natural -> Maybe Natural -> Maybe Int -> VorbisSettings
VorbisSettings'
            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
"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
"sampleRate")
            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
"vbrQuality")
      )

instance Prelude.Hashable VorbisSettings where
  hashWithSalt :: Int -> VorbisSettings -> Int
hashWithSalt Int
_salt VorbisSettings' {Maybe Int
Maybe Natural
vbrQuality :: Maybe Int
sampleRate :: Maybe Natural
channels :: Maybe Natural
$sel:vbrQuality:VorbisSettings' :: VorbisSettings -> Maybe Int
$sel:sampleRate:VorbisSettings' :: VorbisSettings -> Maybe Natural
$sel:channels:VorbisSettings' :: VorbisSettings -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
channels
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
sampleRate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
vbrQuality

instance Prelude.NFData VorbisSettings where
  rnf :: VorbisSettings -> ()
rnf VorbisSettings' {Maybe Int
Maybe Natural
vbrQuality :: Maybe Int
sampleRate :: Maybe Natural
channels :: Maybe Natural
$sel:vbrQuality:VorbisSettings' :: VorbisSettings -> Maybe Int
$sel:sampleRate:VorbisSettings' :: VorbisSettings -> Maybe Natural
$sel:channels:VorbisSettings' :: VorbisSettings -> Maybe Natural
..} =
    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 Natural
sampleRate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
vbrQuality

instance Data.ToJSON VorbisSettings where
  toJSON :: VorbisSettings -> Value
toJSON VorbisSettings' {Maybe Int
Maybe Natural
vbrQuality :: Maybe Int
sampleRate :: Maybe Natural
channels :: Maybe Natural
$sel:vbrQuality:VorbisSettings' :: VorbisSettings -> Maybe Int
$sel:sampleRate:VorbisSettings' :: VorbisSettings -> Maybe Natural
$sel:channels:VorbisSettings' :: VorbisSettings -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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
"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,
            (Key
"vbrQuality" 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 Int
vbrQuality
          ]
      )