GenerIter package¶
Subpackages¶
- GenerIter.app package
- Submodules
- GenerIter.app.algorithm module
- GenerIter.app.categorise module
- GenerIter.app.clep_algorithm module
- GenerIter.app.clep_categorise module
- GenerIter.app.clep_generator module
- GenerIter.app.clep_inventory module
- GenerIter.app.clibase module
- GenerIter.app.generator module
- GenerIter.app.inventory module
- Module contents
- GenerIter.processor package
Submodules¶
GenerIter.config module¶
Class to configure generator algorithms.
Copyright 2020 Thomas Jackson Park & Jeremy Pavier
GenerIter.excepts module¶
Domain-specific Exception classes for GenerIter
Copyright 2020 Thomas Jackson Park & Jeremy Pavier
-
exception
GenerIter.excepts.
GIErr
[source]¶ Bases:
Exception
Base class for domain-specific exceptions.
-
exception
GenerIter.excepts.
GINotImplementedErr
[source]¶ Bases:
GenerIter.excepts.GIErr
Class for propogating not implemented errors.
-
exception
GenerIter.excepts.
GIParameterErr
[source]¶ Bases:
GenerIter.excepts.GIErr
Class for propogating parameter errors.
-
exception
GenerIter.excepts.
GIResourceErr
[source]¶ Bases:
GenerIter.excepts.GIErr
Class for propogating resource errors.
-
exception
GenerIter.excepts.
GIValidationErr
[source]¶ Bases:
GenerIter.excepts.GIErr
Class for propogating validation errors.
GenerIter.factory module¶
Class that constructs the correct processor object.
Copyright 2020 Thomas Jackson Park & Jeremy Pavier
GenerIter.process module¶
Abstract base class for all Process-based generator algorithms.
Copyright 2020 Thomas Jackson Park & Jeremy Pavier
-
class
GenerIter.process.
Process
(prefix=None)[source]¶ Bases:
object
This is the abstract base class from which all other processors are derived.
As such it implements the core interface as well as several important generic helper services which can simplify the derived algorithm implementations.
-
SUPPORTED_FORMATS
= ['wav']¶
-
TSHIRT
= {'l': 480, 'm': 300, 's': 180, 'xl': 780, 'xxl': 1260, 'xxxl': 2640}¶
-
declick
(segment, value=10)[source]¶ This is a helper function with which a fade/rise can be applied to each end of an AudioSegment to reduce the potential for ‘clicking’ when they are connected end-to-end.
Can also be used, with longer fade times, if large track fades are required.
- Parameters
value (int) – number of milliseconds across which the segment will be faded from full gain to zero (typically 10 seems to work well).
- Returns
AudioSegment
-
GenerIter.selector module¶
Class to catalogue and select source files.
Copyright 2020 Thomas Jackson Park & Jeremy Pavier
-
class
GenerIter.selector.
Selector
(searchpath=None, loadpath=None)[source]¶ Bases:
object
Represents the inventory of samples available for algorithmic processing.
from GenerIter.selector import Selector # Selector selector = Selector(searchpath=pathstring,loadpath=loadfile)
-
load
(lpath=None)[source]¶ Load a previously-saved Selector configuration.
This method is uniquely additive in that it can be run repeatedly and any repeats are silently overwritten.
- Parameters
lpath (str) – path to the loadable JSON file containing a saved Selector state.
from GenerIter.selector import Selector # Empty Selector selector = Selector() # Load a previously-saved inventory file selector.load(lpath=pathstring)
-
search
(spath=None)[source]¶ 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.
- Parameters
spath (str) – path to the root of the searchble directory tree.
from GenerIter.selector import Selector # Empty Selector selector = Selector() # Search a directory tree selector.search(spath=pathstring)
-
selectRandom
(key)[source]¶ Method for getting a random selection from within a sub-category of the Selector.
This method will attempt to randomly choose an entry for the specified sub-category in the Selector.
It will fail if there are no
true
enabled entries in the sub-category or if the randomised function repeatedly fails to find atrue
enabled entry because they are too sparse.The number of attempts is limited by the size of the sub-category array.
- Parameters
key (str) – the name of a sub-category within the Selector’s structure.
- Raises
RDJParameterErr – if unable to select a return value.
-
GenerIter.source module¶
Classes to represent references to GenerIter source files.
Copyright 2020 Thomas Jackson Park & Jeremy Pavier
-
class
GenerIter.source.
FlacSource
(dpath=None, dexist=False)[source]¶ Bases:
GenerIter.source.Source
Derived class specialised for FLAC source files.
This is a placeholder for future developments.
-
class
GenerIter.source.
Mp3Source
(dpath=None, dexist=False)[source]¶ Bases:
GenerIter.source.Source
Derived class specialised for MP3 source files.
This is a placeholder for future developments.
-
class
GenerIter.source.
Source
(path=None, exist=False)[source]¶ Bases:
object
Generic file source representation.
- Parameters
path (string) – string representation of the absolute or relative path to the target file.
exist (boolean) – flag setting to test for the file’s existence when the reference object is instantiated.
- Raises
GIResourceErr – if
exist == True
and the file does not exist.
-
property
dname
¶ Returns the name of the file’s directory.
-
property
ext
¶ Returns the filename extension of the file
-
property
fname
¶ Returns the basename of the file.
-
isValidExtension
(ref=None)[source]¶ Tests if the filename extension matches an expected value.
Indicates whether the Source or derived object carries the same file extension, either as upper- or lower-case forms.
- Parameters
ref (str) – the extension value to compare against.
- Returns
boolean
-
property
path
¶ Accessor to the value of full path value
-
property
root
¶ Returns the root name of the file.
-
class
GenerIter.source.
WavSource
(dpath=None, dexist=False)[source]¶ Bases:
GenerIter.source.Source
Derived class specialised for WAV source files.
WAV is the only currently supported format.
GenerIter.util module¶
Useful unencapsulated functions to be reused across the domain.
Copyright 2020 Thomas Jackson Park & Jeremy Pavier
-
GenerIter.util.
debug
(astring)[source]¶ Only print if in DEBUG mode.
- Parameters
astring (str) – any valid Python string
-
GenerIter.util.
debug_except
(inst)[source]¶ Only print exception diagnostics if in DEBUG mode.
- Parameters
inst – any valid exception instance
-
GenerIter.util.
jStr
(struct)[source]¶ Default JSON output human-readable string format.
The output string is formatted for ease of reading, with an indent value of 4 chars, using standard separators and all fields sorted by name at their appropriate level.
- Parameters
struct – arbitary Python iterable data structure i.e. list or dict.
- Returns
string
-
GenerIter.util.
jsonSerial
(obj)[source]¶ JSON serializer for objects not serializable by default json code.
Currently supports datetime objects.
- Parameters
obj (any type) – arbitary Python object or type.
- Returns
string
- Raises
TypeError – if the object is not serializable.
-
GenerIter.util.
localTimestamp
(some_time=None, time_format=None)[source]¶ Return a specified UTC time, formatted by the given string.
- Parameters
some_time – a datetime object (default
None
usesdatetime.utcnow()
)time_format – format to covert a datetime object to string (default
None
uses%Y%m%d%H%M%S
)
- Returns
A timestamp string
-
GenerIter.util.
mkdir_p
(path)[source]¶ Replicates mkdir -p functionality.
For a given path, any missing directories are created to ensure the full path exists
- Parameters
path (str) – absolute path to the target directory.
- Raises
OSError – if the path already exists as a file, or the target directory cannot be created because of a permissions error.
-
GenerIter.util.
shCmd
(cspec, trace=False)[source]¶ Executes a shell command and returns a string list of the output.
- Parameters
[] (cspec) – array of command line options and parameters.
trace (boolean) – flag to set for text output if required (default : False)
- Returns
[] (str) if
trace == True
elseNone
- Raises
CalledProcessError – if the subprocess call fails