4.1. rpscripts package

4.1.1. Subpackages

4.1.2. Submodules

4.1.3. rpscripts.annotator module

This module provides annotation features. It adds data such as partition into the XML score data and saves as a MXL file.

class rpscripts.annotator.Subparser(subparser: ArgumentParser)[source]

Bases: GeneralSubparser

Implements argparser.

add_arguments() None[source]

Add argparse.ArgumentParser arguments.

handle(args)[source]

Parse arguments and run the module functions.

setup() None[source]

Basic setup.

Set program_name and help message.

rpscripts.annotator.main(m21_score: Score, rpdata: RPData, outfilename: str, labels_name='partitions') None[source]

Add data from given RPData into the given Music21 score and save its in a new outfile.

4.1.4. rpscripts.calculator module

This module provides classes and functions to calculate the rhythmic partitions from a given digital score.

class rpscripts.calculator.MusicalEvent(**kwargs)[source]

Bases: object

Auxiliary musical event class.

This class has only the needed attributes of Music21’s Note, Rest and Chord classes.

is_rest()[source]

Check if the current object represents a music21’ rest object.

set_data_from_m21_obj(m21_obj, measure_number, measure_offset, offset=None)[source]

Get data from given Music21 object, set as current object’s attributes, and return offset and duration.

class rpscripts.calculator.Parsema(**kwargs)[source]

Bases: object

Auxiliary Parsema class.

Parsema is the set of adjacent equal partitions. See Gentil-Nunes 2009 for further information.

add_single_events(single_events: list) None[source]

Set single events, calculate their durations and set partition.

set_partition() None[source]

Create Partition object from single events attribute and set it to partition attribute.

class rpscripts.calculator.ParsemaeSegment(**kwargs)[source]

Bases: object

Parsema segment class.

get_data() tuple[source]

Get partitions, agglomeration, and dispersion data and their locations.

make_from_music21_score(m21_score: Score) None[source]

Create Parsema objects fom given Music21 Score object and store at parsemae class attribute.

make_rpdata(filename: str) RPData[source]

Return RPData object from parsemae class attribute.

class rpscripts.calculator.PartSoundingMap(**kwargs)[source]

Bases: object

Sounding Map class of a musical part.

get_single_event_by_location(global_offset: Fraction) SingleEvent[source]

Return a SingleEvent object from its location.

set_from_m21_part(m21_part: Part) None[source]

Set Music21’s part elements into single_events attribute.

Create MusicEvent objects for each event and then, create SingleEvent objects to add to single_events attribute.

class rpscripts.calculator.ScoreSoundingMap(**kwargs)[source]

Bases: object

Sounding Map class of a musical score. Individual parts are sounding maps.

add_part_sounding_map(m21_part: Part) None[source]

Creates a PartSoundingMap from a given Music21 Part and add it to sounding_maps and attacks attributes.

add_score_sounding_maps(m21_score: Score) None[source]

Create PartSoundingMap objects from each part of a given Music21 Score.

This method also get measure offsets and explodes voices into parts.

get_single_events_by_location(global_offset: Fraction) list[source]

Return a list of SingleEvent objects in different sounding_maps from their locations.

make_parsemae() list[source]

Return a list of Parsema objects from attacks attribute.

This method also handles merged parsemae.

class rpscripts.calculator.SingleEvent(**kwargs)[source]

Bases: object

Auxiliary single event. It’s more simple than Music21’s note and rest objects and has useful attributes such ass number of pitches and sounding.

class rpscripts.calculator.Subparser(subparser: ArgumentParser)[source]

Bases: GeneralSubparser

Implements argparser.

add_arguments() None[source]

Add argparse.ArgumentParser arguments.

handle(args)[source]

Parse arguments and run the module functions.

setup() None[source]

Basic setup.

Set program_name and help message.

rpscripts.calculator.aux_join_music_events(events: dict) dict[source]

Join MusicalEvent

This methods join adjacent tied objects as well as adjacent rests.

