{-# 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-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.Mp3Settings 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.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 average bitrate in bits per second.
    Mp3Settings -> Maybe Natural
bitrate :: Prelude.Maybe Prelude.Natural,
    -- | 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,
    -- | 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
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]
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
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. 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:
--
-- 'bitrate', 'mp3Settings_bitrate' - Specify the average bitrate in bits per second.
--
-- '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.
--
-- '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'
    { $sel:bitrate:Mp3Settings' :: Maybe Natural
bitrate = forall a. Maybe a
Prelude.Nothing,
      $sel:channels:Mp3Settings' :: Maybe Natural
channels = forall a. Maybe a
Prelude.Nothing,
      $sel:rateControlMode:Mp3Settings' :: Maybe Mp3RateControlMode
rateControlMode = forall a. Maybe a
Prelude.Nothing,
      $sel:sampleRate:Mp3Settings' :: Maybe Natural
sampleRate = forall a. Maybe a
Prelude.Nothing,
      $sel:vbrQuality:Mp3Settings' :: Maybe Natural
vbrQuality = forall a. Maybe a
Prelude.Nothing
    }

-- | Specify the average bitrate in bits per second.
mp3Settings_bitrate :: Lens.Lens' Mp3Settings (Prelude.Maybe Prelude.Natural)
mp3Settings_bitrate :: Lens' Mp3Settings (Maybe Natural)
mp3Settings_bitrate = 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)

-- | 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 :: Lens' Mp3Settings (Maybe Natural)
mp3Settings_channels = 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 :: Lens' Mp3Settings (Maybe Mp3RateControlMode)
mp3Settings_rateControlMode = 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 :: Lens' Mp3Settings (Maybe Natural)
mp3Settings_sampleRate = 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)

-- | 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 :: Lens' Mp3Settings (Maybe Natural)
mp3Settings_vbrQuality = 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 Data.FromJSON Mp3Settings where
  parseJSON :: Value -> Parser Mp3Settings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Mp3Settings"
      ( \Object
x ->
          Maybe Natural
-> Maybe Natural
-> Maybe Mp3RateControlMode
-> Maybe Natural
-> Maybe Natural
-> Mp3Settings
Mp3Settings'
            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
"bitrate")
            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
"rateControlMode")
            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 Mp3Settings where
  hashWithSalt :: Int -> Mp3Settings -> Int
hashWithSalt Int
_salt Mp3Settings' {Maybe Natural
Maybe Mp3RateControlMode
vbrQuality :: Maybe Natural
sampleRate :: Maybe Natural
rateControlMode :: Maybe Mp3RateControlMode
channels :: Maybe Natural
bitrate :: Maybe Natural
$sel:vbrQuality:Mp3Settings' :: Mp3Settings -> Maybe Natural
$sel:sampleRate:Mp3Settings' :: Mp3Settings -> Maybe Natural
$sel:rateControlMode:Mp3Settings' :: Mp3Settings -> Maybe Mp3RateControlMode
$sel:channels:Mp3Settings' :: Mp3Settings -> Maybe Natural
$sel:bitrate:Mp3Settings' :: Mp3Settings -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
bitrate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
channels
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Mp3RateControlMode
rateControlMode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
sampleRate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
vbrQuality

instance Prelude.NFData Mp3Settings where
  rnf :: Mp3Settings -> ()
rnf Mp3Settings' {Maybe Natural
Maybe Mp3RateControlMode
vbrQuality :: Maybe Natural
sampleRate :: Maybe Natural
rateControlMode :: Maybe Mp3RateControlMode
channels :: Maybe Natural
bitrate :: Maybe Natural
$sel:vbrQuality:Mp3Settings' :: Mp3Settings -> Maybe Natural
$sel:sampleRate:Mp3Settings' :: Mp3Settings -> Maybe Natural
$sel:rateControlMode:Mp3Settings' :: Mp3Settings -> Maybe Mp3RateControlMode
$sel:channels:Mp3Settings' :: Mp3Settings -> Maybe Natural
$sel:bitrate:Mp3Settings' :: Mp3Settings -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
bitrate
      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 Mp3RateControlMode
rateControlMode
      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 Natural
vbrQuality

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