Technical documentation

Overview

The main modules

  • The motor of PYNWC is the main script Pythonnwc.

    For the Noteworthy Software application (NWC), Pythonnwc is just one user tool, but when started, you see a window where you have the choise between several tools. So PYNWC is a tool environment within the user tool environment of NWC.

  • The NWC file that’s opened in NWC when you start Pythonnwc is read from the standard input (stdin).

  • The module NWC classes is used to create a ‘score object<NwcFile>’ from the input file.

  • Validity checking of the input is done via the module NWC terms.

  • The module NWC types contains the definition of the types used in PYNWC.

  • The module NWC xlsx writer writes a workbook from a dictionary.

Tool structure

Present in every tool:

  • A docstring with a short one line description, followed by a blank line, followed by a full description of the tool.

    The first line will be shown in the reporting frame when a tool is selected. The lines after the blank line are used as help information when the button ‘Help’ is pressed.

  • The descriptive ‘name’ of the tool, which is shown in the selection frame of the main window.

  • A list ‘report’: each action taken by the tool is registered in this list and shown in the reporting frame of the main window.

  • A list ‘summary’: a summary overview of the actions.

  • A dictionary of ‘features’:
    • mode: ‘edit’ or ‘report’

    • needs selection: ‘Yes’ or ‘No’

    • has parameters: ‘Yes’ or ‘No’

    • output file types: NWCtext Files (.nwctxt), Text Files (.txt) or XLSX Files (.xls)

  • An instance ‘G’ of a DictClass, containing the global variables:
    • the score

    • if the tool has parameters:
      • the layout for the tool parameter window

      • the parameter_values

      • a function to get the parameters from the tool parameter window

    • variables, specific for the tool itself

  • A function init(score: NWCFile, config: ParmDict). The function is called when a tool is selected and contains following actions:
    • restore the global variables to their original values; this is necessary because a tool can be selected more than once in the same session of PYNWC

    • store the argument ‘score’ in the global variables

    • if the tool has parameters:
      • initialise the parameter values: use the values from config if present or default values.

      • set global variables from the parameter values

      • create a layout for the tool parameter window

      • store a reference in the global variable to the function that gets the parameter values from the tool parameter window

  • Functions if the tool has parameters:
    • create_parameter_layout()

    • get_parameter_values(values)

    • set_parameter_variables(parameter_values)

    • update_parameter_window(window, event, values)

  • A function run().

    This function is called when the button ‘Run Tool’ on the main window is pressed.

  • A function finish() that restores the global variables.

    This function is called when a tool has been run and the main script has done the reporting.

Scenario

  • Upon start:
    • the input file is read from stdin and a NwcFile object is created

    • the configuration file is read into a dictionary (with the tool name as key)

    • the main window is constructed

    • some information about the score is shown in the reporting window

    • if the command line contains arguments (see ‘Installation for a specific tool’ in Installing PYNWC), they are processsed

    • user interaction is awaited

  • actions after a user interaction:
    • Tool selection:
      • The tool name and its features are shown in the reporting frame.

      • The init() function of the tool is called.

    • Button ‘HELP’ is pressed: a help window is opened.
      • If no tool was selected, the general help text is shown.

      • If a tool is selected, the help text of that tool is shown. Via a radio button the user can get the general help text.

    • Button ‘Show Score Info’ is pressed:

      Some info about the score is shown in the reporting frame.

    • Button ‘Tool Parameters’ is pressed (only enabled when a tool with parameters is selected):
      • A parameter window is shown; the layout is determined by the specific tool function create_parameter_layout.

      • When the user exits this window, the values of that window are processed by the selected tool function get_parameter_values and stored in the global variables of the tool.

      • The parameter values for the tool are updated in the configuration dictionary.

    • Button ‘Run Tool’ is pressed:
      • The run() function of the selected tool is called.

      • The resulted report and summary lines are shown in the reporting frame.

      • A list of output lines is formed with:
        • If the tool has mode ‘edit’ and changes to the score are made: the new file representation.

        • If the tool had mode ‘report’: the report lines.

      • The finish() function of the selected tool is called.

    • Button ‘Show Output’ is pressed:

      the output lines are shown in the reporting frame.

    • Button ‘Save Changes’ is pressed:
      • A popup ‘Save changes?’ appears.

      • If the user confirms, the output lines with the representation of the changed score is written to stdout.

    • Button ‘Save as’ is pressed:
      • The output file path is set:
        • The folder must be specified by the user.

        • If the tool returned a value for ‘output_filename’, this is used as the default base file name, otherwise the input file name.

        • The extension is set on the basis of the tool feature ‘output file types’.

        • The user has still the opportunity to change the file name.

      • The file is saved, after confirmation by the user.

    • Button ‘EXIT’ is pressed:
      • If the score was changed and has’nt been saved, a popup ‘Save changes?’ will appear and, if the user confirms, the output lines with the representation of the changed score is written to stdout.

      • The main window is closed.

      • The configuratioen dictionary with the tool parameters is saved in the configuration file.