rpscripts.calculator.aux_make_events_from_part(m21_part: Part) dict[source]

Return a dictionary with Musical Events and their locations from a given Music21 part object.

rpscripts.calculator.auxiliary_get_duration(m21_obj) Fraction[source]

Return the duration of the given Music21 object as a Fraction object.

rpscripts.calculator.make_music_events_from_part(m21_part: Part) dict[source]

Return a dictionary with location and Musical Events from a given Music21 part object. Adjacent rests and tied notes are joined.

rpscripts.calculator.make_offset_map(m21part: Part) dict[source]

Create map with measure number and global offset value.

rpscripts.calculator.split_part_chords(m21_part: Part) Part[source]

Return a new Music21 Part object with pitches extracted from chords of a given Music21 Part object.

This function splits chords with notes of distinct durations.

rpscripts.calculator.split_score(filename: str) Score[source]

Parse a given digital score file, split chords, convert voices to parts and returns a new Music21 Score object.

4.1.5. rpscripts.cli module

This module provides the command line interface.

rpscripts.cli.main() None[source]

Parse the given command line arguments.

4.1.6. rpscripts.config module

This module contains RP Scripts’ global variables.

These variables are used in multiple modules.

4.1.7. rpscripts.converter module

This module converts calculator’s JSON output into CSV file with or without intermediary equally-sized events.

class rpscripts.converter.Subparser(subparser: ArgumentParser)[source]

Bases: GeneralSubparser

Implements argparser.

add_arguments() None[source]

Add argparse.ArgumentParser arguments.

handle(args) None[source]

Parse arguments and run the module functions.

setup() None[source]

Basic setup.

Set program_name and help message.

rpscripts.converter.main(filename: str, equally_sized=False) None[source]

Create RPData object from given filename and save the data into a csv file.

If equally_sized parameter is true, the events are proportionally divided into smaller events of a unique duration.

4.1.8. rpscripts.info module

This shows information about data.

class rpscripts.info.Subparser(subparser: ArgumentParser)[source]

Bases: GeneralSubparser

Implements argparser.

handle(args)[source]

Parse arguments and run the module functions.

setup() None[source]

Basic setup.

Set program_name and help message.

rpscripts.info.main(filename: str) None[source]

Print basic information about the given filename.

4.1.9. rpscripts.labeler module

This module parses TXT label file and adds this information into the JSON file.

class rpscripts.labeler.Edge(label=None, index=None, global_offset=None)[source]

Bases: object

This class represents the point where a excerpt or section starts.

set_global_offset(offset_map: dict) None[source]

Set the edge global offset from a given offset map.

set_index(offset_map: dict) None[source]

Set the edge index (measure_number + global_offset).

class rpscripts.labeler.Subparser(subparser: ArgumentParser)[source]

Bases: GeneralSubparser

Implements argparser.

add_arguments() None[source]

Add argparse.ArgumentParser arguments.

handle(args)[source]

Parse arguments and run the module functions.

setup() None[source]

Basic setup.

Set program_name and help message.

rpscripts.labeler.main(json_filename: str, txt_fname: str) None[source]

Add the given TXT file labels into the given JSON file.

rpscripts.labeler.parse_txt(filename: str) list[source]

Return list of Edge objects created from extracted labels information given in TXT file.

4.1.10. rpscripts.plotter module

class rpscripts.plotter.AbstractIndexogramPlotter(rpdata: RPData, image_format='svg', close_bubbles=False, show_labels=False)[source]

Bases: AbstractTimePlotter

Abstract indexogram plotter class.

This class extends AbstractTimePlotter and has dispersion and inverted agglomeration data as attributes to help indexograms plotting.

class rpscripts.plotter.AbstractPartitiogramPlotter(rpdata: RPData, image_format='svg', with_labels=True, **kwargs)[source]

Bases: AbstractPlotter

Abstract partitiogram plotter class.

This class extends AbstractPlotter and has agglomeration, dispersion and quantity attributes to help Partitiogram scatter plotting.

check_given_limits() bool[source]

