| 1 | //============================================================================ |
| 2 | // |
| 3 | // SSSS tt lll lll |
| 4 | // SS SS tt ll ll |
| 5 | // SS tttttt eeee ll ll aaaa |
| 6 | // SSSS tt ee ee ll ll aa |
| 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" |
| 8 | // SS SS tt ee ll ll aa aa |
| 9 | // SSSS ttt eeeee llll llll aaaaa |
| 10 | // |
| 11 | // Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony |
| 12 | // and the Stella Team |
| 13 | // |
| 14 | // See the file "License.txt" for information on usage and redistribution of |
| 15 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 16 | //============================================================================ |
| 17 | |
| 18 | #ifndef AUDIO_PARAMTERS_HXX |
| 19 | #define AUDIO_PARAMTERS_HXX |
| 20 | |
| 21 | #include "bspf.hxx" |
| 22 | |
| 23 | class Settings; |
| 24 | |
| 25 | class AudioSettings |
| 26 | { |
| 27 | public: |
| 28 | |
| 29 | enum class Preset { |
| 30 | custom = 1, |
| 31 | lowQualityMediumLag = 2, |
| 32 | highQualityMediumLag = 3, |
| 33 | highQualityLowLag = 4, |
| 34 | ultraQualityMinimalLag = 5 |
| 35 | }; |
| 36 | |
| 37 | enum class ResamplingQuality { |
| 38 | nearestNeightbour = 1, |
| 39 | lanczos_2 = 2, |
| 40 | lanczos_3 = 3 |
| 41 | }; |
| 42 | |
| 43 | static constexpr const char* SETTING_PRESET = "audio.preset" ; |
| 44 | static constexpr const char* SETTING_SAMPLE_RATE = "audio.sample_rate" ; |
| 45 | static constexpr const char* SETTING_FRAGMENT_SIZE = "audio.fragment_size" ; |
| 46 | static constexpr const char* SETTING_BUFFER_SIZE = "audio.buffer_size" ; |
| 47 | static constexpr const char* SETTING_HEADROOM = "audio.headroom" ; |
| 48 | static constexpr const char* SETTING_RESAMPLING_QUALITY = "audio.resampling_quality" ; |
| 49 | static constexpr const char* SETTING_STEREO = "audio.stereo" ; |
| 50 | static constexpr const char* SETTING_VOLUME = "audio.volume" ; |
| 51 | static constexpr const char* SETTING_ENABLED = "audio.enabled" ; |
| 52 | static constexpr const char* SETTING_DPC_PITCH = "audio.dpc_pitch" ; |
| 53 | |
| 54 | static constexpr Preset DEFAULT_PRESET = Preset::highQualityMediumLag; |
| 55 | static constexpr uInt32 DEFAULT_SAMPLE_RATE = 44100; |
| 56 | static constexpr uInt32 DEFAULT_FRAGMENT_SIZE = 512; |
| 57 | static constexpr uInt32 DEFAULT_BUFFER_SIZE = 3; |
| 58 | static constexpr uInt32 DEFAULT_HEADROOM = 2; |
| 59 | static constexpr ResamplingQuality DEFAULT_RESAMPLING_QUALITY = ResamplingQuality::lanczos_2; |
| 60 | static constexpr bool DEFAULT_STEREO = false; |
| 61 | static constexpr uInt32 DEFAULT_VOLUME = 80; |
| 62 | static constexpr bool DEFAULT_ENABLED = true; |
| 63 | static constexpr uInt32 DEFAULT_DPC_PITCH = 20000; |
| 64 | |
| 65 | static constexpr int MAX_BUFFER_SIZE = 10; |
| 66 | static constexpr int MAX_HEADROOM = 10; |
| 67 | |
| 68 | public: |
| 69 | |
| 70 | explicit AudioSettings(Settings& mySettings); |
| 71 | |
| 72 | static void normalize(Settings& settings); |
| 73 | |
| 74 | Preset preset(); |
| 75 | |
| 76 | uInt32 sampleRate(); |
| 77 | |
| 78 | uInt32 fragmentSize(); |
| 79 | |
| 80 | uInt32 bufferSize(); |
| 81 | |
| 82 | uInt32 headroom(); |
| 83 | |
| 84 | ResamplingQuality resamplingQuality(); |
| 85 | |
| 86 | bool stereo() const; |
| 87 | |
| 88 | uInt32 volume() const; |
| 89 | |
| 90 | bool enabled() const; |
| 91 | |
| 92 | uInt32 dpcPitch() const; |
| 93 | |
| 94 | void setPreset(Preset preset); |
| 95 | |
| 96 | void setSampleRate(uInt32 sampleRate); |
| 97 | |
| 98 | void setFragmentSize(uInt32 fragmentSize); |
| 99 | |
| 100 | void setBufferSize(uInt32 bufferSize); |
| 101 | |
| 102 | void setHeadroom(uInt32 headroom); |
| 103 | |
| 104 | void setResamplingQuality(ResamplingQuality resamplingQuality); |
| 105 | |
| 106 | void setStereo(bool allROMs); |
| 107 | |
| 108 | void setDpcPitch(uInt32 pitch); |
| 109 | |
| 110 | void setVolume(uInt32 volume); |
| 111 | |
| 112 | void setEnabled(bool isEnabled); |
| 113 | |
| 114 | void setPersistent(bool isPersistent); |
| 115 | |
| 116 | private: |
| 117 | |
| 118 | bool customSettings() const; |
| 119 | |
| 120 | void updatePresetFromSettings(); |
| 121 | |
| 122 | private: |
| 123 | |
| 124 | Settings& mySettings; |
| 125 | |
| 126 | Preset myPreset; |
| 127 | |
| 128 | uInt32 myPresetSampleRate; |
| 129 | uInt32 myPresetFragmentSize; |
| 130 | uInt32 myPresetBufferSize; |
| 131 | uInt32 myPresetHeadroom; |
| 132 | ResamplingQuality myPresetResamplingQuality; |
| 133 | |
| 134 | bool myIsPersistent; |
| 135 | }; |
| 136 | |
| 137 | #endif // AUDIO_PARAMTERS_HXX |
| 138 | |