1 /* ResidualVM - A 3D game interpreter
2  *
3  * ResidualVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the AUTHORS
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #include "engines/grim/grim.h"
24 #include "engines/grim/imuse/imuse.h"
25 #include "engines/grim/emi/sound/emisound.h"
26 #include "engines/grim/sound.h"
27 
28 namespace Grim {
29 
30 SoundPlayer *g_sound = nullptr;
31 
startVoice(const char * soundName,int volume,int pan)32 bool SoundPlayer::startVoice(const char *soundName, int volume, int pan) {
33 	if (g_grim->getGameType() == GType_GRIM)
34 		return g_imuse->startVoice(soundName, volume, pan);
35 	else
36 		return g_emiSound->startVoice(soundName, volume, pan);
37 }
38 
getSoundStatus(const char * soundName)39 bool SoundPlayer::getSoundStatus(const char *soundName) {
40 	if (g_grim->getGameType() == GType_GRIM)
41 		return g_imuse->getSoundStatus(soundName);
42 	else
43 		return g_emiSound->getSoundStatus(soundName);
44 }
45 
stopSound(const char * soundName)46 void SoundPlayer::stopSound(const char *soundName) {
47 	if (g_grim->getGameType() == GType_GRIM) {
48 		g_imuse->stopSound(soundName);
49 		return;
50 	} else {
51 		g_emiSound->stopSound(soundName);
52 	}
53 }
54 
getPosIn16msTicks(const char * soundName)55 int32 SoundPlayer::getPosIn16msTicks(const char *soundName) {
56 	if (g_grim->getGameType() == GType_GRIM)
57 		return g_imuse->getPosIn16msTicks(soundName);
58 	else
59 		return g_emiSound->getPosIn16msTicks(soundName);
60 }
61 
setVolume(const char * soundName,int volume)62 void SoundPlayer::setVolume(const char *soundName, int volume) {
63 	if (g_grim->getGameType() == GType_GRIM) {
64 		g_imuse->setVolume(soundName, volume);
65 	} else {
66 		g_emiSound->setVolume(soundName, volume);
67 	}
68 }
69 
setPan(const char * soundName,int pan)70 void SoundPlayer::setPan(const char *soundName, int pan) {
71 	if (g_grim->getGameType() == GType_GRIM) {
72 		g_imuse->setPan(soundName, pan);
73 	} else {
74 		g_emiSound->setPan(soundName, pan);
75 	}
76 }
77 
setMusicState(int stateId)78 void SoundPlayer::setMusicState(int stateId) {
79 	if (g_grim->getGameType() == GType_GRIM) {
80 		g_imuse->setMusicState(stateId);
81 	} else {
82 		g_emiSound->setMusicState(stateId);
83 	}
84 }
85 
flushTracks()86 void SoundPlayer::flushTracks() {
87 	if (g_grim->getGameType() == GType_GRIM) {
88 		g_imuse->flushTracks();
89 	} else {
90 		g_emiSound->flushTracks();
91 	}
92 }
93 
restoreState(SaveGame * savedState)94 void SoundPlayer::restoreState(SaveGame *savedState) {
95 	if (g_grim->getGameType() == GType_GRIM) {
96 		g_imuse->restoreState(savedState);
97 	} else {
98 		g_emiSound->restoreState(savedState);
99 	}
100 }
101 
102 
saveState(SaveGame * savedState)103 void SoundPlayer::saveState(SaveGame *savedState) {
104 	if (g_grim->getGameType() == GType_GRIM) {
105 		g_imuse->saveState(savedState);
106 	} else {
107 		g_emiSound->saveState(savedState);
108 	}
109 }
110 
111 } // end of namespace Grim
112