ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

sound_component.cpp

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 
00024 #include "engines/grim/grim.h"
00025 #include "engines/grim/set.h"
00026 #include "engines/grim/debug.h"
00027 #include "engines/grim/costume.h"
00028 
00029 #include "engines/grim/costume/sound_component.h"
00030 
00031 #include "engines/grim/imuse/imuse.h"
00032 
00033 namespace Grim {
00034 
00035 
00036 SoundComponent::SoundComponent(Component *p, int parentID, const char *filename, tag32 t) :
00037         Component(p, parentID, filename, t) {
00038     const char *comma = strchr(filename, ',');
00039     if (comma) {
00040         _name = Common::String(filename, comma);
00041     }
00042 }
00043 
00044 SoundComponent::~SoundComponent() {
00045     // Stop the sound if it's in progress
00046     reset();
00047 }
00048 
00049 void SoundComponent::setKey(int val) {
00050     switch (val) {
00051     case 0: // "Play"
00052         // No longer a need to check the sound status, if it's already playing
00053         // then it will just use the existing handle
00054         g_imuse->startSfx(_name.c_str());
00055         if (g_grim->getCurrSet()) {
00056             Math::Vector3d pos = _cost->getMatrix().getPosition();
00057             g_grim->getCurrSet()->setSoundPosition(_name.c_str(), pos);
00058         }
00059         break;
00060     case 1: // "Stop"
00061         g_imuse->stopSound(_name.c_str());
00062         break;
00063     case 2: // "Stop Looping"
00064         g_imuse->setHookId(_name.c_str(), 0x80);
00065         break;
00066     default:
00067         Debug::warning(Debug::Costumes, "Unknown key %d for sound %s", val, _name.c_str());
00068     }
00069 }
00070 
00071 void SoundComponent::reset() {
00072     // A lot of the sound components this gets called against aren't actually running
00073     if (g_imuse && g_imuse->getSoundStatus(_name.c_str()))
00074         g_imuse->stopSound(_name.c_str());
00075 }
00076 
00077 } // end of namespace Grim


Generated on Sat Jul 20 2019 05:00:49 for ResidualVM by doxygen 1.7.1
curved edge   curved edge