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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(VorbisSettings -> VorbisSettings -> Bool)
-> (VorbisSettings -> VorbisSettings -> Bool) -> Eq VorbisSettings
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]
(Int -> ReadS VorbisSettings)
-> ReadS [VorbisSettings]
-> ReadPrec VorbisSettings
-> ReadPrec [VorbisSettings]
-> Read 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
(Int -> VorbisSettings -> ShowS)
-> (VorbisSettings -> String)
-> ([VorbisSettings] -> ShowS)
-> Show VorbisSettings
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. VorbisSettings -> Rep VorbisSettings x)
-> (forall x. Rep VorbisSettings x -> VorbisSettings)
-> Generic VorbisSettings
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' :: Maybe Natural -> Maybe Natural -> Maybe Int -> VorbisSettings
VorbisSettings'
    { $sel:channels:VorbisSettings' :: Maybe Natural
channels = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:sampleRate:VorbisSettings' :: Maybe Natural
sampleRate = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:vbrQuality:VorbisSettings' :: Maybe Int
vbrQuality = Maybe Int
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 :: (Maybe Natural -> f (Maybe Natural))
-> VorbisSettings -> f VorbisSettings
vorbisSettings_channels = (VorbisSettings -> Maybe Natural)
-> (VorbisSettings -> Maybe Natural -> VorbisSettings)
-> Lens
     VorbisSettings VorbisSettings (Maybe Natural) (Maybe Natural)
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 :: (Maybe Natural -> f (Maybe Natural))
-> VorbisSettings -> f VorbisSettings
vorbisSettings_sampleRate = (VorbisSettings -> Maybe Natural)
-> (VorbisSettings -> Maybe Natural -> VorbisSettings)
-> Lens
     VorbisSettings VorbisSettings (Maybe Natural) (Maybe Natural)
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 :: (Maybe Int -> f (Maybe Int)) -> VorbisSettings -> f VorbisSettings
vorbisSettings_vbrQuality = (VorbisSettings -> Maybe Int)
-> (VorbisSettings -> Maybe Int -> VorbisSettings)
-> Lens VorbisSettings VorbisSettings (Maybe Int) (Maybe Int)
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 Core.FromJSON VorbisSettings where
  parseJSON :: Value -> Parser VorbisSettings
parseJSON =
    String
-> (Object -> Parser VorbisSettings)
-> Value
-> Parser VorbisSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"VorbisSettings"
      ( \Object
x ->
          Maybe Natural -> Maybe Natural -> Maybe Int -> VorbisSettings
VorbisSettings'
            (Maybe Natural -> Maybe Natural -> Maybe Int -> VorbisSettings)
-> Parser (Maybe Natural)
-> Parser (Maybe Natural -> Maybe Int -> VorbisSettings)
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
"channels")
            Parser (Maybe Natural -> Maybe Int -> VorbisSettings)
-> Parser (Maybe Natural) -> Parser (Maybe Int -> VorbisSettings)
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")
            Parser (Maybe Int -> VorbisSettings)
-> Parser (Maybe Int) -> Parser VorbisSettings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"vbrQuality")
      )

instance Prelude.Hashable VorbisSettings

instance Prelude.NFData VorbisSettings

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