Giter Club home page Giter Club logo

musicowl's Introduction

Build Status Maven Central License: MIT Contribute: Gitpod

Music Score to RDF Converter

This converter parses MusicXML 3.0 files and converts them to RDF, based on the MusicOWL Ontology [ˈmjuːzɪkəl]. It fully supports the following concepts:

  • Articulations
  • Clefs
  • Durations
  • Dynamics
  • Measures (Bars)
  • Note Sets
  • Notes
  • Staves
  • Tonalities
  • Voices

Parameters

setInputFile  MusicXML 3.0 file to be converted. Supported are .xml and .mxl files.

setOutputFile  Path and name for RDF output file.

setThumbnail  Thumbnail for the converted music score (optional).

setScoreIdentifier  URI for the converted score (optional) .

setScoreTitle  Music score title.

issued  Date issued. Formats accepted: yyyy, yyyyMM, yyyyMMdd (optional).

setCollection  Collections can be used for classifying music scores into certaing groups, e.g. "18th Century Composers", "Advanced Music Scores", etc.

isVerbose  Setting it to true logs in the console the converter progress.

setOutputFormat  Sets the RDF notation for the output file. Accepted notations are: TURLTE, NTRIPLES, JSON-LD, RDF/XML, RDF/JSON.

addPerson  This method can be used to add persons related to the music score. It consists of an URI, a name and a role, which can have one of the following attributes:

Role.ARRANGER;
Role.COMPOSER;
Role.EDITOR;
Role.ENCODER;
Role.LIBRETTIST;
Role.LYRICIST;
Role.PERFORMER;
Role.TRANSLATOR;
Role.UNKNOWN;

addResource  Links existing resources to the converted music score, such as pdf or mp3 files. This method relies on three parameters:

  • Link: Link to the resource
  • Description: Text describing the resource
  • Type: MIME Type

Music2RDF at Maven Central

To add the Music Score to RDF Converter to your project just add the following dependency in your pom.xml file:

<dependency>
  <groupId>de.uni-muenster</groupId>
  <artifactId>music2rdf</artifactId>
  <version>[VERSION]</version>
</dependency>

Using the Java API

The above mentioned parameters can be used as follows:

package de.wwu.music2rdf.example;

import java.io.File;

import com.google.common.net.MediaType;

import de.wwu.music2rdf.converter.MusicXML2RDF;
import de.wwu.music2rdf.core.Collection;
import de.wwu.music2rdf.core.Person;
import de.wwu.music2rdf.core.Role;
import de.wwu.music2rdf.core.ScoreResource;

public class Example {

  public static void main(String[] args) {
				
    MusicXML2RDF music2rdf = new MusicXML2RDF();
			
    music2rdf.setInputFile(new File("musicxml/ulb-muenster/elgar_cello_concerto_op.85.xml"));
    music2rdf.setOutputFile("rdf/elgar_cello_concerto_op.85");
    music2rdf.setThumbnail("https://upload.wikimedia.org/wikipedia/commons/thumb/3/37/Elgar-cello-concerto-manuscript.jpg/220px-Elgar-cello-concerto-manuscript.jpg");
    music2rdf.setScoreIdentifier("http://dbpedia.org/resource/Cello_Concerto_(Elgar)");
    music2rdf.addCollection(new Collection("https://wwu.greatcomposers.de","Great Composers"));
    music2rdf.addCollection(new Collection("https://sammlungen.ulb.uni-muenster.de","Digitale Sammlung der Universität und Landesbibliothek Münster"));
    music2rdf.addPerson(new Person("http://dbpedia.org/resource/Edward_Elgar","Sir Edward William Elgar",Role.COMPOSER));
    music2rdf.addPerson(new Person("http://jimjones.de","Jim Jones",Role.ENCODER));
    music2rdf.addResource(new ScoreResource("https://musescore.com/score/152011/download/pdf", "Print",MediaType.PDF.toString()));
    music2rdf.addResource(new ScoreResource("https://en.wikipedia.org/wiki/Cello_Concerto_(Elgar)", "Wikipedia Article",MediaType.HTML_UTF_8.toString()));
    music2rdf.setScoreTitle("Cellokonzert e-Moll op. 85");
    music2rdf.isVerbose(false);
    music2rdf.setOutputFormat("turtle");
    music2rdf.setDateIssued("1919"); //Formats accepted: yyyy, yyyyMM, yyyyMMdd.    	
		
    music2rdf.parseMusicXML();		
  }
}

Using the converter in the console

If you don't feel like building the Musci2RDF converter from source, visit the releases area to get a prebuilt jar. You can use this jar with following parameters:

metadata  In order to keep the full metadata support via console, you have to pass the metadata in separated file. This metadata file can be encoded in XML ...

