Beispiel #1
0
    def write(self, algorithm, counter, source):
        # How many times do you want this to run?
        iterations = int(self._config["tracks"])
        # Need to be able to pad the correct number of zeroes
        digits = self.intwidth(iterations)
        # What's the base root name of the outputs?
        base = type(self).__name__
        # Set the correct sub directory and ensure it exists
        destdir = os.path.join(self._destination, base)
        mkdir_p(destdir)
        # Zero pad the counter string
        ctr = str(counter).zfill(digits)
        track = f"{base}_{algorithm}_{ctr}"
        debug(f"Track: {track}")

        # Create the output file name with zero padded counter value
        if self.supported(self._format) is True:
            filename = "{0}.{1}".format(track, self._format)
            # Set up the output path
            dest = os.path.join(destdir, filename)
            print(f"\t{dest}")
            # Write it out
            source.export(dest, format=self._format)
            src = WavSource(dpath=dest, dexist=True)
            self._inventory.insert(src)
        else:
            print("Unsupported output format : {0}".format(self._format))
Beispiel #2
0
 def process(self):
     self.loadSelections()
     self.loadConfiguration()
     if self._sequence is not None:
         for voice in self._sequence:
             debug(f"Voice : {voice}")
             for processor in self._configuration[voice]:
                 debug(f"Processor : {processor}")
                 factory = ProcessorFactory(
                     voice, processor,
                     self._configuration[voice][processor])
                 factory.configure(
                     invent=self._selector,
                     config=self._configuration[voice][processor],
                     dest=self._destination,
                     form=self._format)
                 factory.process()
     else:
         for voice in self._voices:
             if voice != "Globals":
                 for processor in self._configuration[voice]:
                     factory = ProcessorFactory(
                         voice, processor,
                         self._configuration[voice][processor])
                     factory.configure(
                         invent=self._selector,
                         config=self._configuration[voice][processor],
                         dest=self._destination,
                         form=self._format)
                     factory.process()
Beispiel #3
0
 def __init__(self, prefix=None):
     self._config = None
     self._inventory = None
     self._destination = None
     self._format = "wav"
     self._content = []
     self._prefix = prefix
     debug('Process()')
Beispiel #4
0
    def search(self, spath=None):
        """Walk a directory tree to add to the Selector configuration.

        This method walks the specified directory tree and adds any discovered WAV files to its inventory.
        This method is uniquely additive in that it can be run repeatedly across the different or the same trees.
        Uniqueness is enforced during this process, so any repeats are silently overwritten.
        Any files encountered that do not match the criteria for a WAV file are ignored.

        Args:
            spath (str) : path to the root of the searchble directory tree.

        .. code-block:: python
           :caption: Example usage
       
           from GenerIter.selector import Selector
           # Empty Selector
           selector = Selector()
           # Search a directory tree
           selector.search(spath=pathstring)

        """
        if spath is not None:
            # Let's use the object-oriented filesystem abstraction
            sdir = Path(spath)
            # Recursively walk the directory and subdirectories
            fyles = list(sdir.rglob('*.*'))
            for fyle in fyles:
                # Ensure the filepath is absolute
                filepath = str(fyle.resolve())
                #debug(filepath)
                # Attempt to add this item into the current configuration
                try:
                    # Is it a valid WavSource?
                    src = WavSource(dpath=filepath, dexist=True)
                except Exception as inst:
                    debug(filepath)
                    #debug_except(inst)
                    debug("skipping ...")
                    src = None  # The insert will skip this
                self.insert(source=src, include=True)
Beispiel #5
0
    def load(self, lpath=None):
        """Load a previously-saved Selector configuration.

        This method is uniquely additive in that it can be run repeatedly and any repeats are silently overwritten.

        Args:
            lpath (str) : path to the loadable JSON file containing a saved Selector state.

        .. code-block:: python
           :caption: Example usage
       
           from GenerIter.selector import Selector
           # Empty Selector
           selector = Selector()
           # Load a previously-saved inventory file
           selector.load(lpath=pathstring)

        """
        if lpath is not None:
            # Open the specified JSON file and load it
            with open(lpath) as fp:
                #debug("Open {0}".format(lpath))
                tcand = json.load(fp)
            # Iterate down the categories
            for category in tcand:
                # Within each category, iterate down the items
                for item in tcand[category]:
                    # Attempt to add this item into the current configuration
                    try:
                        # Is it a valid WavSource?
                        src = WavSource(dpath=item, dexist=True)
                    except robox.RDJValidationErr as err:
                        debug(err)
                        debug("WavSource exception for {0}".format(item))
                        src = None  # The insert will skip this
                    self.insert(source=src, include=tcand[category][item])
Beispiel #6
0
 def __init__(self):
     super().__init__()
     debug('Basic()')
Beispiel #7
0
 def __init__(self):
     super().__init__()
     debug('Mix()')
Beispiel #8
0
 def __init__(self):
     super().__init__()
     debug('Solo()')
Beispiel #9
0
 def default(self):
     debug('No-op default processing logic')
     debug(type(self))