ScummVM API documentation
vgmsamp.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  * VGMTrans (c) 2002-2019
23  * Licensed under the zlib license,
24  * refer to the included VGMTrans_LICENSE.txt file
25  */
26 #ifndef AUDIO_SOUNDFONT_VGMSAMP_H
27 #define AUDIO_SOUNDFONT_VGMSAMP_H
28 
29 #include "audio/soundfont/common.h"
30 #include "common/scummsys.h"
31 #include "common/str.h"
32 #include "audio/soundfont/vgmitem.h"
33 
34 class VGMSampColl;
35 class VGMInstrSet;
36 
37 enum WAVE_TYPE {
38  WT_UNDEFINED, WT_PCM8, WT_PCM16
39 };
40 
41 class VGMSamp : public VGMItem {
42 public:
43 
44  VGMSamp(VGMSampColl *sampColl, uint32 offset = 0, uint32 length = 0,
45  uint32 dataOffset = 0, uint32 dataLength = 0, uint8 channels = 1,
46  uint16 bps = 16, uint32 rate = 0, Common::String name = "Sample");
47  virtual ~VGMSamp();
48 
49  virtual double GetCompressionRatio(); // ratio of space conserved. should generally be > 1
50  // used to calculate both uncompressed sample size and loopOff after conversion
51  virtual void ConvertToStdWave(uint8 *buf) {};
52 
53  inline void SetLoopStatus(int loopStat) { _loop.loopStatus = loopStat; }
54  inline void SetLoopOffset(uint32 loopStart) { _loop.loopStart = loopStart; }
55  inline void SetLoopLength(uint32 theLoopLength) { _loop.loopLength = theLoopLength; }
56 
57 public:
58  WAVE_TYPE _waveType;
59  uint32 _dataOff; // offset of original sample data
60  uint32 _dataLength;
61  uint16 _bps; // bits per sample
62  uint32 _rate; // sample rate in herz (samples per second)
63  uint8 _channels; // mono or stereo?
64  uint32 _ulUncompressedSize;
65 
66  bool _bPSXLoopInfoPrioritizing;
67  Loop _loop;
68 
69  int8 _unityKey;
70  short _fineTune;
71  double _volume; // as percent of full volume. This will be converted to attenuation for SynthFile
72 
73  VGMSampColl *_parSampColl;
74  Common::String _sampName;
75 };
76 
77 class VGMSampColl : public VGMFile {
78 public:
79  VGMSampColl(RawFile *rawfile, uint32 offset, uint32 length = 0,
80  Common::String theName = "VGMSampColl");
81  VGMSampColl(RawFile *rawfile, VGMInstrSet *instrset, uint32 offset,
82  uint32 length = 0, Common::String theName = "VGMSampColl");
83  virtual ~VGMSampColl(void);
84 
85  virtual bool Load();
86  virtual bool GetHeaderInfo() { return true; } // retrieve any header data
87  virtual bool GetSampleInfo() { return true; } // retrieve sample info, including pointers to data, # channels, rate, etc.
88 
89 protected:
90 
91 public:
92  bool _bLoaded;
93 
94  uint32 _sampDataOffset; // offset of the beginning of the sample data. Used for
95  // rgn->sampOffset matching
96  VGMInstrSet *_parInstrSet;
97  Common::Array<VGMSamp *> _samples;
98 };
99 
100 #endif // AUDIO_SOUNDFONT_VGMSAMP_H
Definition: str.h:59
Definition: rawfile.h:35
Definition: array.h:52
Definition: vgmsamp.h:77
Definition: vgmsamp.h:41
Definition: vgminstrset.h:45
Definition: common.h:36
Definition: vgmitem.h:42
Definition: vgmitem.h:89