Main script

Pythonnwc

Environment to run Python tools in NWC (NoteWorthy Composer).

  • Reads the input file from stdin and creates the score object.

  • Reads the tool parameter values from the configuration file.

  • Reads and processes command line arguments, if present.

  • Opens the PYNWCTools window, shows score info and processes the events.

  • Saves the configuration file.

command line arguments
-t <tool name>, --tool <tool name>: select the tool
-p, --parameters: show the tool parameters
-r, --run: run the tool
-c, --save: save changes
-e, --exit: exit
events

Selection of a tool

Button ‘HELP’ pressed

Button ‘Show Score Info’ pressed

Button ‘Tool Parameters’ pressed

Button ‘Run Tool’ pressed

Button ‘Show Output’ pressed

Button ‘Save Changes’ pressed

Button ‘Save as’ pressed

Button ‘EXIT’ pressed

class pythonnwc.G

Global variables.

pythonnwc.close(values=None) → None

Invoked after event ‘EXIT’.

pythonnwc.help(main_window_values)

invoked after event ‘HELP’.

pythonnwc.run_tool(values=None) → None

Invoked after event ‘Run Tool’.

pythonnwc.save(values=None, close: bool = False) → None

Invoked after event ‘Save Changes’.

Shows a confirmation screen and, if confirmed, saves the changes in the score.

pythonnwc.save_output_file(values) → None

Invoked after event ‘Save as’.

pythonnwc.select_tool(values=None, index: int = None) → None

Invoked by the event ‘Select a tool’.

  • Shows the selected tool name, its features and the actual parameter values (if any) in the reporting frame.

  • Gets the output file types.

  • Calls the init function of the tool.

pythonnwc.show_output(values) → None

Invoked after event ‘Show Output’, if the tool edited the score of produced a text file.

pythonnwc.show_score_info(values=None) → None

Invoked at opening of the environment window and after event ‘Show Score Info’.

Shows info:

  • File path

  • Last modified

  • Song title

  • For each staff:
    • muted and/or hidden

    • name[(hidden)]

    • number of measures

  • Active staff

  • Selection from … to …

General modules

NWC classes

Definition of the classes.

Structure of the classes and subclasses:

class nwc_classes.Chord(line, score, staff_index=None)
class nwc_classes.Clef(line, score, staff_index=None)
class nwc_classes.Editor(line, score)
class nwc_classes.Font(line, score)
class nwc_classes.General(line, score, staff_index=None)
class nwc_classes.Instrument(line, score, staff_index=None)
class nwc_classes.Key(line, score, staff_index=None)
class nwc_classes.LyricLine(line, score, staff_index=None)
class nwc_classes.Lyrics(line, score, staff_index=None)
class nwc_classes.Note(line, score, staff_index=None)
class nwc_classes.NwcFile(nwc_file)
Parameters

nwc_file (list[str]) – the input file, read from stdin

Main attributes

For each input line (except header and trailer) a NwcObject is created.

report(classes=None, file_headers: bool = True, staff_headers: bool = True, staff_instrument: bool = True, staff_lyrics: bool = True, staff_objects: bool = True) → List

