ScummVM API documentation
snd.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 LASTEXPRESS_SND_H
23 #define LASTEXPRESS_SND_H
24 
25 /*
26  Sound format (.SND / .LNK)
27 
28  uint32 {4} - data size
29  uint16 {2} - number of blocks
30 
31  // for each block
32  int16 {2} - initial sample
33  byte {1} - initial index
34  byte {1} - unused (00)
35  byte {x} - IMA ADPCM sample codes
36 */
37 
38 #include "audio/mixer.h"
39 
40 namespace Audio {
41 class AudioStream;
42 class QueuingAudioStream;
43 }
44 
45 namespace Common {
46 class SeekableReadStream;
47 }
48 
49 namespace LastExpress {
50 
51 class LastExpress_ADPCMStream;
52 
53 class SimpleSound {
54 public:
55  SimpleSound();
56  virtual ~SimpleSound();
57 
58  void stop() const;
59  virtual bool isFinished() = 0;
60 
61  uint32 getTimeMS();
62 
63 protected:
64  void loadHeader(Common::SeekableReadStream *in);
65  LastExpress_ADPCMStream *makeDecoder(Common::SeekableReadStream *in, uint32 size, uint32 volume, bool looped) const;
66  void play(Audio::AudioStream *as, DisposeAfterUse::Flag autofreeStream);
67 
68  uint32 _size;
69  uint16 _blocks;
73  uint32 _blockSize;
74  Audio::SoundHandle _handle;
75 };
76 
77 class StreamedSound : public SimpleSound {
78 public:
79  StreamedSound();
80  ~StreamedSound() override;
81 
82  bool load(Common::SeekableReadStream *stream, uint32 volume, bool looped, uint32 startBlock = 0);
83  bool isFinished() override;
84 
85  void setVolume(uint32 newVolume);
86  void setVolumeSmoothly(uint32 newVolume);
87 
88 private:
89  LastExpress_ADPCMStream *_as;
90  bool _loaded;
91 };
92 
93 class AppendableSound : public SimpleSound {
94 public:
96  ~AppendableSound() override;
97 
98  void queueBuffer(const byte *data, uint32 size);
99  void queueBuffer(Common::SeekableReadStream *bufferIn);
100  void finish();
101 
102  bool isFinished() override;
103 
104 private:
106  bool _finished;
107 };
108 
109 } // End of namespace LastExpress
110 
111 #endif // LASTEXPRESS_SND_H
uint32 _size
Definition: snd.h:68
Definition: snd.h:93
Definition: stream.h:745
Definition: animation.h:45
Definition: snd.h:53
Definition: snd.h:77
Definition: mixer.h:49
Definition: algorithm.h:29
Definition: audiostream.h:50
Definition: audiostream.h:370
Definition: system.h:38