<?xml version="1.0" encoding="UTF-8"?>
<score>
	<scoreIdentifier>http://dbpedia.org/resource/Cello_Concerto_(Elgar)</scoreIdentifier>
	<scoreTitle>Cellokonzert e-Moll op. 85</scoreTitle>
	<thumbnail>https://www.rcm.ac.uk/media/Elgar%20Cello%20Concerto%20maunscript%206x4.jpg</thumbnail>
	<issued>1919</issued>
	<collections>
		<collection>
			<collectionLabel>Great Composers</collectionLabel>
			<collectionIdentifier>https://wwu.greatcomposers.de</collectionIdentifier>
		</collection>
	</collections>
	<persons>
		<person>
			<personIdentifier>http://dbpedia.org/resource/Edward_Elgar</personIdentifier>
			<personName>Sir Edward William Elgar</personName>
			<personRole>Composer</personRole>
		</person>
		<person>
			<personIdentifier>http://jimjones.de</personIdentifier>
			<personName>Jim Jones</personName>
			<personRole>Encoder</personRole>
		</person>
	</persons>
	<resources>
		<resource>
			<resourceURL>https://musescore.com/score/152011/download/pdf</resourceURL>
			<resourceLabel>Print</resourceLabel>
			<resourceType>application/pdf</resourceType>
		</resource>
		<resource>
			<resourceURL>https://en.wikipedia.org/wiki/Cello_Concerto_(Elgar)</resourceURL>
			<resourceLabel>Wikipedia Article</resourceLabel>
			<resourceType>text/html</resourceType>
		</resource>
	</resources>
</score>

.. or in case you fancy JSON:

{
   "scoreIdentifier": "http://dbpedia.org/resource/Cello_Concerto_(Elgar)",
   "scoreTitle": "Cellokonzert e-Moll op. 85",
   "thumbnail": "https://www.rcm.ac.uk/media/Elgar%20Cello%20Concerto%20maunscript%206x4.jpg",
   "issued": "1919",
   "collections": [       
      {
         "collectionLabel": "Great Composers",
         "collectionIdentifier": "https://wwu.greatcomposers.de"
      }
   ],
   "persons": [
      {
         "personIdentifier": "http://dbpedia.org/resource/Edward_Elgar",
         "personName": "Sir Edward William Elgar",
         "personRole": "Composer"
      },
      {
         "personIdentifier": "http://jimjones.de",
         "personName": "Jim Jones",
         "personRole": "Encoder"
      }
   ],
   "resources": [
      {
         "resourceURL": "https://musescore.com/score/152011/download/pdf",
         "resourceLabel": "Print",
         "resourceType": "application/pdf"
      },
      {
         "resourceURL": "https://en.wikipedia.org/wiki/Cello_Concerto_(Elgar)",
         "resourceLabel": "Wikipedia Article",
         "resourceType": "text/html"
      }
   ]
}

Further parameters are:

file   Music score file.

output  Name for the output file.

outputFormat  RDF notation for the output file

Example (using the above described metadata file):

$ java -jar music2rdf-[VERSION].jar file=musicxml/metadata-file/elgar_cello_concerto_op.85.xml
metadata=musicxml/elgar_cello_concerto_op.85-metadata.xml 
output=rdf/elgar_cello_concerto_op.85 
outputFormat=turtle

File  	        : musicxml/elgar_cello_concerto_op.85.xml
Score URI       : http://dbpedia.org/resource/Cello_Concerto_(Elgar)
Title           : Cellokonzert e-Moll op. 85
Date Issued     : 1919
Thumbnail       : https://www.rcm.ac.uk/media/Elgar%20Cello%20Concerto%20maunscript%206x4.jpg
Person URI      : http://dbpedia.org/resource/Edward_Elgar
Person Name     : Sir Edward William Elgar
Person Role     : Composer
Person URI      : http://jimjones.de
Person Name     : Jim Jones
Person Role     : Encoder
Resource URI    : https://musescore.com/score/152011/download/pdf
Resource Desc.  : Print
Resource Type   : application/pdf
Resource URI    : https://en.wikipedia.org/wiki/Cello_Concerto_(Elgar)
Resource Desc.  : Wikipedia Article
Resource Type   : text/html
Collection URI  : https://wwu.greatcomposers.de
Collection Name : Great Composers
Output File     : rdf/elgar_cello_concerto_op.85
OutputFormat    : turtle

[2019-08-11 19:33:14,788] INFO  [Converter] - Processing elgar_cello_concerto_op.85.xml ...
[2019-08-11 19:33:15,011] INFO  [Converter] - Loading XML file: 222 ms
[2019-08-11 19:33:15,341] WARN  [Converter] - The title "Cellokonzert e-Moll op. 85" was provided and will therefore overwrite the title provided in the MusicXML document.
[2019-08-11 19:33:15,341] INFO  [Converter] - Creating MusicScore object: 329 ms
[2019-08-11 19:33:16,224] INFO  [Converter] - Score serialization: 883 ms