Shows ‘translation’ of the file into the internal representation that’s used by the tools.

repr_file() → List[Union[Literal[|], str]]

Creates nwctxt lines that can be stored as a file.

:return:List[NWCline]

class nwc_classes.NwcObject(line: str, score: nwc_classes.NwcFile, staff_index=None)

Basic object, the building block for the score.

Parameters
  • line (str) – input line from stdin

  • score (NwcFile) – the NwcFile object from the input file

  • staff_index(optional) (int) – the index of the staff the object belongs to

add(key: str, value: Any, dur_index: int = 0, pos_index: int = 0)

Adds a value to self.dur_features, self.pos_feature, self.fields or self.opts(depending on the key).

get(key: str, default=None) → Any

Gets the value from self.fields or self.opts.

has_duration() → bool
has_notes() → bool
is_score_header() → bool
is_staff_header() → bool
is_type(object_type: str) → bool
set(key: str, value: Any, dur_index: int = 0, pos_index: int = 0)

Sets a value in self.dur_features, self.pos_feature, self.fields or self.opts(depending on the key).

class nwc_classes.PageMargins(line, score)
class nwc_classes.PageSetup(line, score)
class nwc_classes.Playable(line, score, staff_index=None)
property accidentals

derived from pos_features

can_have_lyric() → bool
property courtesy_accs

derived from pos_features

property dots

derived from dur_features

property dur_features

features related to the duration(s) of the object: Duration, Tics (a whole note = 768 tics), Dotted, DblDotted, Triplet, Slur, Grace, Marcato, Staccato, Staccatissimo, Accent, Tenuto.

  • Duration and Tics are always present, the other features only when they apply.

  • the structure is a list of 1 or 2 dictionaries(see also: derived properties).
    • e.g.: [{‘Duration’: ‘8th’, ‘Staccato’: True, ‘Tics’: 96}, {‘Duration’: ‘4th’, ‘Tics’: 192}]

    • derived properties: durations: [‘8th’, ‘4th’], Tics: [96, 192]

property durations

derived from dur_features

has_position() → bool
has_position2() → bool
has_slur() → bool
is_beamed() → bool
is_tripled() → bool
property noteheads

derived from pos_features

property pos_colors

derived from pos_features (refers to the color of individual notes of a chord or restchord, dont confuse with opts[‘Color’])

property pos_features

features related to the position(s) of the object: position, color, tied, accidental, courtesyacc, notehead.

  • the position is always present, the other features only when they apply.

  • the structure is a list of 1 or 2 lists of dictionaries(see also: derived properties).

  • for each value of the position, pos_features contains a dictionary with the feature names as key.

  • for each value of the duration, the feature dictionaries are put together in a list

  • the simplest case is an object that has no duration:
    • e.g.: pos_features: [[{‘position’: -4.0}]]

    • derived property: ‘position’: -4.0

  • for a single note, we can have e.g.: pos_features: [[{‘accidental’: ‘sharp’, ‘tied’: True, ‘position’: 0.0}]]
    • derived properties: positions: [0.0], pos_accidentals: [‘sharp’], ties: [True]

  • the most general case is a chord consisting of notes of different duration,
    • e.g.: [[{‘accidental’: ‘flat’, ‘position’: -4.0}, {‘position’: -2.0}], [{‘position’: -1.0}, {‘position’: 2.0}]]

    • the order is acsending duration / ascending position

    • derived properties: positions: [-4.0, -2.0, -1.0, 2.0], pos_accidentals: [‘flat’, None, None, None]

property position

derived from pos_features (not for chords and restchords, see also: positions)

property positions

derived from pos_features (only for chords and restchords, see also: position)

property tics

derived from dur_features

property ties

derived from pos_features

class nwc_classes.Properties(line, score, staff_index=None)
class nwc_classes.Qualifier(line, score, staff_index=None)
class nwc_classes.Rest(line, score, staff_index=None)
class nwc_classes.RestChord(line, score, staff_index=None)
class nwc_classes.RestMultiBar(line, score, staff_index=None)
class nwc_classes.ScoreHeader(line, score)
class nwc_classes.SongInfo(line, score)
class nwc_classes.Staff(object: nwc_classes.NwcObject, score: nwc_classes.NwcFile)
Parameters
  • object (General) – object that gives rise to creating a staff

  • score – the NwcFile object from the input file

