MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / readSounds

Method readSounds

source/sound/SoundEffectsManager.cpp:131–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129}
130
131void SoundEffectsManager::readSounds(std::map<std::string, std::vector<GameSound*>>& soundsFamily,
132 const std::string& parentPath, const std::string& parentFamily, bool spatialSound)
133{
134 std::vector<std::string> directories;
135 if(!Helper::fillDirList(parentPath, directories, false))
136 {
137 OD_LOG_INF("Could not find sounds in directory=" + parentPath);
138 return;
139 }
140
141 for(const std::string& directory : directories)
142 {
143 // We read sub directories
144 std::string fullDir = parentPath + "/" + directory;
145 std::string fullFamily = parentFamily.empty() ? directory : parentFamily + "/" + directory;
146 readSounds(soundsFamily, fullDir, fullFamily, spatialSound);
147
148 std::vector<std::string> soundFilenames;
149 if(!Helper::fillFilesList(fullDir, soundFilenames, ".ogg"))
150 {
151 OD_LOG_ERR("Cannot load sounds from=" + fullDir);
152 continue;
153 }
154
155 // We do not create entries for empty directories
156 if(soundFilenames.empty())
157 continue;
158
159 std::vector<GameSound*>& sounds = soundsFamily[fullFamily];
160 for(const std::string& soundFilename : soundFilenames)
161 {
162 GameSound* gm = getGameSound(soundFilename, spatialSound);
163 if (gm == nullptr)
164 {
165 OD_LOG_ERR("Cannot load sound=" + soundFilename);
166 continue;
167 }
168
169 OD_LOG_INF("Sound loaded family=" + fullFamily + ", filename=" + soundFilename);
170 sounds.push_back(gm);
171 }
172 }
173}
174
175void SoundEffectsManager::updateListener(float timeSinceLastFrame,
176 const Ogre::Vector3& position, const Ogre::Quaternion& orientation)

Callers

nothing calls this directly

Calls 2

fillDirListFunction · 0.85
fillFilesListFunction · 0.85

Tested by

no test coverage detected