cognitive-catalyst / watson-beat

Other
102 stars 46 forks source link

IndexError: list index out of range #24

Open prsn1988 opened 5 years ago

prsn1988 commented 5 years ago

-------------------------------- DJ MEL Starts --------------------------------------

Mididump Command: python mididump.py Midi/mary.mid > midi_export.mid.dump Traceback (most recent call last): File "wbDev.py", line 6, in Skeleton.run() File "/home/prsn/Downloads/watson-beat-master/src/Skeleton/Skeleton.py", line 509, in run skeleton = Template( results.iniFile, results.midiFilePath, results.outputFilePath ) File "/home/prsn/Downloads/watson-beat-master/src/Skeleton/Skeleton.py", line 33, in init self.populateSections() File "/home/prsn/Downloads/watson-beat-master/src/Skeleton/Skeleton.py", line 320, in populateSections mlResponse = DevServer.Server.run ( json.dumps( wbClientData ), self.midiFilePath ) File "/home/prsn/Downloads/watson-beat-master/src/DevServer/Server.py", line 22, in run movementsServer[mvNum][uniqCPId] = collections.OrderedDict(section.run () ) File "/home/prsn/Downloads/watson-beat-master/src/DevServer/Section.py", line 72, in run self.layers['mel5'] = self.initializeAndRunDJWatsonMelody () File "/home/prsn/Downloads/watson-beat-master/src/DevServer/Section.py", line 125, in initializeAndRunDJWatsonMelody midiTrainingData = ExtractMidiTrainingData.MidiTrainingData ( "midi_export.mid.dump" ) File "/home/prsn/Downloads/watson-beat-master/src/DevServer/ExtractMidiTrainingData.py", line 21, in init self.removeOverlaps() File "/home/prsn/Downloads/watson-beat-master/src/DevServer/ExtractMidiTrainingData.py", line 30, in removeOverlaps lastItem = self.Tracks[trackName][1].key(-1) IndexError: list index out of range

cupOJoseph commented 4 years ago

@amchaney a small update to removeOverlaps() seems to fix this for me.

def removeOverlaps ( self ) :

        trackName = 'melody'
        trackName = 'other'
        lastItem = len(self.Tracks[trackName][1].keys())

        for item in range(len(self.Tracks[trackName][1].keys())):
            if item in self.Tracks[trackName][1] :

                s1 = self.Tracks[trackName][1][item]['Clk'][0]
                e1 = self.Tracks[trackName][1][item]['Clk'][1]

                for nextItem in range ( item+1, lastItem, 1 ) :

                    if nextItem in self.Tracks[trackName][1] :

                        s2 = self.Tracks[trackName][1][nextItem]['Clk'][0]
                        e2 = self.Tracks[trackName][1][nextItem]['Clk'][1]

                        if ( s1 < e2 and ( (e1-s2) > 100 ) )  :
                             print ( "Overlap found between: " ,item, nextItem, self.Tracks[trackName][1][item] , self.Tracks[trackName][1][nextItem] )
                             print()
                             del self.Tracks[trackName][1][nextItem]
cupOJoseph commented 4 years ago

The loop was putting a list's final item into the range function instead of the length of the list. I'll make a PR now.

There are some other issues in the same file though, which keep it from running correctly

SweetmanTech commented 4 years ago

Hello I am still experiencing this issue (attached)

When will this PR get merged? image

SweetmanTech commented 4 years ago

@amchaney a small update to removeOverlaps() seems to fix this for me.

def removeOverlaps ( self ) :

        trackName = 'melody'
        trackName = 'other'
        lastItem = len(self.Tracks[trackName][1].keys())

        for item in range(len(self.Tracks[trackName][1].keys())):
            if item in self.Tracks[trackName][1] :

                s1 = self.Tracks[trackName][1][item]['Clk'][0]
                e1 = self.Tracks[trackName][1][item]['Clk'][1]

                for nextItem in range ( item+1, lastItem, 1 ) :

                    if nextItem in self.Tracks[trackName][1] :

                        s2 = self.Tracks[trackName][1][nextItem]['Clk'][0]
                        e2 = self.Tracks[trackName][1][nextItem]['Clk'][1]

                        if ( s1 < e2 and ( (e1-s2) > 100 ) )  :
                             print ( "Overlap found between: " ,item, nextItem, self.Tracks[trackName][1][item] , self.Tracks[trackName][1][nextItem] )
                             print()
                             del self.Tracks[trackName][1][nextItem]

When I apply this change to BOTH files I receive a new error:

Here is my current error: image

My goal is simply to use a MIDI file outside of the given examples. It's proving way more difficult than expected with these errors.

Can anyone help me?