musicowl's People

Contributors

jimjonesbr avatar dependabot[bot] avatar diegosiqueir4 avatar

Stargazers

Christian Fernandez Perotti avatar Niels Pfeffer avatar  avatar

Watchers

 avatar Fabian C. Moss avatar Stefan Münnich avatar

musicowl's Issues

chord:modifier missing when note tied to preceding note

Thanks for this great converter (and the ontology)!

I think there is an issue with chord:modifier on notes that are tied to preceding notes:

This is a simple example:

Ties_Example

Converting a corresponding XML file to MusicOWL, the pitches of the six notes are converted as follows (missing parts added as ##comments):

node:a2da4aed-f485-42df-9278-24cf5cfb34f5_MOV1_P1_M1_NS_1_NOTE_0
        a               chord:Note ;
        mso:hasOctave   "4"^^xsd:int ;
        chord:modifier  chord:sharp ;
        chord:natural   note:F .

node:a2da4aed-f485-42df-9278-24cf5cfb34f5_MOV1_P1_M2_NS_2_NOTE_0 
        a              chord:Note ;
        mso:hasOctave  "4"^^xsd:int ;
**##missing: chord:modifier	chord:sharp ;**
	chord:natural  note:F . 


node:a2da4aed-f485-42df-9278-24cf5cfb34f5_MOV1_P1_M2_NS_3_NOTE_1
        a              chord:Note ;
        mso:hasOctave  "4"^^xsd:int ;
        chord:natural  note:F .

node:a2da4aed-f485-42df-9278-24cf5cfb34f5_MOV1_P1_M3_NS_4_NOTE_0
        a              chord:Note ;
        mso:hasOctave  "4"^^xsd:int ;
        chord:natural  note:F .

node:a2da4aed-f485-42df-9278-24cf5cfb34f5_MOV1_P1_M3_NS_5_NOTE_1
        a               chord:Note ;
        mso:hasOctave   "4"^^xsd:int ;
        chord:modifier  chord:flat ;
        chord:natural   note:F .

node:a2da4aed-f485-42df-9278-24cf5cfb34f5_MOV1_P1_M4_NS_6_NOTE_0
        a              chord:Note ;
        mso:hasOctave  "4"^^xsd:int ;
**##missing: chord:modifier  chord:flat ;**
        chord:natural  note:F .

If one queries the turtle file with SPARQL, the first note of ms. 2 will not be among the expected results when searching for F sharp. Likewise, the first note of ms. 5 will not be among the expected results when searching for F flat.

Here is the corresponding MusicXML for the first two notes ( F sharp):

...NS_1_NOTE_0:

<note default-x="83">
        <pitch>
          <step>F</step>
          <alter>1</alter>
          <octave>4</octave>
        </pitch>
        <duration>4</duration>
        <tie type="start"/>
        <voice>1</voice>
        <type>half</type>
        <accidental>sharp</accidental>
        <stem default-y="0">up</stem>
        <notations>
          <tied type="start"/>
        </notations>
      </note>

...NS_2_NOTE_0:

<note default-x="13">
        <pitch>
          <step>F</step>
          <alter>1</alter>
          <octave>4</octave>
        </pitch>
        <duration>2</duration>
        <tie type="stop"/>
        <voice>1</voice>
        <type>quarter</type>
        <stem default-y="0">up</stem>
        <notations>
          <tied type="stop"/>
        </notations>
      </note>

Just a guess (I don't understand the Java code well enough, sorry): the converter looks for the <accidental> element when deciding whether to place chord:modifier or not? Instead of looking for the values of <alter>?

MusicXML to MEI conversion

Create feature to add the converted MusicXML string to MEI in the RDF file using the predicate mso:asMEI. This should be triggered based on a boolean method in the MusicXML2RDF class addMEILiteral(boolean)

log4j problem

File : musicxml/metadata-file/elgar_cello_concerto_op.85.xml

log4j:WARN No appenders could be found for logger (Converter).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
java.io.FileNotFoundException:
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(Unknown Source)
at java.io.FileOutputStream.(Unknown Source)
at java.io.FileOutputStream.(Unknown Source)
at de.wwu.music2rdf.converter.MusicXML2RDF.createRDF(MusicXML2RDF.java:1358)
at de.wwu.music2rdf.converter.MusicXML2RDF.parseMusicXML(MusicXML2RDF.java:1486)
at de.wwu.music2rdf.converter.Converter.main(Converter.java:62)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.