AudioSettings.hxx 3.82 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
//============================================================================
//
//   SSSS    tt          lll  lll
//  SS  SS   tt           ll   ll
//  SS     tttttt  eeee   ll   ll   aaaa
//   SSSS    tt   ee  ee  ll   ll      aa
//      SS   tt   eeeeee  ll   ll   aaaaa  --  "An Atari 2600 VCS Emulator"
//  SS  SS   tt   ee      ll   ll  aa  aa
//   SSSS     ttt  eeeee llll llll  aaaaa
//
11
// Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================

#ifndef AUDIO_PARAMTERS_HXX
#define AUDIO_PARAMTERS_HXX

#include "bspf.hxx"

class Settings;

class AudioSettings
{
  public:

    enum class Preset {
      custom                    = 1,
      lowQualityMediumLag       = 2,
      highQualityMediumLag      = 3,
      highQualityLowLag         = 4,
      veryHighQualityVeryLowLag = 5
    };

    enum class ResamplingQuality {
      nearestNeightbour   = 1,
      lanczos_2           = 2,
      lanczos_3           = 3
    };

    static constexpr const char* SETTING_PRESET              = "audio.preset";
    static constexpr const char* SETTING_SAMPLE_RATE         = "audio.sample_rate";
    static constexpr const char* SETTING_FRAGMENT_SIZE       = "audio.fragment_size";
    static constexpr const char* SETTING_BUFFER_SIZE         = "audio.buffer_size";
    static constexpr const char* SETTING_HEADROOM            = "audio.headroom";
    static constexpr const char* SETTING_RESAMPLING_QUALITY  = "audio.resampling_quality";
49
    static constexpr const char* SETTING_STEREO              = "audio.stereo";
50
51
52
53
54
55
56
57
58
    static constexpr const char* SETTING_VOLUME              = "audio.volume";
    static constexpr const char* SETTING_ENABLED             = "audio.enabled";

    static constexpr Preset DEFAULT_PRESET                          = Preset::highQualityMediumLag;
    static constexpr uInt32 DEFAULT_SAMPLE_RATE                     = 44100;
    static constexpr uInt32 DEFAULT_FRAGMENT_SIZE                   = 512;
    static constexpr uInt32 DEFAULT_BUFFER_SIZE                     = 3;
    static constexpr uInt32 DEFAULT_HEADROOM                        = 2;
    static constexpr ResamplingQuality DEFAULT_RESAMPLING_QUALITY   = ResamplingQuality::lanczos_2;
59
    static constexpr bool DEFAULT_STEREO                            = false;
60
61
62
    static constexpr uInt32 DEFAULT_VOLUME                          = 80;
    static constexpr bool DEFAULT_ENABLED                           = true;

Christian Speckner's avatar
Christian Speckner committed
63
64
65
    static constexpr int MAX_BUFFER_SIZE = 10;
    static constexpr int MAX_HEADROOM    = 10;

66
67
  public:

68
    explicit AudioSettings(Settings& mySettings);
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83

    static void normalize(Settings& settings);

    Preset preset();

    uInt32 sampleRate();

    uInt32 fragmentSize();

    uInt32 bufferSize();

    uInt32 headroom();

    ResamplingQuality resamplingQuality();

84
    bool stereo() const;
85

86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
    uInt32 volume() const;

    bool enabled() const;

    void setPreset(Preset preset);

    void setSampleRate(uInt32 sampleRate);

    void setFragmentSize(uInt32 fragmentSize);

    void setBufferSize(uInt32 bufferSize);

    void setHeadroom(uInt32 headroom);

    void setResamplingQuality(ResamplingQuality resamplingQuality);

102
    void setStereo(bool allROMs);
103

104
105
106
107
    void setVolume(uInt32 volume);

    void setEnabled(bool isEnabled);

Christian Speckner's avatar
Christian Speckner committed
108
109
    void setPersistent(bool isPersistent);

110
111
112
113
114
115
116
117
  private:

    bool customSettings() const;

    void updatePresetFromSettings();

  private:

118
    Settings& mySettings;
119
120
121
122
123
124
125
126

    Preset myPreset;

    uInt32 myPresetSampleRate;
    uInt32 myPresetFragmentSize;
    uInt32 myPresetBufferSize;
    uInt32 myPresetHeadroom;
    ResamplingQuality myPresetResamplingQuality;
Christian Speckner's avatar
Christian Speckner committed
127
128

    bool myIsPersistent;
129
130
131
};

#endif // AUDIO_PARAMTERS_HXX