pitchr package¶
Submodules¶
pitchr.df_import module¶
-
pitchr.df_import.
measures_from_ml_output
(pitches, durations, time_signature)[source]¶ Transform an array of Pitch Numbers into a list of measures
- Parameters
pitches – Numpy.array of int32
durations – a list of float detailing corresponding durations of each row in harmony_df
time_signature – string. Example: ‘4/4’
- Returns measures
list of measures
pitchr.harmony_maker module¶
pitchr.helper module¶
-
pitchr.helper.
explanation
(title, text1, text2, stdscr)[source]¶ Outputs explanation of a specific data structure
- Parameters
title – title of DS
text – explanation
stdscr – curses background
-
pitchr.helper.
export_sample_song
(stdscr)[source]¶ Exports sample song to Python code
- Parameters
stdscr – curses background
Shows menu of options
- Parameters
stdscr – curses background
- Returns menu
curses window
pitchr.lyexport module¶
-
pitchr.lyexport.
save_string_and_execute_LilyPond_silent
(ly_string, filename, command)[source]¶ A helper function for to_png and to_pdf. Should not be used directly. :param ly_string: :param filename: :param command: :return: true if export was successful, false if failed :rtype: bool
-
pitchr.lyexport.
show_score_png
(score)[source]¶ Reveals the score in an image form. Image will block the current process until it is closed in non-interactive scripts.
- Parameters
score –
-
pitchr.lyexport.
to_ly
(score)[source]¶ convert score to lilypond string :param score: :return: lilypond string :rtype: string
-
pitchr.lyexport.
to_pdf
(ly_string, filename)[source]¶ write lilypond string to PDF using lilypond executable :param ly_string: :param filename: :return: whether export was successful :rtype: bool
-
pitchr.lyexport.
to_png
(ly_string, filename)[source]¶ write lilypond string to PNG using lilypond executable :param ly_string: :param filename: :return: whether export was successful :rtype: bool
pitchr.model_maker module¶
pitchr.music module¶
-
class
pitchr.music.
Chord
(notes=None)[source]¶ Bases:
pitchr.music._Music
Class representing an organized group of notes.
- Parameters
notes – [Note]
-
property
accidentals
¶ Get the accidentals of a Chord
- Returns
accidentals (string)
-
static
augmented_triad
(note)[source]¶ Get the augmented triad of a Note
- Parameters
note – Note
- Returns
Chord
-
static
diminished_triad
(note)[source]¶ Get the diminished triad of a Note
- Parameters
note – Note
- Returns
Chord
-
property
duration
¶ Get the duration of a Chord
- Returns
duration
-
property
letter
¶ Get the letter of a Chord
- Returns
letter
-
static
major_triad
(note)[source]¶ Get the major triad of a Note
- Parameters
note – Note
- Returns
Chord
-
static
minor_triad
(note)[source]¶ Get the minor triad of a Note
- Parameters
note – Note
- Returns
Chord
-
property
notes
¶ Get the notes of a Chord
- Returns
[Note]
-
property
octave
¶ Get the octave of a Chord
- Returns
octave
-
property
pitch
¶ Get the pitch of a Chord
- Returns
String of letter-note, accidentals, and octave
-
class
pitchr.music.
Interval
[source]¶ Bases:
object
Stores Pitch Intervals.
-
M2
= 2¶
-
M3
= 4¶
-
M4
= 5¶
-
M5
= 7¶
-
M6
= 9¶
-
M7
= 11¶
-
M8
= 12¶
-
m2
= 1¶
-
m3
= 3¶
-
m5
= 6¶
-
m6
= 8¶
-
m7
= 10¶
-
-
class
pitchr.music.
Key
(flats=0, sharps=0)[source]¶ Bases:
object
Class representing the Key the Score is played in
- Parameters
flats – number of flats in the Key
sharps – number of sharps in the Key
-
A_MAJOR
= <pitchr.music.Key object>¶
-
A_MINOR
= <pitchr.music.Key object>¶
-
Ab_MAJOR
= <pitchr.music.Key object>¶
-
B_MAJOR
= <pitchr.music.Key object>¶
-
B_MINOR
= <pitchr.music.Key object>¶
-
Bb_MAJOR
= <pitchr.music.Key object>¶
-
Bb_MINOR
= <pitchr.music.Key object>¶
-
C_MAJOR
= <pitchr.music.Key object>¶
-
C_MINOR
= <pitchr.music.Key object>¶
-
C_SHARP_MAJOR
= <pitchr.music.Key object>¶
-
C_SHARP_MINOR
= <pitchr.music.Key object>¶
-
Cb_MAJOR
= <pitchr.music.Key object>¶
-
D_MAJOR
= <pitchr.music.Key object>¶
-
D_MINOR
= <pitchr.music.Key object>¶
-
Db_MAJOR
= <pitchr.music.Key object>¶
-
E_MAJOR
= <pitchr.music.Key object>¶
-
E_MINOR
= <pitchr.music.Key object>¶
-
Eb_MAJOR
= <pitchr.music.Key object>¶
-
Eb_MINOR
= <pitchr.music.Key object>¶
-
F_MAJOR
= <pitchr.music.Key object>¶
-
F_MINOR
= <pitchr.music.Key object>¶
-
F_SHARP_MAJOR
= <pitchr.music.Key object>¶
-
F_SHARP_MINOR
= <pitchr.music.Key object>¶
-
G_MAJOR
= <pitchr.music.Key object>¶
-
G_MINOR
= <pitchr.music.Key object>¶
-
G_SHARP_MINOR
= <pitchr.music.Key object>¶
-
Gb_MAJOR
= <pitchr.music.Key object>¶
-
property
fifths
¶ Returns number of fifths that defines this key signature.
- Returns
number of fifths that defines this key signature.
-
property
flat
¶ Returns True if this key signature contains flats :returns: this key signature contains flats
-
property
ly
¶ Returns a lilypond string representation of this key signature. Consists of the tonic in lowercase with “-is” or “-es” if sharp or flat respectively, and then “major”. :returns: lilypond string representation of this key signature
-
property
major_scale
¶ Returns the index of the tonic of this key signature.
- Returns
list of strings of the 8 letters representing the major scale associated with this major key
-
property
major_tonic
¶ Returns the tonic/root of this key signature, assuming a major key.
- Returns
returns the letter of the key signature’s tonic
-
property
major_tonic_offset
¶ Returns the index of the tonic of this key signature.
- Returns
the related offset (in half steps) of this tonic from middle C
-
property
sharp
¶ Returns True if this key signature contains sharps :returns: this key signature contains sharps
-
class
pitchr.music.
Keyboard
[source]¶ Bases:
object
Simulates a piano keyboard. Useful for calculating scales.
-
class
pitchr.music.
Measure
(notes=None, time_signature=None)[source]¶ Bases:
pitchr.music._Music
Class representing a collection of notes.
- Parameters
notes – []
-
property
duration
¶ Returns the total duration of notes in this measure
-
property
time_signature
¶ Get time signature of the Measure
- Returns
time signature
-
class
pitchr.music.
Note
(pitch, duration, dynamic=None, articulation=None, tie=False)[source]¶ Bases:
pitchr.music._Music
Class representing the smallest unit for the Pitcher.
- Parameters
pitch – string with letter name, accidentals, and octave, such as ‘A#4’
duration – note duration
dynamic – dynamic, such as piano, forte, crescendo, etc
articulation – articulation, such as staccato, accent, fermata, etc
tie – when true will play this note continuously into the next note
-
property
accidentals
¶ Get the accidentals of a Note
- Returns
accidentals (string)
-
property
articulation
¶ Get the articulation of a Note
- Returns
duration
-
property
duration
¶ Get the duration of a Note
- Returns
duration
-
property
dynamic
¶ Get the dynamic of a Note
- Returns
dynamic
-
property
letter
¶ Get the letter of a Note
- Returns
letter
-
property
mingus_note
¶ Returns mingus note
-
property
octave
¶ Get the octave of a Note
- Returns
octave
-
property
pitch
¶ Get the pitch of a Note
- Returns
String of letter-note, accidentals, and octave
-
property
pitch_number
¶
-
property
tie
¶ Get the tie status of a Note
- Returns
tie
-
class
pitchr.music.
Part
(staffs=None, tempo=60, time_signature=None, key_signature=None)[source]¶ Bases:
pitchr.music._Music
Class representing a collection of staffs. Add effects / stanza-chorus / key/time changes to parts. Should affect its children.
- Parameters
staffs – from Staff()
tempo – int
time_signature – instance of Time
key_signature – instance of Key
-
property
key_signature
¶ Get the key signature of the current Part
- Returns
key signature
-
property
tempo
¶
-
property
time_signature
¶ Get the time signature of the current Part
- Returns
time signature
-
exception
pitchr.music.
PitcherException
[source]¶ Bases:
Exception
Exceptions related to Pitcher issues
-
class
pitchr.music.
Rest
(duration)[source]¶ Bases:
pitchr.music.Note
Class representing a Rest Note. Has no pitch. Only duration.
- Parameters
duration – float
-
property
accidentals
¶ Get the accidentals of a Note
- Returns
accidentals (string)
-
property
letter
¶ Get the letter of a Note
- Returns
letter
-
property
octave
¶ Get the octave of a Note
- Returns
octave
-
property
pitch
¶ Get the pitch of a Note
- Returns
String of letter-note, accidentals, and octave
-
property
pitch_number
¶
-
class
pitchr.music.
Score
(parts=None, title=None, subtitle=None, author=None, author_email=None)[source]¶ Bases:
pitchr.music._Music
Class representing a collection of parts
- Parameters
parts – [Part]
title – str
subtitle – str
author – str
author_email – str
Get the author of the current Score.
- Returns
Author
-
property
composer
¶ Alias for author of the score
-
property
title
¶ Get the title of the current Score.
- Returns
title
-
class
pitchr.music.
Staff
(measures=None, clef=<Clef.TREBLE: 0>, voice=<Voice.PIANO: 0>, time_signature=None)[source]¶ Bases:
pitchr.music._Music
Class representing a collection of measures.
- Parameters
clef – from Clef()
voice – from Voice()
measures – Measure()
-
property
clef
¶ Get clef of the Staff
- Returns
clef
-
property
time_signature
¶ Get time signature of the Staff
- Returns
time signature
-
property
voice
¶ Get voice of the Staff
- Returns
voice
-
class
pitchr.music.
Time
(time)[source]¶ Bases:
object
Class representing the Time signature the Score is played in
- Parameters
time – String representing the time signature
-
COMMON_TIME
= <pitchr.music.Time object>¶
-
CUT_TIME
= <pitchr.music.Time object>¶
-
property
beat_definition
¶ Get the beat definition of the Score
- Returns
beat definition
-
property
beats_per_measure
¶ Get the beats per measure of the Score
- Returns
beats per measure
pitchr.pitch_tagger module¶
-
pitchr.pitch_tagger.
tag_accidentals
(notes_df)[source]¶ Tag accidentals to a dataframe of notes
- Parameters
notes_df – dataframe of notes
pitchr.playing module¶
-
class
pitchr.playing.
Event
(event_type, pitch_number, velocity, time)[source]¶ Bases:
object
Represents a MIDI keyon/keyoff event.
- Parameters
event_type – a MIDI message type of “note_on” or “note_off”
pitch_number – int representing the pitch of the key”
velocity – int representing the velocity of keypress
time – number of ticks after the previous event
-
property
event_type
¶
-
property
pitch_number
¶
-
property
time
¶
-
property
velocity
¶
pitchr.predict module¶
-
class
pitchr.predict.
PredictDF
(dataframe)[source]¶ Bases:
pitchr.predict.Predict
A version of the bigram modeller that consumes dataframes