Swayam Sahoo

Part

Overview

Part is a class to fetch seperate parts of a Scopul object (ie. flute part, piano part). It provides 3 properties: part, name, sequence and 8 methods: get_notes(), get_note_count(), get_rests(), get_rest_count(), get_chords(), get_chord_count(),get_measure(), get_highest_note()

Here’s an example of how to get a Part object from a Scopul instance:

from Scopul import Scopul

scop = Scopul("test.mid")

# Get all the parts
parts = scop.parts
# parts = [<Sequence.Part object at 0x000001C8065EBCD0>] **this list can be longer

# Get sample flute part
flute_part = parts[0]
print(flue_part)

# Sample output
>>> <Sequence.Part object at 0x000001C8065EBCD0>


Creating a Part object

Part(self, part: Iterable | music21.stream.Part)

You can create your own note class, which you may use to append to the existing MIDI or use for other purposes

Args

To make it your self:

from Scopul import Note, Chord, Rest, Part

N1 = Note(name="C#4", length=1.5)
N2 = Note(name="E4", length=1.5)
N3 = Note(name="G4", length=1.5)
R1 = Rest(length=3)
C1 = Chord(notes=[N1, N2, N3], measure=5)

# Create a part object with values initialized
my_part = Part([N1, C1, R1])

# Empty part
my_empty_part = Part([])


Properties


Methods