Return True if there are value filters defined.

check_labels()[source]
data_filter() None[source]

Filter the dispersion and agglomeration indexes values for a narrowed plot.

plot()[source]

Extend AbstractPlotter’s method. Set X- and Y-axis labels.

class rpscripts.plotter.AbstractPlotter(rpdata: RPData, image_format='svg')[source]

Bases: object

Main abstract plotter class.

This class has useful attributes and methods to handle RPData objects.

get_subplots()[source]

Return subplots dumped into pickle file.

Useful for multiple chart creation.

plot() None[source]

Plot Setup.

Depends on the extended classes implementation.

save(close_figure=True) None[source]

Saves the chart into the RPData outname.

xticks_adjust() None[source]

Apply tight layout method to the plot object.

It is useful for rotated xlabels charts.

class rpscripts.plotter.AbstractTimePlotter(rpdata: RPData, image_format='svg', show_labels=False)[source]

Bases: AbstractPlotter

Abstract time plotter class.

This class extends AbstractPlotter and handles X-axis to show measure numbers and offsets.

make_xticks() None[source]
plot()[source]

Extend AbstractPlotter’s method. Set X-axis label and add optional vertical lines for labels if they are available in RPData.

xticks_adjust()[source]

Extend AbstractPlotter’s xticks_adjust method.

Rotates xticks.

class rpscripts.plotter.BubblePartitiogramPlotter(rpdata: RPData, image_format='svg', with_labels=True, bubble_size=2000, **kwargs)[source]

Bases: AbstractPartitiogramPlotter

plot()[source]

Extend AbstractPartitiogramPlotter’s method. Create scatter plot.

class rpscripts.plotter.CombinedIndexogramPlotter(rpdata: RPData, image_format='svg', close_bubbles=False, show_labels=False)[source]

Bases: AbstractIndexogramPlotter

plot()[source]

Extend AbstractPlotter’s method. Set X-axis label and add optional vertical lines for labels if they are available in RPData.

class rpscripts.plotter.ComparativePartitiogramMaker(rpdata: RPData, image_format='svg', with_labels=True, **kwargs)[source]

Bases: AbstractPartitiogramPlotter

plot()[source]

Call ComparativePartitiogramPlotter’s plot method for each plotter object available at plotters attribute.

save()[source]

Saves the chart into the RPData outname.

class rpscripts.plotter.ComparativePartitiogramPlotter(rpdata: RPData, column_1, column_2, image_format='svg', with_labels=True, **kwargs)[source]

Bases: AbstractPartitiogramPlotter

plot()[source]

Extend AbstractPartitiogramPlotter’s method. Create multiple superimposed scatter plots.

class rpscripts.plotter.SimpleIndexogramPlotter(rpdata: RPData, image_format='svg', close_bubbles=False, show_labels=False)[source]

Bases: AbstractIndexogramPlotter

plot()[source]

Extend AbstractPlotter’s method. Set X-axis label and add optional vertical lines for labels if they are available in RPData.

class rpscripts.plotter.SimplePartDensityNumberInTimePlotter(rpdata: RPData, image_format='svg', show_labels=False)[source]

Bases: AbstractTimePlotter

plot()[source]

Extend AbstractPlotter’s method. Set X-axis label and add optional vertical lines for labels if they are available in RPData.

class rpscripts.plotter.SimplePartDensityNumberScatterPlotter(rpdata: RPData, image_format='svg', with_labels=False, **kwargs)[source]

Bases: AbstractPlotter

check_given_limits() bool[source]

Return True if there are value filters defined.

check_labels()[source]
data_filter() None[source]

Filter the dispersion and agglomeration indexes values for a narrowed plot.

plot()[source]

Extend AbstractPlotter’s method. Set X- and Y-axis labels.

class rpscripts.plotter.SimplePartitiogramPlotter(rpdata: RPData, image_format='svg', with_labels=True, **kwargs)[source]

Bases: AbstractPartitiogramPlotter

plot()[source]

Extend AbstractPartitiogramPlotter’s method. Create scatter plot.

class rpscripts.plotter.StairsIndexogramPlotter(rpdata: RPData, image_format='svg', close_bubbles=False, show_labels=False)[source]

Bases: AbstractIndexogramPlotter

plot()[source]

Extend AbstractPlotter’s method. Set X-axis label and add optional vertical lines for labels if they are available in RPData.

class rpscripts.plotter.StemIndexogramPlotter(rpdata: RPData, image_format='svg', close_bubbles=False, show_labels=False)[source]

Bases: AbstractIndexogramPlotter

plot()[source]

Extend AbstractPlotter’s method. Set X-axis label and add optional vertical lines for labels if they are available in RPData.

class rpscripts.plotter.StepIndexogramPlotter(rpdata: RPData, image_format='svg', close_bubbles=False, show_labels=False)[source]

Bases: AbstractIndexogramPlotter

plot()[source]

Extend AbstractPlotter’s method. Set X-axis label and add optional vertical lines for labels if they are available in RPData.

class rpscripts.plotter.Subparser(subparser: ArgumentParser)[source]

Bases: GeneralSubparser

Implements argparser.

add_arguments() None[source]

Add argparse.ArgumentParser arguments.

handle(args)[source]

Parse arguments and run the module functions.

setup() None[source]

Basic setup.

Set program_name and help message.

4.1.11. rpscripts.stats module

This module provides a few statistical data about the given filename.

class rpscripts.stats.AgglomerationDispersionStatistics(rpdata: RPData, image_format='svg')[source]

Bases: Statistics

get_histograms(no_plot: bool, split_labels: bool) None[source]

Make histogram and print statistical summary of agglomeration and dispersion indexes.

class rpscripts.stats.PartsDensityNumberStatistics(rpdata: RPData, image_format='svg')[source]

Bases: Statistics

get_histograms(no_plot: bool, split_labels: bool) None[source]

Make histogram and print statistical summary of number of parts and density number.

class rpscripts.stats.Statistics(rpdata: RPData, name: str, image_format='svg')[source]

Bases: object

Auxiliary class for statistics calculus.

get_histograms(no_plot: bool, split_labels: bool) None[source]

Make histogram and print statistical summary.

class rpscripts.stats.Subparser(subparser: ArgumentParser)[source]

Bases: GeneralSubparser

Implements argparser.

add_arguments() None[source]

Add argparse.ArgumentParser arguments.

handle(args)[source]

Parse arguments and run the module functions.

setup() None[source]

Basic setup.

Set program_name and help message.

4.1.12. rpscripts.tclass module

This module generates textural classes data and chart.

For further information about textural classes, see Daniel Moreira (2019).

Moreira, Daniel. 2019. “Textural Design: A Compositional Theory for the Organization of Musical Texture.” Ph.D. Thesis, Universidade Federal do Rio de Janeiro.

class rpscripts.tclass.ExtendedPartition(parts=None)[source]

Bases: Partition

Extend Partition class to handle partition classes.

get_texture_class()[source]

Get the partition’s textural class.

class rpscripts.tclass.ExtendedRPData(path=None)[source]

Bases: RPData

Extend RPData class to add tclass data.

make_counting_chart(filename=None) None[source]

Save counting chart into given filename.

set_textural_classes() None[source]

Set textural class into RPData.

class rpscripts.tclass.Subparser(subparser: ArgumentParser)[source]

Bases: GeneralSubparser

Implements argparser.

add_arguments() None[source]

Add argparse.ArgumentParser arguments.

handle(args)[source]

Parse arguments and run the module functions.

setup() None[source]

Basic setup.

Set program_name and help message.

class rpscripts.tclass.TexturalClassPlot(rpdata: RPData, image_format='svg', show_labels=False, as_step=False)[source]

Bases: AbstractTimePlotter

Textural Class Plot class.

plot()[source]

Extend AbstractPlotter’s method. Set X-axis label and add optional vertical lines for labels if they are available in RPData.

rpscripts.tclass.are_classes_neighbors(class1: str, class2: str) bool[source]

Check if both classes are neighbors.

rpscripts.tclass.get_partition_texture_class(str_partition: str) str[source]

Get the textural class of a given partition.

4.1.13. rpscripts.tcontour module

This module generates complexity map and adds level and sublevel complexity to given csv rhythmic partitioning data.

For further information, see Daniel Moreira (2015 and 2019).

Moreira, Daniel. 2015. “Perspectivas para a análise textural a partir da mediação entre a teoria dos contornos e a análise particional.” Dissertação de mestrado, Universidade Federal do Rio de Janeiro.

Moreira, Daniel. 2019. “Textural Design: A Compositional Theory for the Organization of Musical Texture.” Ph.D. Thesis, Universidade Federal do Rio de Janeiro.

class rpscripts.tcontour.Contour(str_partitions, complexity_map, locations, indexes)[source]

Bases: object

Contour class. It handles the contour points.

make_complexity_data() None[source]

Make the complexity data from the available sequences of complexity levels and sublevels.

make_contour() None[source]

Make the contour from the available complexity levels and partitions information.

make_maps(complexity_map: dict) None[source]

Make and set levels map and partitions info about complexity level and number of parts.

class rpscripts.tcontour.ContourPlot(contour: Contour, rpdata: RPData, image_format='svg', show_labels=False, run_lowess=False, lowess_degree=0.05, as_step=False)[source]

Bases: AbstractTimePlotter

Contour Plot class.

plot()[source]

Extend AbstractPlotter’s method. Set X-axis label and add optional vertical lines for labels if they are available in RPData.

class rpscripts.tcontour.ContourPoint(level=None, sublevel=None, partition_str=None)[source]

Bases: object

Contour point class. It handles complexity level and sublevel

class rpscripts.tcontour.ExtendedPartition(parts=None)[source]

Bases: Partition

Extend Partition class to handle textural contour.

get_complexity_level(complexity_map: dict) int[source]

Return partition’s complexity level.

class rpscripts.tcontour.ExtendedRPData(path=None)[source]

Bases: RPData

Extend RPData class to add complexity (contour) data.

add_complexity_data(contour: Contour)[source]
class rpscripts.tcontour.Subparser(subparser: ArgumentParser)[source]

Bases: GeneralSubparser

Implements argparser.

add_arguments() None[source]

Add argparse.ArgumentParser arguments.

handle(args)[source]

Parse arguments and run the module functions.

setup() None[source]

Basic setup.

Set program_name and help message.

rpscripts.tcontour.make_contour_object(rpdata: RPData, complexity_map: dict) Contour[source]

Return a contour object.

4.1.14. rpscripts.trimmer module

This module cuts off a given calc’s JSON output file by given start and end measure numbers and return a new JSON file.

class rpscripts.trimmer.Subparser(subparser: ArgumentParser)[source]

Bases: GeneralSubparser

Implements argparser.

add_arguments() None[source]

Add argparse.ArgumentParser arguments.

handle(args)[source]

Parse arguments and run the module functions.

setup() None[source]

Basic setup.

Set program_name and help message.

rpscripts.trimmer.main(rpdata: RPData, start_measure, end_measure) None[source]

Trim the given RPData between the given start and end measures.

4.1.15. rpscripts.utils module

This module contains helpful tools for the rhythmic partitioning task.

class rpscripts.utils.Subparser(subparser: ArgumentParser)[source]

Bases: GeneralSubparser

Implements argparser.

add_arguments() None[source]

Add argparse.ArgumentParser arguments.

handle(args)[source]

Parse arguments and run the module functions.

setup() None[source]

Basic setup.

Set program_name and help message.

rpscripts.utils.copy_default_lattice_map() None[source]

Copy lattice map to the default path.

rpscripts.utils.save_map(lexset: int) None[source]

Create a partition lattice of lexset size and save into the program’s default path.

4.1.16. Module contents

Provide main modules and classes.