ScummVM API documentation
sound_object.h
1 
2 /* ScummVM - Graphic Adventure Engine
3  *
4  * ScummVM is the legal property of its developers, whose names
5  * are too numerous to list here. Please refer to the COPYRIGHT
6  * file distributed with this source distribution.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef BAGEL_BAGLIB_SOUND_OBJECT_H
24 #define BAGEL_BAGLIB_SOUND_OBJECT_H
25 
26 #include "bagel/baglib/object.h"
27 #include "bagel/baglib/bagel.h"
28 #include "bagel/boflib/sound.h"
29 
30 namespace Bagel {
31 
35 class CBagSoundObject : public CBagObject {
36 private:
37  static CBofSound *_pMidiSound; // There is only one allowed at a time
38  CBofSound *_pSound;
39 
40  uint16 _wFlags;
41  int _nLoops;
42  byte _nVol;
43 
44 protected:
45  byte _bWait;
46 
47 public:
49  virtual ~CBagSoundObject();
50  static void initialize();
51 
52  void killSound();
53  void newSound(CBofWindow *pWin);
54 
55  // Return true if the Object had members that are properly initialized/de-initialized
56  ErrorCode attach() override {
57  return attach((CBofWindow *)CBagel::getBagApp()->getMasterWnd());
58  }
59  ErrorCode attach(CBofWindow *pWnd);
60  bool isAttached() override {
61  return _pSound != nullptr;
62  }
63  ErrorCode detach() override;
64 
65  CBofSound *getLastMidi() {
66  return _pMidiSound;
67  }
68 
69  CBofSound *getSound() {
70  return _pSound;
71  }
72 
73  void setWave() {
74  _wFlags = SOUND_WAVE;
75  }
76  void setMidi() {
77  _wFlags = (SOUND_MIDI | SOUND_LOOP);
78  }
79 
80  // Gives ability to sound over certain sounds
81  void setSoundOver() {
82  _wFlags |= SOUND_OVEROK;
83  }
84 
85  void setSync(bool b = true);
86  void setASync(bool b = true) {
87  setSync(!b);
88  }
89  bool isSync() {
90  return _wFlags & SOUND_ASYNCH;
91  }
92 
93  void setMix() {
94  _wFlags = SOUND_MIX;
95  }
96  void setQueue(bool b = true);
97 
98  bool runObject() override;
99 
100  void setVolume(int nVol);
101  int getVolume();
102 
103  void setNumOfLoops(int n);
104 
105  int getProperty(const CBofString &sProp) override;
106  void setProperty(const CBofString &sProp, int nVal) override;
107 
112  ParseCodes setInfo(CBagIfstream &istr) override;
113 
114  // Added properties to sound object
115  bool isPlaying();
116  bool isQueued();
117 
118  void setPlaying(bool bVal = true);
119 };
120 
121 } // namespace Bagel
122 
123 #endif
Definition: window.h:50
ParseCodes setInfo(CBagIfstream &istr) override
Definition: sound.h:73
Definition: object.h:85
Definition: ifstream.h:31
Definition: string.h:38
Definition: bagel.h:31
Definition: sound_object.h:35