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

Convert music21 to muspy track #55

Open
raymondtoh94 opened this issue Feb 7, 2021 · 0 comments
Open

Convert music21 to muspy track #55

raymondtoh94 opened this issue Feb 7, 2021 · 0 comments

Comments

@raymondtoh94
Copy link

Midi File exported from music21 and also convert to muspy track sound different.
midi_file -> music21_read -> get_key -> music21 export -> test.midi
midi_file -> music21_read -> get_key -> muspy_from_music21 export -> generated_track.midi
test.midi sound different from generated_track.midi

for i in os.listdir(SONGS_PATH):
        if i.lower().endswith(('mid','midi')):
            midi = converter.parse(SONGS_PATH i)
            
            #Get Midi key
            key = midi.analyze("key")
            if key.mode == "major":
                intervals = interval.Interval(key.tonic, pitch.Pitch("C"))
            elif key.mode == "minor":
                intervals = interval.Interval(key.tonic, pitch.Pitch("A"))
            
            #Transpose to C major or A minor
            transpose_midi = midi.transpose(intervals)
            transpose_midi.write('midi', fp='test.midi') #This Midi is different from muspy midi
            
            
            midi = muspy.from_music21(transpose_midi, resolution=resolution)
            muspy.write("generated_track.midi", midi, kind="midi")
            
            events = muspy.to_event_representation(midi, encode_velocity=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant