"""
Module: cli.menu_entries.py
===========================
This module provides functionalities to construct the entries for various menus used within the command-line interface (CLI) of the Interactive Music Analysis Tool (I-MaT).
This module is responsible for constructing the menu entries for different sections of the command line interface (CLI)
of the Interactive Music Analysis Tool (I-MaT). The menus are used to navigate through the CLI, and the functions
in this module return the entries for each menu in a structured format.
Functions
---------
- `mainmenu_environment_settings_entries`: Returns the menu entries for the main environment settings menu.
- `mainmenu_single_musical_piece_entries`: Returns the menu entries for the single musical piece menu.
- `mainmenu_tokenization_entries`: Returns the menu entries for the tokenization menu.
- `start_menu_entries`: Returns the menu entries for the start menu.
- `submenu_single_musical_piece_basic_functions_entries`: Returns the menu entries for the basic functions submenu.
- `submenu_single_musical_piece_pattern_search_entries`: Returns the menu entries for the pattern search submenu.
- `submenu_single_musical_piece_statistical_analysis_page1_entries`: Returns the menu entries for the first page of the statistical analysis submenu.
- `submenu_single_musical_piece_statistical_analysis_page2_entries`: Returns the menu entries for the second page of the statistical analysis submenu.
- `submenu_single_musical_piece_visualizations_entries`: Returns the menu entries for the visualizations submenu.
- `submenu_tokenization_calculations_entries`: Returns the menu entries for the calculations submenu in tokenization.
- `submenu_tokenization_refine_data_entries`: Returns the menu entries for the refine data submenu in tokenization.
Each function returns a dictionary representing the menu entries for a specific menu. The dictionary includes the
menu text to be displayed, the function to be executed when the menu entry is selected, and other relevant information.
These functions allow for easy modification of the menu structure and contents, providing flexibility in the design
and functionality of the CLI. The module aids in ensuring that the command-line interface remains user-friendly
and intuitive, providing clear navigation and straightforward access to the tool's functionalities.
"""
from iMaT.src.analysis.functions import analysis_advanced_calculate_activity_rate, \
analysis_advanced_compare_pitches_and_pitch_classes_per_duration, analysis_ambitus, \
analysis_number_of_intervals_per_type, analysis_number_of_intervals_per_type_with_direction, \
analysis_number_of_notes, analysis_number_of_pitch_classes_per_metrical_position, \
analysis_number_of_pitch_classes_per_offset, analysis_number_of_pitch_classes_per_tone_duration, \
analysis_number_of_pitches_per_metrical_position, analysis_number_of_pitches_per_offset, \
analysis_number_of_pitches_per_tone_duration, analysis_number_of_rests, analysis_number_of_rests_per_rest_duration, \
analysis_number_of_sound_events_per_metrical_position, analysis_number_of_sound_events_per_pitch, \
analysis_number_of_sound_events_per_pitch_class, analysis_number_of_sound_events_per_tone_duration
from iMaT.src.analysis.main import analysis_workflow_single_musical_piece
from iMaT.src.conversion.main import convert_multiple_files_filetype
from iMaT.src.m21_environment.main import display_environment_file, set_user_preferences
from iMaT.src.pattern_search.functions import pattern_search_only_rhythm, \
pattern_search_with_transposition_with_rhythm, \
pattern_search_with_transposition_without_rhythm, \
pattern_search_without_transposition_with_rhythm, pattern_search_without_transposition_without_rhythm
from iMaT.src.pattern_search.main import pattern_search_workflow_single_musical_piece
from iMaT.src.visualizations.main import generic_display_workflow
from iMaT.src.score_selection.main import score_selection
from iMaT.src.tokenization.main import tokenization_tokenize_folder_midi_files
from iMaT.src.tokenization.refine_results.absolute_duration import \
corpus_tokenization_refine_data_absolute_duration
from iMaT.src.tokenization.refine_results.calculate_pitch_intervals import \
tokenization_calculate_pitch_intervals
from iMaT.src.tokenization.refine_results.remove_prefixes import \
corpus_tokenization_refine_data_remove_prefixes
from iMaT.src.tokenization.refine_results.tokens_to_txt import tokenization_export_csv_columns_to_txt_file
from iMaT.src.utils.misc import change_part_names, show_metadata, show_part_names
from iMaT.src.visualizations.m21_integrated import play_midi_score, show_chord_connections, show_chord_scale_system, \
show_figured_bass, show_key_analysis, show_musescore, show_pianoroll, show_voice_progression, show_volume_change
[docs]def mainmenu_single_musical_piece_entries():
"""
Menu dedicated to operations and analyses related to a single piece of music.
Level: First Child (Parent: start_menu_entries)
This function defines the second level menu that is specific to
analyzing a single piece of music. It provides options to access
basic functions, statistical analysis tools, visualization tools,
and pattern search tools.
"""
return {
"menu_displayed_text": [
"LOCATION: Start Menu >> Main Menu: Individual Piece",
"Please make a selection from the options below by entering the entry index number:",
"Which menu item should be executed? (<No. of menu item>): ",
["Menu item", "<Explanation>"],
],
"menu_entries": [
["FILE: Access Basic Functions", submenu_single_musical_piece_basic_functions_entries, "<Access basic functions such as file selection, display metadata, etc.>"],
["TOOL: Statistical Analysis Tools", submenu_single_musical_piece_statistical_analysis_page1_entries, "<Choose from various statistical analysis tools>"],
["TOOL: Visualization Tools", submenu_single_musical_piece_visualizations_entries, "<Choose from different visualization tools>"],
["TOOL: Pattern Search Tools", submenu_single_musical_piece_pattern_search_entries, "<Choose from different tools for pattern search>"],
["BACK: Return to Previous Menu", 'back', "<Go back to the previous menu."],
]
}
[docs]def mainmenu_tokenization_entries():
"""
Main menu for operations related to music tokenization.
Level: First Child (Parent: start_menu_entries)
This function defines the second level menu for tokenization
operations. It provides options to tokenize a folder of midi files,
refine tokenization results, perform calculations on tokens, and
extract token data to a TXT file.
"""
return {
"menu_displayed_text": [
"LOCATION: Start Menu >> Main Menu: Tokenization",
"Please make a selection from the options below by entering the entry index number:",
"Which menu item should be executed? (<No. of menu item>): ",
["Menu item", "<Explanation>"],
],
"menu_entries": [
["TOKN: Tokenize a folder of midi files", tokenization_tokenize_folder_midi_files, "<Tokenize sheet music using the midiTok library>"],
["RFNE: Refine tokenization results", submenu_tokenization_refine_data_entries, "<Prepare tokenization data (CSV) for further processing>"],
["CALC: Add columns by performing calculations", submenu_tokenization_calculations_entries, "<Perform calculations on existing data and safe those in new columns>"],
["EXTR: Extract Columns to TXT", tokenization_export_csv_columns_to_txt_file, "<Extract specified columns from the dataset and save to a TXT file>"],
["BACK: Return to the last menu", 'back', "<Returns to the parent menu>"],
],
}
[docs]def mainmenu_environment_settings_entries():
"""
Menu for managing software paths and user preferences.
Level: First Child (Parent: start_menu_entries)
This function defines the second level menu for updating software
paths and preferences. It provides options to display the
environment file and to update paths and preferences.
"""
return {
"menu_displayed_text": [
"LOCATION: Start Menu >> Main Menu: Update Software Paths and Preferences",
"Please make a selection from the options below by entering the entry index number:",
"Which menu item should be executed? (<No. of menu item>): ",
["Menu item", "<Explanation>"],
],
"menu_entries": [
["ENVT: Display Environment File", display_environment_file, "<Display the content of the current music21 environment file>"],
["CONF: Update Paths & Preferences", set_user_preferences, "<Update or redefine the paths to essential software and set user preferences>"],
["BACK: Return to Previous Menu", 'back', "<Return to the parent menu without making any changes>"],
]
}