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

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

-- | Required when you set Codec, under AudioDescriptions>CodecSettings, to
-- the value MP3.
--
-- /See:/ 'newMp3Settings' smart constructor.
data Mp3Settings = Mp3Settings'
  { -- | 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.
    Mp3Settings -> Maybe Natural
channels :: Prelude.Maybe Prelude.Natural,
    -- | Specify whether the service encodes this MP3 audio output with a
    -- constant bitrate (CBR) or a variable bitrate (VBR).
    Mp3Settings -> Maybe Mp3RateControlMode
rateControlMode :: Prelude.Maybe Mp3RateControlMode,
    -- | Sample rate in hz.
    Mp3Settings -> Maybe Natural
sampleRate :: Prelude.Maybe Prelude.Natural,
    -- | Specify the average bitrate in bits per second.
    Mp3Settings -> Maybe Natural
bitrate :: Prelude.Maybe Prelude.Natural,
    -- | Required when you set Bitrate control mode (rateControlMode) to VBR.
    -- Specify the audio quality of this MP3 output from 0 (highest quality) to
    -- 9 (lowest quality).
    Mp3Settings -> Maybe Natural
vbrQuality :: Prelude.Maybe Prelude.Natural
  }
  deriving (Mp3Settings -> Mp3Settings -> Bool
(Mp3Settings -> Mp3Settings -> Bool)
-> (Mp3Settings -> Mp3Settings -> Bool) -> Eq Mp3Settings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Mp3Settings -> Mp3Settings -> Bool
$c/= :: Mp3Settings -> Mp3Settings -> Bool
== :: Mp3Settings -> Mp3Settings -> Bool
$c== :: Mp3Settings -> Mp3Settings -> Bool
Prelude.Eq, ReadPrec [Mp3Settings]
ReadPrec Mp3Settings
Int -> ReadS Mp3Settings
ReadS [Mp3Settings]
(Int -> ReadS Mp3Settings)
-> ReadS [Mp3Settings]
-> ReadPrec Mp3Settings
-> ReadPrec [Mp3Settings]
-> Read Mp3Settings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Mp3Settings]
$creadListPrec :: ReadPrec [Mp3Settings]
readPrec :: ReadPrec Mp3Settings
$creadPrec :: ReadPrec Mp3Settings
readList :: ReadS [Mp3Settings]
$creadList :: ReadS [Mp3Settings]
readsPrec :: Int -> ReadS Mp3Settings
$creadsPrec :: Int -> ReadS Mp3Settings
Prelude.Read, Int -> Mp3Settings -> ShowS
[Mp3Settings] -> ShowS
Mp3Settings -> String
(Int -> Mp3Settings -> ShowS)
-> (Mp3Settings -> String)
-> ([Mp3Settings] -> ShowS)
-> Show Mp3Settings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Mp3Settings] -> ShowS
$cshowList :: [Mp3Settings] -> ShowS
show :: Mp3Settings -> String
$cshow :: Mp3Settings -> String
showsPrec :: Int -> Mp3Settings -> ShowS
$cshowsPrec :: Int -> Mp3Settings -> ShowS
Prelude.Show, (forall x. Mp3Settings -> Rep Mp3Settings x)
-> (forall x. Rep Mp3Settings x -> Mp3Settings)
-> Generic Mp3Settings
forall x. Rep Mp3Settings x -> Mp3Settings
forall x. Mp3Settings -> Rep Mp3Settings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Mp3Settings x -> Mp3Settings
$cfrom :: forall x. Mp3Settings -> Rep Mp3Settings x
Prelude.Generic)

-- |
-- Create a value of 'Mp3Settings' 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', 'mp3Settings_channels' - 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.
--
-- 'rateControlMode', 'mp3Settings_rateControlMode' - Specify whether the service encodes this MP3 audio output with a
-- constant bitrate (CBR) or a variable bitrate (VBR).
--
-- 'sampleRate', 'mp3Settings_sampleRate' - Sample rate in hz.
--
-- 'bitrate', 'mp3Settings_bitrate' - Specify the average bitrate in bits per second.
--
-- 'vbrQuality', 'mp3Settings_vbrQuality' - Required when you set Bitrate control mode (rateControlMode) to VBR.
-- Specify the audio quality of this MP3 output from 0 (highest quality) to
-- 9 (lowest quality).
newMp3Settings ::
  Mp3Settings
newMp3Settings :: Mp3Settings
newMp3Settings =
  Mp3Settings' :: Maybe Natural