refresh(ind: int = 0)

Recalculates the locative attributes of the staff objects.

Parameters

ind (int) – the index of the first staff object to refresh.

Returns

class nwc_classes.StaffHeader(line, score, staff_index=None)
class nwc_classes.StaffObject(line, score, staff_index=None)
class nwc_classes.Tempo(line, score, staff_index=None)
class nwc_classes.TimeSignature(line, score, staff_index=None)

NWC terms

Contains dictionaries to validate NWC-objects.

  • type_field_lists: valid fields per object type

  • type_field_value_lists: valid values per type_field (special case: type_field_value_lists[“ObjType”] contains the valid object types).

NWC Types

Definition of types used in PYNWC.

class nwc_types.DictClass(**kwargs)

Dict-like class with attributes instead of keys. The initial values are remembered and can be restored.

restore(*attributes)

Restores the initial value (default: all attributes).

class nwc_types.MagicDict

Xlsx module

my_xlsxwriter.write_workbook_from_dict(workbook_name: str, xlsx_dict: Dict[str, Union[List[str], Dict[str, List[Any]]]]) → None

Adds apropriate format and stores the xlsx file from the dictionary with sheet information.

Parameters
  • workbook_name – path name of the xlsx file to be saved

  • xlsx_dict – dictionary with sheets

Returns

None

Tool modules

Add rest measures

Adds ‘rest measures’ to the staves that have less measures then the active staff.

This tool completes the staves that have less measures than the active staff with ‘rest measures’(*).

The tool parameters determine whether or not the hidden staves are processed.

(*)A ‘rest measure’ is constructed from a copy of the corresponding measure in the active staff, replacing notes, chords and restchords with rests of the same duration and leaving the other objects as they are.

add_rest_measures.create_parameter_layout() → List[List[Callable]]

Creates a layout for the variable part of the ‘Tool Parameters’ window:

Two radio buttons (“No”, “Yes”) for ‘Process hidden staves?’.

add_rest_measures.finish()

Restoring static state of global variables. This function is called after running tool.run

add_rest_measures.init(score: nwc_classes.NwcFile, config: Dict[str, Dict[str, Any]] = None)

Initialisation of the global variables. This function is called when the tool is selected.

add_rest_measures.run() → Dict[str, Union[List[str], Dict[str, Union[List[str], Dict[str, List[Any]]]]]]

Add ‘rest measures’ to staves that have less measures than the active staff.

Returns

A dictionary:

  • ”Report”: a list of report lines.

  • ”Summary”: a list of summary lines.

  • ”Edited”: True if there has been some editing of the score.

Side effects

Rest measures are inserted in global variable G.score.

add_rest_measures.set_parameter_variables(values: Dict[str, Any]) → None

Sets the global variables that depend on the parameters

Analyse score

Creates an analysis report of the score.

The analysis of the score is divided into several analysis groups. You can see these groups in the ‘Tool Parameters’ window.

There are 2 categories of groups:

  • The ‘Staff Properties’ groups: they report several staff properties.

  • The ‘Object Type’ groups contain the measure numbers for each particular value of the main property for a certain object type.

    For some object types, extra properties can be reported (e.g. velocity and volume for dynamics).

In the ‘Tool Parameters’ window, you can uncheck the groups and/or properties that you want to exclude from the analysis.

The results are presented on a window with one tab per group.

When the ‘OK’ button of this window is pressed, the report can be saved into a xlsx file by pressing ‘Save as’ on the main window. In this file, the results are presented in one sheet per group.

analyse_score.create_parameter_layout() → List[List[Callable]]

Creates a layout with the rows for the ‘Tool Parameters’ window.

analyse_score.create_xlsx_dict(score: nwc_classes.NwcFile) → Dict[str, Union[List[str], Dict[str, List[Any]]]]

