gsapi.GSStyles

gsapi.GSStyles.GSBaseStyle module

class gsapi.GSStyles.GSBaseStyle.GSBaseStyle[source]

Base class for defining a style. Such class needs to provide following functions:

  • generateStyle(self, PatternClasses)
  • generatePattern(self, seed=None)
  • getDistanceFromStyle(self, Pattern)
  • getClosestPattern(self, Pattern, seed=None)
  • getInterpolated(self, PatternA, PatternB, distanceFromA, seed=None)
  • getInternalState(self)
  • loadInternalState(self, internalStateDict)
  • isBuilt(self)
generateStyle(PatternClasses)[source]

Computes inner state of style based on list of patterns.

generatePattern(seed=None)[source]

Generates a new random pattern using seed if not “None” (Ideally same seeds should lead to same patterns.)

getDistanceFromStyle(Pattern)[source]

Returns a normalized value representing the “styliness” of a pattern 1 being farthest from style.

getClosestPattern(Pattern, seed=None)[source]

Returns the closest pattern in this style.

getInterpolated(PatternA, PatternB, distanceFromA, seed=0)[source]

Interpolates between two patterns given this style constraints.

getInternalState()[source]

Returns a dict representing the current internal state.

setInternalState(internalStateDict)[source]

Loads internal state from a given dict.

isBuilt()[source]

Returns true if style hasbeen correctly build.

saveToJSON(filePath)[source]
loadFromJSON(filePath)[source]
saveToPickle(filePath)[source]
loadFromPickle(filePath)[source]

gsapi.GSStyles.GSDBStyle module

class gsapi.GSStyles.GSDBStyle.GSDBStyle(generatePatternOrdering='indexed')[source]

Bases: gsapi.GSStyles.GSBaseStyle.GSBaseStyle

A database based style. It generates GSPatterns from existing patterns

Parameters:generatePatternOrdering – {‘indexed’, ‘increasing’, ‘random’}. Defines the generatePattern behaviour
generateStyle(PatternClasses)[source]
generatePattern(seed=None)[source]
getDistanceFromStyle(Pattern)[source]
getClosestPattern(Pattern, seed=0)[source]
getInterpolated(PatternA, PatternB, distanceFromA, seed=0)[source]
getInternalState()[source]
setInternalState(internalStateDict)[source]
isBuilt()[source]

gsapi.GSStyles.GSMarkovStyle module

class gsapi.GSStyles.GSMarkovStyle.GSMarkovStyle(order, numSteps, loopDuration)[source]

Bases: gsapi.GSStyles.GSBaseStyle.GSBaseStyle

Computes a style based on markov chains.

Parameters:
  • order – order used for markov computation
  • numSteps – number of steps to consider (binarization of pattern)
order

order used for markov computation

numSteps

number of steps to consider (binarization of pattern)

generateStyle(PatternList)[source]

Generates a style based on list of GSPatterns.

Parameters:PatternList – list of GSPatterns
buildStyle()[source]

Builds transition table for a previously given list of GSPatterns.

generatePattern(seed=None)[source]

Generates a new pattern.

Parameters:seed – seed used for random initialisation of pattern (value of None generates a new one)
formatPattern(p)[source]
getLastEvents(pattern, step, num, stepSize)[source]
getDistanceFromStyle(Pattern)[source]
getClosestPattern(Pattern, seed=0)[source]
getInterpolated(PatternA, PatternB, distanceFromA, seed=0)[source]
getInternalState()[source]
setInternalState(state)[source]
isBuilt()[source]