aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm/imuse_digi/dimuse_track.h
blob: 33147128cb8fdb3ea10bb9174cdc84c4a56422c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * $URL$
 * $Id$
 */

#if !defined(SCUMM_IMUSE_DIGI_TRACK_H) && defined(ENABLE_SCUMM_7_8)
#define SCUMM_IMUSE_DIGI_TRACK_H

#include "common/scummsys.h"

namespace Scumm {


// These flag bits correspond exactly to the sound mixer flags of March 2007.
// We don't want to use the mixer flags directly, because then our saved games
// will break in interesting ways if the mixer flags are ever assigned new
// values. Now they should keep working, as long as these flags don't change.

enum {
	kFlagUnsigned = 1 << 0,
	kFlag16Bits = 1 << 1,
	kFlagLittleEndian = 1 << 2,
	kFlagStereo = 1 << 3,
	kFlagReverseStereo = 1 << 4

	// Not used by Digital iMUSE
	// kFlagAutoFree = 1 << 5,
	// kFlagLoop = 1 << 6
};

struct Track {
	int trackId;		// used to identify track by value (0-15)

	int8 pan;			// panning value of sound
	int32 vol;			// volume level (values 0-127 * 1000)
	int32 volFadeDest;	// volume level which fading target (values 0-127 * 1000)
	int32 volFadeStep;	// delta of step while changing volume at each imuse callback
	int32 volFadeDelay;	// time in ms how long fading volume must be
	bool volFadeUsed;	// flag if fading is in progress

	int32 soundId;		// sound id used by scumm script
	char soundName[15]; // sound name but also filename of sound in bundle data
	bool used;			// flag mean that track is used
	bool toBeRemoved;   // flag mean that track need to be free
	bool mixerStreamRunning;	// flag mean sound mixer's stream is running OBSOLETE
	bool souStreamUsed;	// flag mean that track use stream from sou file
	bool sndDataExtComp;// flag mean that sound data is compressed by scummvm tools
	int32 soundPriority;// priority level of played sound (0-127)
	int32 regionOffset; // offset to sound data relative to begining of current region
	int32 dataOffset;	// offset to sound data relative to begining of 'DATA' chunk
	int32 curRegion;	// id of current used region
	int32 curHookId;	// id of current used hook id
	int32 volGroupId;	// id of volume group (IMUSE_VOLGRP_VOICE, IMUSE_VOLGRP_SFX, IMUSE_VOLGRP_MUSIC)
	int32 soundType;	// type of sound data (kSpeechSoundType, kSFXSoundType, kMusicSoundType)
	int32 feedSize;		// size of sound data needed to be filled at each callback iteration
	int32 dataMod12Bit;	// value used between all callback to align 12 bit source of data
	int32 mixerFlags;	// flags for sound mixer's channel (kFlagStereo, kFlag16Bits, kFlagReverseStereo, kFlagUnsigned, kFlagLittleEndian)

	ImuseDigiSndMgr::SoundDesc *soundDesc;	// sound handle used by iMuse sound manager
	Audio::SoundHandle mixChanHandle;					// sound mixer's channel handle
	Audio::AppendableAudioStream *stream;		// sound mixer's audio stream handle for *.la1 and *.bun

	Track() : soundId(-1), used(false), stream(NULL) {
	}

	int getPan() const { return (pan != 64) ? 2 * pan - 127 : 0; }
	int getVol() const { return vol / 1000; }
	Audio::Mixer::SoundType getType() const {
		Audio::Mixer::SoundType type = Audio::Mixer::kPlainSoundType;
		if (volGroupId == 1)
			type = Audio::Mixer::kSpeechSoundType;
		else if (volGroupId == 2)
			type = Audio::Mixer::kSFXSoundType;
		else if (volGroupId == 3)
			type = Audio::Mixer::kMusicSoundType;
		return type;
	}
};

} // End of namespace Scumm

#endif