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 "common/str.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 
37 public:
38  AdLibSfxStream() {
39  opl = nullptr;
40  duration = 0;
41  }
42 
43  AdLibSfxStream(const Configuration *cfg, int rate, uint8 channel, sint8 note, uint8 velocity, uint8 program_number, uint32 d);
44  ~AdLibSfxStream() override;
45 
46  int readBuffer(sint16 *buffer, const int numSamples) override;
47 
49  bool isStereo() const override {
50  return true;
51  }
52 
54  int getRate() const override {
55  return opl->getRate();
56  }
57 
58  bool rewind() override {
59  return false;
60  }
61 
69  bool endOfData() const override {
70  if (total_samples_played >= duration) {
71  return true;
72  }
73  return false;
74  }
75 
76  uint32 getLengthInMsec() {
77  return (uint32)(duration / (getRate() / 1000.0f));
78  }
79 protected:
80 
81  OplClass *opl;
82  OriginFXAdLibDriver *driver;
83  uint32 duration;
84  int interrupt_samples_left;
85  int interrupt_rate;
86  uint32 total_samples_played;
87 };
88 
89 } // End of namespace Nuvie
90 } // End of namespace Ultima
91 
92 #endif
Definition: adlib_sfx_stream.h:36
Definition: origin_fx_adib_driver.h:34
Definition: configuration.h:61
int getRate() const override
Definition: adlib_sfx_stream.h:54
Definition: detection.h:27
Definition: opl_class.h:176
Definition: audiostream.h:109
bool endOfData() const override
Definition: adlib_sfx_stream.h:69
bool rewind() override
Definition: adlib_sfx_stream.h:58
int readBuffer(sint16 *buffer, const int numSamples) override
bool isStereo() const override
Definition: adlib_sfx_stream.h:49