def parse_song(self, song_lines, song_key, octave_shift): if isinstance( song_lines, str): # Break newlines and make sure the result is a List song_lines = song_lines.split(os.linesep) english_song_key = self.english_note_name(song_key) note_shift = self.get_note_parser().get_base_of_western_major_scale( ) * octave_shift # Parses song line by line song = Song(maker=self.get_maker(), music_key=english_song_key ) # The song key must be in English format for song_line in song_lines: instrument_line = self.parse_line( song_line, song_key, note_shift) # The song key must be in the original format song.add_line(instrument_line) return song