-> Maybe Mp3RateControlMode
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Mp3Settings
Mp3Settings'
    { $sel:channels:Mp3Settings' :: Maybe Natural
channels = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:rateControlMode:Mp3Settings' :: Maybe Mp3RateControlMode
rateControlMode = Maybe Mp3RateControlMode
forall a. Maybe a
Prelude.Nothing,
      $sel:sampleRate:Mp3Settings' :: Maybe Natural
sampleRate = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:bitrate:Mp3Settings' :: Maybe Natural
bitrate = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:vbrQuality:Mp3Settings' :: Maybe Natural
vbrQuality = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | 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.
mp3Settings_channels :: Lens.Lens' Mp3Settings (Prelude.Maybe Prelude.Natural)
mp3Settings_channels :: (Maybe Natural -> f (Maybe Natural))
-> Mp3Settings -> f Mp3Settings
mp3Settings_channels = (Mp3Settings -> Maybe Natural)
-> (Mp3Settings -> Maybe Natural -> Mp3Settings)
-> Lens Mp3Settings Mp3Settings (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Mp3Settings' {Maybe Natural
channels :: Maybe Natural
$sel:channels:Mp3Settings' :: Mp3Settings -> Maybe Natural
channels} -> Maybe Natural
channels) (\s :: Mp3Settings
s@Mp3Settings' {} Maybe Natural
a -> Mp3Settings
s {$sel:channels:Mp3Settings' :: Maybe Natural
channels = Maybe Natural
a} :: Mp3Settings)

-- | Specify whether the service encodes this MP3 audio output with a
-- constant bitrate (CBR) or a variable bitrate (VBR).
mp3Settings_rateControlMode :: Lens.Lens' Mp3Settings (Prelude.Maybe Mp3RateControlMode)
mp3Settings_rateControlMode :: (Maybe Mp3RateControlMode -> f (Maybe Mp3RateControlMode))
-> Mp3Settings -> f Mp3Settings
mp3Settings_rateControlMode = (Mp3Settings -> Maybe Mp3RateControlMode)
-> (Mp3Settings -> Maybe Mp3RateControlMode -> Mp3Settings)
-> Lens
     Mp3Settings
     Mp3Settings
     (Maybe Mp3RateControlMode)
     (Maybe Mp3RateControlMode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Mp3Settings' {Maybe Mp3RateControlMode
rateControlMode :: Maybe Mp3RateControlMode
$sel:rateControlMode:Mp3Settings' :: Mp3Settings -> Maybe Mp3RateControlMode
rateControlMode} -> Maybe Mp3RateControlMode
rateControlMode) (\s :: Mp3Settings
s@Mp3Settings' {} Maybe Mp3RateControlMode
a -> Mp3Settings
s {$sel:rateControlMode:Mp3Settings' :: Maybe Mp3RateControlMode
rateControlMode = Maybe Mp3RateControlMode
a} :: Mp3Settings)

-- | Sample rate in hz.
mp3Settings_sampleRate :: Lens.Lens' Mp3Settings (Prelude.Maybe Prelude.Natural)
mp3Settings_sampleRate :: (Maybe Natural -> f (Maybe Natural))
-> Mp3Settings -> f Mp3Settings
mp3Settings_sampleRate = (Mp3Settings -> Maybe Natural)
-> (Mp3Settings -> Maybe Natural -> Mp3Settings)
-> Lens Mp3Settings Mp3Settings (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Mp3Settings' {Maybe Natural
sampleRate :: Maybe Natural
$sel:sampleRate:Mp3Settings' :: Mp3Settings -> Maybe Natural
sampleRate} -> Maybe Natural
sampleRate) (\s :: Mp3Settings
s@Mp3Settings' {} Maybe Natural
a -> Mp3Settings
s {$sel:sampleRate:Mp3Settings' :: Maybe Natural
sampleRate = Maybe Natural
a} :: Mp3Settings)

-- | Specify the average bitrate in bits per second.
mp3Settings_bitrate :: Lens.Lens' Mp3Settings (Prelude.Maybe Prelude.Natural)
mp3Settings_bitrate :: (Maybe Natural -> f (Maybe Natural))
-> Mp3Settings -> f Mp3Settings
mp3Settings_bitrate = (Mp3Settings -> Maybe Natural)
-> (Mp3Settings -> Maybe Natural -> Mp3Settings)
-> Lens Mp3Settings Mp3Settings (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Mp3Settings' {Maybe Natural
bitrate :: Maybe Natural
$sel:bitrate:Mp3Settings' :: Mp3Settings -> Maybe Natural
bitrate} -> Maybe Natural
bitrate) (\s :: Mp3Settings
s@Mp3Settings' {} Maybe Natural
a -> Mp3Settings
s {$sel:bitrate:Mp3Settings' :: Maybe Natural
bitrate = Maybe Natural
a} :: Mp3Settings)

