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 SOUND_HXX
19#define SOUND_HXX
20
21class OSystem;
22class AudioQueue;
23class EmulationTiming;
24
25#include "bspf.hxx"
26
27/**
28 This class is an abstract base class for the various sound objects.
29 It has no functionality whatsoever.
30
31 @author Stephen Anthony
32*/
33class Sound
34{
35 public:
36 /**
37 Create a new sound object. The open method must be invoked before
38 using the object.
39 */
40 Sound(OSystem& osystem) : myOSystem(osystem) { }
41 virtual ~Sound() = default;
42
43 public:
44 /**
45 Enables/disables the sound subsystem.
46
47 @param enable Either true or false, to enable or disable the sound system
48 */
49 virtual void setEnabled(bool enable) = 0;
50
51 /**
52 Start the sound system, initializing it if necessary. This must be
53 called before any calls are made to derived methods.
54 */
55 virtual void open(shared_ptr<AudioQueue>, EmulationTiming*) = 0;
56
57 /**
58 Should be called to stop the sound system. Once called the sound
59 device can be started again using the ::open() method.
60 */
61 virtual void close() = 0;
62
63 /**
64 Set the mute state of the sound object. While muted no sound is played.
65
66 @param state Mutes sound if true, unmute if false
67
68 @return The previous (old) mute state
69 */
70 virtual bool mute(bool state) = 0;
71
72 /**
73 Toggles the sound mute state. While muted no sound is played.
74
75 @return The previous (old) mute state
76 */
77 virtual bool toggleMute() = 0;
78
79 /**
80 Sets the volume of the sound device to the specified level. The
81 volume is given as a percentage from 0 to 100. Values outside
82 this range indicate that the volume shouldn't be changed at all.
83
84 @param percent The new volume percentage level for the sound device
85 */
86 virtual void setVolume(uInt32 percent) = 0;
87
88 /**
89 Adjusts the volume of the sound device based on the given direction.
90
91 @param direction Increase or decrease the current volume by a predefined
92 amount based on the direction (1 = increase, -1 =decrease)
93 */
94 virtual void adjustVolume(Int8 direction) = 0;
95
96 /**
97 This method is called to provide information about the sound device.
98 */
99 virtual string about() const = 0;
100
101 protected:
102 // The OSystem for this sound object
103 OSystem& myOSystem;
104
105 private:
106 // Following constructors and assignment operators not supported
107 Sound() = delete;
108 Sound(const Sound&) = delete;
109 Sound(Sound&&) = delete;
110 Sound& operator=(const Sound&) = delete;
111 Sound& operator=(Sound&&) = delete;
112};
113
114#endif
115