def __init__ ( self, wbLevers, homeScale, homeChord, duration, melodyPL ) : self.melodyPL = melodyPL self.maxNoteIndex = len(melodyPL) self.printMelodyNotes ( self.melodyPL ) self.desc = 'melody5' self.duration = duration self.homeChord = homeChord self.homeScale = homeScale self.speed = wbLevers['rhythmSpeed'] # initialize the state attributes for the melody5 layer self.StateAttributes = StateAttributes.StateAttributes['melody5'] self.numFeatures = len( self.StateAttributes ) self.features = [ i for i in range(self.numFeatures) ] layerParams = None # initialize actions for the melody5 layer self.Knobs, self.Actions, self.ReverseActions = ComplexityKnobs.setKnobs ( self.desc, wbLevers['complexity'], layerParams ) self.numActions = len(self.Actions) self.defaultAction = 1 #'PLAY_CHORD_TONE' # Create the melody5 environment self.env = Environment.Melody5Environment( wbLevers['tse'], wbLevers['phraseLength'], self.homeScale, self.homeChord ) # Initialize the melody5 environment variables self.env.InitializeEnvironment ( self.homeScale ) self.env.printEnvironmentVariables () # Initialize the RL data Structures self.initializeQLearningObject ( 0 ) self.trainedData = collections.OrderedDict()
def __init__(self, wbLevers, scale, chord, duration, rhythm): self.desc = 'bass2' self.duration = duration self.rhythm = rhythm self.homeChord = chord self.homeScale = scale self.id = wbLevers['id'] # initialize the state attributes for the bass2 layer self.StateAttributes = StateAttributes.StateAttributes[self.desc] self.numFeatures = len(self.StateAttributes) self.features = [i for i in range(self.numFeatures)] isRL = False if isRL: layerParams = None # initialize actions for the bass2 layer self.Knobs, self.Actions, self.ReverseActions = ComplexityKnobs.setKnobs( self.desc, wbLevers['complexity'], layerParams) self.numActions = len(self.Actions) self.defaultAction = 0 #'PLAY_HOME_NOTE' # Create the bass2 environment self.env = Environment.Bass2Environment(wbLevers['tse'], wbLevers['phraseLength'], scale, chord) # Initialize the bass2 environment variables self.env.InitializeEnvironment(scale) # self.env.printEnvironmentVariables () # Initialize the RL data Structures self.initializeQLearningObject(0) self.trainedData = [] else: layerParams = None # initialize actions for the bass2 layer self.Knobs, self.Actions, self.ReverseActions = ComplexityKnobs.setKnobs( self.desc, wbLevers['complexity'], layerParams) self.numActions = len(self.Actions)
def __init__(self, wbLevers, scale, chord, ids, duration): wbLevers['complexity'] = 'semi_complex' self.desc = 'melody5' self.duration = duration self.homeChord = chord[0] self.homeScale = scale[0] self.speed = wbLevers['rhythmSpeed'] # store all chord ids with same duration self.chordIds = ids # if there is more than one chord with the same duration store them here. Will be used later to fill the actions based on the first learned chord for this duration self.otherChords = chord self.otherScales = scale # initialize the state attributes for the melody5 layer self.StateAttributes = StateAttributes.StateAttributes['melody5'] self.numFeatures = len(self.StateAttributes) self.features = [i for i in range(self.numFeatures)] layerParams = None # initialize actions for the melody5 layer self.Knobs, self.Actions, self.ReverseActions = ComplexityKnobs.setKnobs( self.desc, wbLevers['complexity'], layerParams) self.numActions = len(self.Actions) self.defaultAction = 1 #'PLAY_CHORD_TONE' # Create the melody5 environment self.env = Environment.Melody5Environment(wbLevers['tse'], wbLevers['phraseLength'], self.homeScale, self.homeChord) # Initialize the melody5 environment variables self.env.InitializeEnvironment(self.homeScale) self.env.printEnvironmentVariables() # Initialize the RL data Structures self.initializeQLearningObject(0) self.trainedData = collections.OrderedDict() if (prnFlag): self.PrintClassInfo()
def __init__(self, wbLevers, scale, chord, duration, rhythm): self.desc = 'bass3' self.duration = duration self.homeChord = chord self.rhythm = rhythm self.homeScale = scale self.id = wbLevers['id'] self.tse = wbLevers['tse'] # initialize the state attributes for the bass2 layer #self.StateAttributes = StateAttributes.StateAttributes[self.desc] #self.numFeatures = len( self.StateAttributes ) #self.features = [ i for i in range(self.numFeatures) ] layerParams = None # initialize actions for the bass2 layer self.Knobs, self.Actions, self.ReverseActions = ComplexityKnobs.setKnobs( self.desc, wbLevers['complexity'], layerParams) self.numActions = len(self.Actions) if (0): for rhy in self.rhythm: print(self.rhythm[rhy])
def __init__(self, wbLevers): self.desc = 'bass1' self.tse = Constants.TSEs[wbLevers['tse']] self.primaryScale = wbLevers['primaryScale'] self.id = wbLevers['id'] self.mood = wbLevers['mood'] self.complexity = wbLevers['complexity'] # initialize the state attributes for the bass1 layer self.StateAttributes = StateAttributes.StateAttributes['bass1'] self.numFeatures = len(self.StateAttributes) self.features = [i for i in range(self.numFeatures)] self.trueMinPenalty = 4 # ( 4 + 0 + 0 ) self.trueMaxPenalty = -24 # ( 0 + ( -5 ) + ( -19 ) ) self.penaltyBase = ( self.trueMaxPenalty * -1 ) + 1 # why 25, beacuse the adder for making all penalties positive is 25. why 25, because the maximum penalty is -24 and the min penalty = 4 self.penaltyMin = self.penaltyBase + self.trueMinPenalty # so min penalty after adder = 4+25 = 29 self.penaltyMax = self.penaltyBase + self.trueMaxPenalty # so max penalty after adder = -24 + 25 = 1 self.trueMinPenalty = 7 self.trueMaxPenalty = -19 self.penaltyBase = ( self.trueMaxPenalty * -1 ) + 1 # why 20, beacuse the adder for making all penalties positive is 20. why 20, because the maximum penalty is -19 and the min penalty = 7 self.penaltyMin = self.penaltyBase + self.trueMinPenalty # so min penalty after adder = 7+20 = 27 self.penaltyMax = self.penaltyBase + self.trueMaxPenalty # so max penalty after adder = -19 + 20 = 1 self.trueMinPenalty = 7 self.trueMaxPenalty = -30 self.penaltyBase = (self.trueMaxPenalty * -1) + 1 self.penaltyMin = self.penaltyBase + self.trueMinPenalty self.penaltyMax = self.penaltyBase + self.trueMaxPenalty layerParams = { 'minPenalty': self.penaltyMin, 'maxPenalty': self.penaltyMax } # initialize actions for the bass1 layer self.Knobs, self.Actions, self.ReverseActions = ComplexityKnobs.setKnobs( 'bass1', wbLevers['complexity'], layerParams) self.numActions = len(self.Actions) self.defaultAction = 3 #'PLAY_CHORD_PROGRESSION_TONE_FOR_PRIMARY_KEY' # Create the bass1 environment self.env = Environment.Bass1Environment(wbLevers['tse'], wbLevers['phraseLength'], wbLevers['primaryScale'], wbLevers['mood']) # Initialize the bass1 environment variables self.env.InitializeEnvironment(wbLevers['primaryScale']) #self.env.printEnvironmentVariables () # Initialize the RL data Structures self.initializeQLearningObject(0) self.trainedData = []