-- | Required when you set Bitrate control mode (rateControlMode) to VBR.
-- Specify the audio quality of this MP3 output from 0 (highest quality) to
-- 9 (lowest quality).
mp3Settings_vbrQuality :: Lens.Lens' Mp3Settings (Prelude.Maybe Prelude.Natural)
mp3Settings_vbrQuality :: (Maybe Natural -> f (Maybe Natural))
-> Mp3Settings -> f Mp3Settings
mp3Settings_vbrQuality = (Mp3Settings -> Maybe Natural)
-> (Mp3Settings -> Maybe Natural -> Mp3Settings)
-> Lens Mp3Settings Mp3Settings (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Mp3Settings' {Maybe Natural
vbrQuality :: Maybe Natural
$sel:vbrQuality:Mp3Settings' :: Mp3Settings -> Maybe Natural
vbrQuality} -> Maybe Natural
vbrQuality) (\s :: Mp3Settings
s@Mp3Settings' {} Maybe Natural
a -> Mp3Settings
s {$sel:vbrQuality:Mp3Settings' :: Maybe Natural
vbrQuality = Maybe Natural
a} :: Mp3Settings)

instance Core.FromJSON Mp3Settings where
  parseJSON :: Value -> Parser Mp3Settings
parseJSON =
    String
-> (Object -> Parser Mp3Settings) -> Value -> Parser Mp3Settings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Mp3Settings"
      ( \Object
x ->
          Maybe Natural
-> Maybe Mp3RateControlMode
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Mp3Settings
Mp3Settings'
            (Maybe Natural
 -> Maybe Mp3RateControlMode
 -> Maybe Natural
 -> Maybe Natural
 -> Maybe Natural
 -> Mp3Settings)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Mp3RateControlMode
      -> Maybe Natural -> Maybe Natural -> Maybe Natural -> Mp3Settings)
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 Mp3RateControlMode
   -> Maybe Natural -> Maybe Natural -> Maybe Natural -> Mp3Settings)
-> Parser (Maybe Mp3RateControlMode)
-> Parser
     (Maybe Natural -> Maybe Natural -> Maybe Natural -> Mp3Settings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Mp3RateControlMode)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"rateControlMode")
            Parser
  (Maybe Natural -> Maybe Natural -> Maybe Natural -> Mp3Settings)
-> Parser (Maybe Natural)
-> Parser (Maybe Natural -> Maybe Natural -> Mp3Settings)
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 Natural -> Maybe Natural -> Mp3Settings)
-> Parser (Maybe Natural) -> Parser (Maybe Natural -> Mp3Settings)
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
"bitrate")
            Parser (Maybe Natural -> Mp3Settings)
-> Parser (Maybe Natural) -> Parser Mp3Settings
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
"vbrQuality")
      )

instance Prelude.Hashable Mp3Settings

instance Prelude.NFData Mp3Settings

instance Core.ToJSON Mp3Settings where
  toJSON :: Mp3Settings -> Value
toJSON Mp3Settings' {Maybe Natural
Maybe Mp3RateControlMode
vbrQuality :: Maybe Natural
bitrate :: Maybe Natural
sampleRate :: Maybe Natural
rateControlMode :: Maybe Mp3RateControlMode
channels :: Maybe Natural
$sel:vbrQuality:Mp3Settings' :: Mp3Settings -> Maybe Natural
$sel:bitrate:Mp3Settings' :: Mp3Settings -> Maybe Natural
$sel:sampleRate:Mp3Settings' :: Mp3Settings -> Maybe Natural
$sel:rateControlMode:Mp3Settings' :: Mp3Settings -> Maybe Mp3RateControlMode
$sel:channels:Mp3Settings' :: Mp3Settings -> 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
"rateControlMode" Text -> Mp3RateControlMode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Mp3RateControlMode -> Pair)
-> Maybe Mp3RateControlMode -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Mp3RateControlMode
rateControlMode,
            (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
"bitrate" 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
bitrate,
            (Text
"vbrQuality" 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
vbrQuality
          ]
      )