Creates a dictionary with sheet names and result sheets. Used as parameter for write_workbook_from_dict

Parameters

score (NwcFile) –

Returns

Dictionary with sheet names and result sheets.

analyse_score.finish()

Restoring static state of global variables. This function is called after running tool.run

analyse_score.get_parameter_values(WindowValues: Dict[str, Any]) → Dict[str, Any]

Set the parameter values from the output of the ‘Tool Parameters’ window.

Parameters

values (Dict) – Output values of the ‘Parameter Tools’ window.

Returns

The parameter values.

Return type

Dict

analyse_score.init(score: nwc_classes.NwcFile, config: Dict[str, Dict[str, Any]])

Initialisation of the global variables. Runs when the tool is selected.

analyse_score.run() → Dict[str, Union[List[str], Dict[str, Union[List[str], Dict[str, List[Any]]]]]]

Creates an analysis report of the score.

Returns

A dictionary:

  • ”Report”: a list of report lines.

  • ”Summary”: a list of summary lines.

  • ”Xlsx”: a dictionary with sheet names and result sheets.

Side effects

A window with the analysis results is shown.

analyse_score.show_window(score: nwc_classes.NwcFile) → None

Creates a window with the results of the analysis.

:param score :type score: ´NwcFile´ :return: None

Color beams, slurs and triplets

Colors beams, slurs and triplets in the selection.

When you select notes in a NWC file and change the color, the beams, slurs and triplet bracket still have the old color.

With this tool, the necessary markers and beam objects are created, so that everything will be colored.

It contains an algorithm to determine the position and final stemlength of the beam object and the position of the triplet and slur marker, but maybe you need to change them for an optimal result.

The tool operates on the selection you made on the score. The objects with a default color will get the color of the first selected object.

color_beams_slurs_triplets.beam_object_opts(object: nwc_classes.NwcObject) → Tuple[str, str]

Calculates position and final stemlength of the beam user object to be created.

Parameters

object (NwcObject) – first note or chord in a beamed serie

Returns

beam_pos

Returns

final_stemlength

Return type

Tuple[str, str]

color_beams_slurs_triplets.finish()

Restoring static state of global variables. This function is called after running tool.run

color_beams_slurs_triplets.init(score: nwc_classes.NwcFile, config: Dict[str, Dict[str, Any]])

Initialisation of the global variables. This function is called when the tool is selected.

color_beams_slurs_triplets.slur_marker_position(object: nwc_classes.NwcObject) → float

Calculates the position of the marker object to be inserted.

Parameters

object (NwcObject) – object having a slur

Returns

position of the slur marker

Return type

float

color_beams_slurs_triplets.triplet_marker_position(object: nwc_classes.NwcObject, beam_object: nwc_classes.NwcObject) → float

Calculates the position of the triplet marker to be created.

Parameters
  • object (NwcObject) – last object of a triplet serie

  • beam_object – the created beam object or None

Returns

position of the triplet marker

Return type

float

Color flow changes

Colors flow changes.

This tool colors all items that change the direction of the flow:

  • flow direction objects(Coda, Segno, Fine, …, D.S. al Fine)

  • repeat bars

  • special endings

Via ‘Tool Parameters’ you can set:

  • the color for the flow change objects

  • the staves to be processed

color_flow_changes.create_parameter_layout() → List[List[Callable]]

Creates a layout for the variable part of the ‘Tool Parameters’ window: a listbox to set the color.

color_flow_changes.finish()

Restoring static state of global variables. This function is called after running tool.run

color_flow_changes.init(score: nwc_classes.NwcFile, config: Dict[str, Dict[str, Any]])

Initialization of the global variables. This function is called when the tool is selected.

color_flow_changes.run() → Dict[str, Union[List[str], Dict[str, Union[List[str], Dict[str, List[Any]]]]]]

Colors all items that change the direction of the flow.

Returns

A dictionary:

  • ”Report”: a list of report lines.

  • ”Summary”: a list of summary lines.

  • ”Edited”: True if there has been some editing of the score.

Side effects

Rest measures are inserted in global variable G.score.

