ScummVM API documentation
adlib_sfx_stream.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef NUVIE_SOUND_MIXER_DECODER_ADLIB_SFX_STREAM_H
23 #define NUVIE_SOUND_MIXER_DECODER_ADLIB_SFX_STREAM_H
24 
25 #include "ultima/shared/std/string.h"
26 #include "ultima/nuvie/sound/adplug/opl_class.h"
27 #include "audio/audiostream.h"
28 
29 namespace Ultima {
30 namespace Nuvie {
31 
32 class OriginFXAdLibDriver;
33 class Configuration;
34 
35 
36 using Std::string;
37 
39 public:
40  AdLibSfxStream() {
41  opl = nullptr;
42  duration = 0;
43  }
44 
45  AdLibSfxStream(const Configuration *cfg, int rate, uint8 channel, sint8 note, uint8 velocity, uint8 program_number, uint32 d);
46  ~AdLibSfxStream() override;
47 
48  int readBuffer(sint16 *buffer, const int numSamples) override;
49 
51  bool isStereo() const override {
52  return true;
53  }
54 
56  int getRate() const override {
57  return opl->getRate();
58  }
59 
60  bool rewind() override {
61  return false;
62  }
63 
71  bool endOfData() const override {
72  if (total_samples_played >= duration) {
73  return true;
74  }
75  return false;
76  }
77 
78  uint32 getLengthInMsec() {
79  return (uint32)(duration / (getRate() / 1000.0f));
80  }
81 protected:
82 
83  OplClass *opl;
84  OriginFXAdLibDriver *driver;
85  uint32 duration;
86  int interrupt_samples_left;
87  int interrupt_rate;
88  uint32 total_samples_played;
89 };
90 
91 } // End of namespace Nuvie
92 } // End of namespace Ultima
93 
94 #endif
Definition: adlib_sfx_stream.h:38
Definition: origin_fx_adib_driver.h:34
Definition: configuration.h:61
int getRate() const override
Definition: adlib_sfx_stream.h:56
Definition: detection.h:27
Definition: opl_class.h:176
Definition: audiostream.h:109
bool endOfData() const override
Definition: adlib_sfx_stream.h:71
bool rewind() override
Definition: adlib_sfx_stream.h:60
int readBuffer(sint16 *buffer, const int numSamples) override
bool isStereo() const override
Definition: adlib_sfx_stream.h:51