Skip to content

Commit

Permalink
delete jsymbollic module
Browse files Browse the repository at this point in the history
  • Loading branch information
martianbug committed Dec 11, 2023
1 parent fc58f86 commit c7077b8
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 298 deletions.
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@ To install the latest version of musif, just run
`pip install musif`
which will download musif and all its necessary dependencies.

## jSymbolic and music21 features
Currently, musif is able to process and integrate jsymbolic as well as basic music21 features. If jsymbolic features are selected, Java JRE >= 8 must be installed in your OS and the `JAVA_HOME` environment variable is correctly set (Download Java Development Kit: https://www.oracle.com/es/java/technologies/downloads/). `jSymbolic` will be downloaded automatically at the first run. You can force the download of `jSymbolic` and the check of Java installation by running `python -m musif.extract.features.jsymbolic`.
## music21 and jsymbollic features
Currently, musif is able to process and integrate basic music21 features.
For jsymbollic features, musif currently does not support the integration of these features, but a tutorial will be provided to manually merge them into musif's dataframe.
# jsymbollic installation
Java JRE >= 8 must be installed in your OS. Download Java Development Kit: https://www.oracle.com/es/java/technologies/downloads/

*Important*: right now music21 and jSymbolic features are NOT guaranteed to be compatible with musif's cache system, unlike some music21 stock features.
*Important*: right now music21 features are NOT guaranteed to be compatible with musif's cache system. Native musif's features work with cache system just fine.

In case of problems when installing Java or getting it to work as a command, these sites might be helpful:
https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/How-do-I-install-Java-on-Ubuntu
https://www.wikihow.com/Set-Java-Home

## Testing and features extraction
Apart from the documentation of musif, where Tutorials and example code can be found, please feel free to clone and check this repository, where musif is used to extract features from different corpuses
https://github.com/DIDONEproject/music_symbolic_features
Expand Down
13 changes: 0 additions & 13 deletions config_extraction_example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,6 @@ feature_modules_addresses: ["musif.extract.features"]
# See `Caching` page for more info
precache_hooks: []

# Maximum RAM allowed to the Java Virtual Machine for each file (if using parallel,
# this parameter is multiplied for the number of processes)
jsymbolic_max_ram: "4g"

# Path to file containing jsymbolic configuration; if None (default) the default
# jSymbolic configuration is used
jsymbolic_config_file: null

# jsymbolic needs conversion to MIDI and this is not feasible if repeat marks are
# not properly set up in the input file; when this option is true, if exporting to MIDI fails, we retry after having removed all the repeat signs
# If this option is true, the caching system should not be used.
jsymbolic_try_without_repeats: false

# remove notes and objects referred to percussion instruments
# (musif stock features do not work with percussion instruments)
remove_unpitched_objects: true
Expand Down
1 change: 0 additions & 1 deletion docs/source/Feature_definition.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ musif.extract.features.jsymbolic`.
| **Column RegEx** | **Explanation** | Stock module |
|------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|
| `m21_.*` | Music21 features; only native features if `jsymbolic` is also included | `music21` |
| `js_.*` | jSymbolic features; need Java installed | `jsymbolic` |
| `FileName` | File name of the original score | `core` |
| `Measures` | No. of measures of the piece | `core` |
| `.+_SoundingMeasures` | No. of measures that have at least one note (not all silence) for a given part | `core` |
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Search <search>
```
`musif` is a Python module for computing features from music scores. It has been designed and extensively used by the [Didone](https://didone.eu) team for analyzing arias from 18th-century Italian operas on texts by Pietro Metastasio.

It also includes tools for extracting features using [`music21`](http://web.mit.edu/music21/) and [`jSymbolic`](https://jmir.sourceforge.net/jSymbolic.html). For this, see the [Feature Definition](Feature_definition.html) page.
It also includes tools for extracting features using [`music21`](http://web.mit.edu/music21/). For this, see the [Feature Definition](Feature_definition.html) page.

Please, see the [Tutorial](Tutorial.html) for an easy introduction.

Expand Down
8 changes: 0 additions & 8 deletions musif/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
PRECACHE_HOOKS = "precache_hooks"
REMOVE_UNPITCHED_OBJECTS = "remove_unpitched_objects"
MSCORE_EXEC = "mscore_exec"
JSYMBOLIC_CONFIG_FILE = "jsymbolic_config_file"
JSYMBOLIC_MAX_RAM = "jsymbolic_max_ram"
JSYMBOLIC_TRY_WITHOUT_REPEATS = "jsymbolic_try_without_repeats"
JSYMBOLIC_REMOVE_REPEATS = "jsymbolic_remove_repeats"
SPLIT_KEYWORDS = "split_keywords"

DELETE_FILES = "delete_failed_files"
Expand Down Expand Up @@ -75,10 +71,6 @@
MSCORE_EXEC: None,
DFS_DIR: None,
REMOVE_UNPITCHED_OBJECTS: True,
JSYMBOLIC_MAX_RAM: "4g",
JSYMBOLIC_CONFIG_FILE: None,
JSYMBOLIC_TRY_WITHOUT_REPEATS: False,
JSYMBOLIC_REMOVE_REPEATS: False
}

_CONFIG_POST_FALLBACK = {
Expand Down
9 changes: 2 additions & 7 deletions musif/extract/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,18 +240,13 @@ def __init__(self, *args, **kwargs):
self.exclude_files = kwargs.get("exclude_files") or getattr(
self._cfg, "exclude_files", None
)
if any(i in self._cfg.features for i in ("jsymbolic","music21")) and self._cfg.cache_dir:
pwarn("\nEither music21 or jsymbolic features were requested. musif's caching system is not compatible with these, so cache will be disabled! \n")
if any(i in self._cfg.features for i in ("music21")) and self._cfg.cache_dir:
pwarn("\nmusic21's features were requested. musif's caching system is not compatible with these, so cache will be disabled. \n")
self._cfg.cache_dir = None

if self._cfg.cache_dir is not None:
pinfo("Cache activated!")
Path(self._cfg.cache_dir).mkdir(exist_ok=True)
if "jsymbolic" in self._cfg.features:
from musif.extract.features import jsymbolic

jsymbolic.utils.download_jsymbolic()
jsymbolic.utils.get_java_path()

def extract(self) -> DataFrame:
"""
Expand Down
1 change: 0 additions & 1 deletion musif/extract/features/jsymbolic/__init__.py

This file was deleted.

9 changes: 0 additions & 9 deletions musif/extract/features/jsymbolic/__main__.py

This file was deleted.

132 changes: 0 additions & 132 deletions musif/extract/features/jsymbolic/handler.py

This file was deleted.

113 changes: 0 additions & 113 deletions musif/extract/features/jsymbolic/utils.py

This file was deleted.

9 changes: 3 additions & 6 deletions musif/extract/features/music21/handler.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import List

import music21 as m21
from music21.features import jSymbolic, native
from music21.features import native
from music21.features.base import extractorsById

from musif import cache
Expand All @@ -12,7 +12,7 @@
from .constants import ERRORED_FEATURES_IDS


def allFeaturesAsList(cfg, streamInput, include_jSymbolic_from_m21=True):
def allFeaturesAsList(cfg, streamInput):
"""
only a little change around m21.features.base.allFeaturesAsList: no Parallel
processing
Expand All @@ -21,8 +21,6 @@ def allFeaturesAsList(cfg, streamInput, include_jSymbolic_from_m21=True):
ds = m21.features.base.DataSet(classLabel="")
ds.runParallel = False # this is the only difference with the m21 original code
all_features = list(native.featureExtractors)
if include_jSymbolic_from_m21:
all_features += list(jSymbolic.featureExtractors)
if cfg.cache_dir:
pwarn('\nCache is activated! Some music21 features will NOT be computed.')
final_features = [feature for feature in all_features if feature.id not in
Expand All @@ -49,8 +47,7 @@ def update_score_objects(
# Override the isinstance and hasattr definitions for the caching system
m21.features.base.isinstance = cache.isinstance
m21.features.base.hasattr = cache.hasattr
include_jSymbolic_from_m21 = 'jsymbolic' not in cfg.features
features, columns = allFeaturesAsList(cfg, score, include_jSymbolic_from_m21=include_jSymbolic_from_m21)
features, columns = allFeaturesAsList(cfg, score)
score_features.update(
{
'm21_' + columns[outer] + f"_{i}": f
Expand Down

0 comments on commit c7077b8

Please sign in to comment.