color_flow_changes.set_parameter_variables(values: Dict[str, Any]) → None

Sets the global variables that depend on the parameters

Layer voices

Layer 2 voices and do necessary changes to get a ‘neat’ visual result.

In many song sheets for choirs, each group of two voices is on 1 staff. In NWC, you can do this by entering chords, or by layering each group of two staves.

Entering chords is not very easy + you don’t always have control over the stems of the individual notes of a chord, which is necessary to differentiate between the two voices.

On the other hand, when layering, you not only have to set the stems. In order not to have a messy result after layering, you also have to set the properties ‘Use stem for articulation’, ‘Slur direction’ and ‘Tie direction’.

Furthermore, you have to check the whole staff for situations where you have to set the properties ‘Extra note spacing’ and/or ‘Extra accidental spacing’.

This tool takes care of all this.

In addition:

If both staves have lyrics, the property ‘Placement’ will be set to ‘Top’, resp. ‘Bottom’.

The label of the bottom staff will be changed to the combination of the 2 labels.

Via a popup window you can choose which pair of staves you want to be layered.

REMARK: Because of the many changes, you’ll be asked if a safety copy of the original file is to be created before layering.

class layer_voices.PlayLocation(staff: nwc_classes.Staff, index: int)
layer_voices.finish()

Restoring static state of global variables. This function is called after running tool.run

layer_voices.init(score: nwc_classes.NwcFile, config: Dict[str, Dict[str, Any]])

Initialisation of the global variables. This function is called when the tool is selected.

layer_voices.layer_locs(top: nwc_classes.Staff, bottom: nwc_classes.Staff)

Yields the locations of the next layer_pair.

layer_voices.playables(staff: nwc_classes.Staff)

Yields the next object with duration except multibarrests.

layer_voices.run() → Dict[str, Union[List[str], Dict[str, Union[List[str], Dict[str, List[Any]]]]]]

Layer 2 voices and do necessary changes to get a ‘neat’ visual result.

Returns

A dictionary:

  • ”Report”: a list of report lines.

  • ”Summary”: a list of summary lines.

  • ”Edited”: True if there has been some editing of the score.

Side effects
  • If ‘Edited’ is True, the score has been changed.

layer_voices.tune_contains_chord(top_object, bottom_object)

Sets extra note space on bottom staff.

layer_voices.tune_contains_rest(top_object, bottom_object)

Sets vertical offset.

layer_voices.tune_notes(top_object: nwc_classes.NwcObject, bottom_object: nwc_classes.NwcObject)

Sets extra note space and extra accidental space.

  1. check accidentals and vertical distance

  2. if distance == 0 : check for white/black notes

  3. if distance between -2 and 2: check for dots

Make rehearsal file

Creates a rehearsal file.

For each staff, you can assign one of three ‘play modes’: background voice, foreground voice or instrument. After you click ‘OK’, the staff volume, stereo pan, color and dynamics will be changed according to the ‘Tool Parameters’.

So, before you run this tool for the first time, take a look at the ‘Tool Parameters’ window.

The left frame shows the ‘Play mode Staff Properties’. Here you can set the staff volume, stereo pan and color for the three play modes.

