Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError: list index out of range #24

Open
prsn1988 opened this issue Sep 27, 2019 · 4 comments
Open

IndexError: list index out of range #24

prsn1988 opened this issue Sep 27, 2019 · 4 comments
Labels

Comments

@prsn1988
Copy link

-------------------------------- 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

@amchaney amchaney added the MIDI label Oct 7, 2019
@cupOJoseph
Copy link

@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
Copy link

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
Copy link

Hello I am still experiencing this issue (attached)

When will this PR get merged?
image

@sweetmantech
Copy link

@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:

  • src/Skeleton/ExtractMidiTrainingData.py (removeOverlaps)
  • src/DevServer/ExtractMidiTrainingData.py (removeOverlaps)

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants