def loadSoundsFromFolder(self, path, sounds_from_xml): all_sounds = [] skipping = 0 if os.path.exists(path): files = os.listdir(path) print("Found", len(files), "files.") for f in files: (filename, extension) = os.path.splitext(f) if extension.upper() in self.supported_file_extensions: b = True for s in sounds_from_xml: # print (s.path, "vs.", os.path.join(path,f)) if s.filePath == os.path.join(path, f): b = False skipping += 1 # print("skipping", os.path.join(path,f), "... already in xml") break if b: # print("Adding: "+os.path.join(path,f)) s = SoundData() s.filePath = os.path.join(path, f) all_sounds.append(s) else: print("Warning ../../sounds not found.") print("skipping", skipping, "sounds because they were already loaded from xml") return all_sounds
def load(self, filename): soundlist = [] tree = parse(filename) root = tree.getroot() for node in root: s = SoundData() s.name = str(node.attrib.get("_name")) s.filePath = str(node.attrib.get("_filePath")) s.index = int(node.attrib.get("_index")) s.length = int(node.attrib.get("_length")) s.start = int(node.attrib.get("_start")) s.stop = int(node.attrib.get("_stop")) s.fadeIn = int(node.attrib.get("_fadeIn")) s.fadeOut = int(node.attrib.get("_fadeOut")) s.fadeStop = int(node.attrib.get("_fadeStop")) s.masterVolume = float(node.attrib.get("_masterVolume")) s.waveformFile = str(node.attrib.get("_waveformFile")) soundlist.append(s) return soundlist