The right frame concerns the ‘Default Dynamic Velocities’. Here you can choose the values for the default dynamic velocities that will be set in the instrument panel for each staff of your score. These values are used to calculate the velocity and volume settings of the dynamics. (For more information: see document ‘Dynamics.pdf’ in <http://nwc-scriptorium.org/helpful.html#Explanations>) You can either choose for the velocities of the active staff (which are shown at the top op the frame, or for the parameter values.

After you pressed ‘Run Tool’, have set the play modes and pressed ‘OK’:

  • The chosen default dynamic velocities are copied in each staff.

  • The staff properties are changed according to the tool parameters.

  • The velocity and volume settings of the dynamics are calculated as follows:

    • for a voice staff :

      ° The ‘custom velocity’ of each dynamic is set equal to the highest value of the default dynamic velocity (‘fff’).

      ° The ‘custom volume’ is set using Tina Billet’s formula : Volume = default velocity for the dynamic * Staff Volume / highest velocity.

    • for an instrument staff: the custom velocity and volume are unchecked.

Tip: Use the button ‘Save as’ to create a rehearsal file and add the label of the foreground voice to the file name. You can do this for each voice as foreground while keeping the original file unchanged by answering ‘No’ the the popup ‘Save changes?’

rehearsal_file.Tina_Billets_formula(default_velocity, staff_volume, high_velocity)

Calculate velocity and volume for a dynamic.

rehearsal_file.create_parameter_layout() → List[List[Callable]]

Create a layout with the rows of the ‘Tool Parameters’ window.

rehearsal_file.finish()

Restore the static state of global variables. This function is called after running tool.run

rehearsal_file.init(score: nwc_classes.NwcFile, config: Dict[str, Dict[str, Any]])

Initialise the global variables. This function is called when the tool is selected.

rehearsal_file.run() → Dict[str, Union[List[str], Dict[str, Union[List[str], Dict[str, List[Any]]]]]]
Returns

A dictionary:

“Report”: a list of report lines.

“Summary”: a list of summary lines.

Side effects

changes the score

rehearsal_file.set_dynamics(staff, play_mode, high_velocity)

Set the velcity and volume for the dynamics in a staff.

rehearsal_file.set_parameter_variables(values) → None

Set the global variables that depend on the parameters.

rehearsal_file.set_staff_properties(staff, play_mode)

Set the staff_properties according to the play_modes of the staff.

Organize files

Version management for your NWC files.

The purpose of this tool is to provide a sort of ‘version management’. A possible scenario:

  • When you think a draft version of your score is ready to be ‘promoted’ or secured:
    • register the date last modified in the File Info comments section.

    • create a read-only copy in a dedicated folder, with one or more suffixes added to the file name to see at a glance the date last modified, the creation date of the copy and/or a ‘version text’.

  • Then you can safely continue working with the original draft version.

  • If you want to work again with the secured version, you could unlock it, or leave it locked and create a new, writable copy in your ‘working’ folder.

The tool window:

  • The date modified, shown at the top of the window, is extracted from the windows file system.

  • The ‘File Info Comments’ frame shows the comment section of the ‘File Info’ from the input file.

  • The actions lock or unlock input file will be done after you click ‘OK’.

  • The other actions that you select in the ‘Actions’ frame are not accomplished until you click one of the buttons ‘Save changes’ or ‘Save as’ in the main window.

Via the Tool Parameters you can change following values:

  • The caption for the date modified text (default = ‘Last Modified’

  • The PageStyle for the print object (default = ‘Modified’)

  • The font and font size (default = StaffItalic, size 1.0)

  • The location of the print object (default = bottom left, X- and Y-offset 0)

If you save a copy of the input file, you can add one or more suffixes:

  • #m, followed by the date modified

  • #c, followed by the creation date of the copy

  • #v, followed by a self chosen text

(Remark: Any suffixes of the input file are not retained in the name of the copy.)

Via a popup window you can choose or create the folder for the copy.

organize_files.create_print_objects()

Creates(but doesn’t save it yet) the necessary user object(s) to print the date modified at the bottom of each page on each page.

organize_files.init(score: nwc_classes.NwcFile, config: Dict[str, Dict[str, Any]]) → None

Initialisation of the global variables. This function is called when the tool is selected.

organize_files.lock_inputfile()

Locks the input file (after confirmation). Executed after ‘OK’ has been pressed on the tool window and ‘Lock input file’ was checked.

organize_files.register_lock_input_file()

Registers that ‘Unlock input file’ was checked.

organize_files.register_unlock_input_file()

Registers that ‘Unlock input file’ was checked.

organize_files.run()

Creates and processes a window with the possible actions.

organize_files.set_parameter_variables(parameter_values: Dict[str, Any]) → None

Sets the global variables that depend on the parameters

organize_files.store_date_modified() → None

Stores(but doesn’t save it yet) the date modified in the comments section of the ‘File Info’.

organize_files.unlock_inputfile()

Unlocks the input file (after confirmation). Executed after ‘OK’ has been pressen on the tool window and ‘Unlock input file’ was checked.

Set Staff Properties

Set general, visual and midi staff properties for every staves in one window.

The window of this tool contains 5 tabs: ‘General’, Visual’, ‘Midi’,Instrument and ‘Default Dynamic Velocities’. These tabs correspondent with the tabs or the Staff Properties Window of NWC, with following exceptions: - In the ‘Visual’ tab, you can also change ‘Allow layering’ (at the bottom), although it’s not a staff property.

  • The ‘Midi’ tab doesn’t contain the playback device.

  • In the ‘Instrument’ tab, the instrument name, patch and bank are showed but can’t be changed.

  • The default dynamic velocities have their own tab.

In each tab you have a staves column, a selection column, followed by some property columns. If you want to change a certain property for a certain staff, just change the value in the appropriate row/column combination.

But it’s also possible to change a property for more than one staff in one go, via the top row. The cells in the top row are disabled until you tick one of more boxes in the selection column. (Ticking the top most box will check all boxes.) The staff names of the selected rows will appear in green. You can then change a property for the selected staves in one go via the op row.

If needed, you can repeat this for other selections and properties. (Ticking the top most box twice will remove all selections.)

set_staff_properties.finish()

Restoring static state of global variables. This function is called after running tool.run

set_staff_properties.init(score: nwc_classes.NwcFile, config: Dict[str, Dict[str, Any]])

Initialisation of the global variables. This function is called when the tool is selected.

Show clip

Shows ‘translation’ of the selected object(s) into the internal representation that’s used by the tools.

This tool shows a translation of the selected object(s) into the internal representation that’s used by the tools.

show_clip.finish()

Restoring static state of global variables. This function is called after running tool.run

show_clip.init(score: nwc_classes.NwcFile, config: Dict[str, Dict[str, Any]])

Initialisation of the global variables. This function is called when the tool is selected.

Show file

Shows ‘translation’ of the file objects into the internal representation that’s used by the tools.

This tool shows a translation of the file objects into the internal representation that’s used by the tools. The tool parameters determine the objects that are shown.

show_file.finish()

Restoring static state of global variables. This function is called after running tool.run

show_file.init(score: nwc_classes.NwcFile, config: Dict[str, Dict[str, Any]])

Initialisation of the global variables. This function is called when the tool is selected.

Transfer selection

Copies the selected objects to the other staves.

The selected objects are copied to the other staves. The tool parameters determine whether or not the hidden staves are processed.

transfer_selection.create_parameter_layout() → List[List[Callable]]

Create a layout with the rows of the ‘Tool Parameters’ window.

transfer_selection.finish()

Restore the static state of global variables. This function is called after running tool.run

transfer_selection.init(score: nwc_classes.NwcFile, config: Dict[str, Dict[str, Any]])

Initialise the global variables. This function is called when the tool is selected.

transfer_selection.set_parameter_variables(values: Dict[str, Any]) → None

Set the global variables that depend on the parameters

Tool template

A template for a nwctool module.

Include the description and the help text here.

tool_template.create_parameter_layout() → List[List[Callable]]

Create a layout with the rows of the ‘Tool Parameters’ window.

tool_template.finish()

Restoring static state of global variables. This function is called after running tool.run

tool_template.init(score: nwc_classes.NwcFile, config: Dict[str, Dict[str, Any]])

Initialisation of the global variables. This function is called when the tool is selected.

tool_template.run() → Dict[str, Union[List[str], Dict[str, Union[List[str], Dict[str, List[Any]]]]]]

Do what has to be done.

Returns

A dictionary:

“Report”: a list of report lines.

“Summary”: a list of summary lines.

# “Output_filename”: a suggested filename when ‘saving as’

# “Edited”: True if there has been some editing of the score.

# “XLSX”: a dictionary that holds the data to save in a XLSX file.

Side effects
  • If ‘Edited’ is True, the score has been changed.

# …

tool_template.set_parameter_variables(values: Dict[str, Any]) → None

Sets the global variables that depend on the parameters