oggy22 / MusicTools

Various musical tools including music hearing, machine composer and Chomsky music analyzer.
4 stars 2 forks source link

Create DAG out of melody #24

Closed oggy22 closed 5 years ago

oggy22 commented 7 years ago

Given a melody, create a DAG which breaks the melody down, looking for similarities. If multiple DAGs are possible, take one with the fittest score based on a criteria. A criteria should be probably one of the following:

This may be a hard AI/NP problem.

p.s. DAG is representation of melody as Directed Acyclic graph such that nodes represent parts of the melody, and edges represent containment i.e. "this part is composed of these smaller parts". The root node represent the whole melody.

oggy22 commented 7 years ago

This problem is known as Smallest Grammar Problem in Chomsky grammars, and there are papers on its applications in music.

oggy22 commented 7 years ago

The input should be midi files with fugal-like works. Fugal like work is a composition where each track has no more than a single tone in a time.

oggy22 commented 7 years ago

The output should be a graphical layout of DAG with each node being a musical sheet snippet without clef. Each node will include stats as:

Each node will provide interface for modifications, so you can modify it and replay the composition.

You should be able to sort nodes based on:

oggy22 commented 7 years ago

The program should work nicely on Bach inventions, especially C major, D minor, F major, G major and A minor.

oggy22 commented 7 years ago

The program should be able to analyze multiple compositions in parallel, e.g. all the 15 inventions by Bach and therefore provide some insights, possibly, to entire corpus.

oggy22 commented 6 years ago

Here is code design:

interface IDuration { Fraction duration; }
class note : IDuration
{
}

class ChromaticPassage : IDuration, IEnumerable<note>
{
  List<IDuration> parts;
  duration => parts.Sum(part => part.duration);
  int offset;
}

class DiatonicPassage : IDuration
{
}
oggy22 commented 6 years ago

If there were only chromatic melodies:

interface IMelodyPart { Fraction duration; IEnumerable GetNotes(); }

class note : IMelodyPart { Fraction duration => duration; IEnumerable GetNotes() { if (pause) yield return this; else yield break; } ... }

class MelodyPartList : List { }

class ChromaticMelodyPart : IMelodyPart { Int offset; MelodyPartList list; IEnumerable GetNotes() { foreach mp in list foreach note in mp yield return note + offset; } }

oggy22 commented 6 years ago

To add diatonic: class DiatonicMelodyPart : IMelodyPart { int offset; TwevleToneSet scale; MelodyPartList list; }

oggy22 commented 6 years ago

More songs which should be analyzed nicely: Winter wonderlands Mozart 6th symphony 1st movement Albinoni adagio

oggy22 commented 5 years ago

This is mostly done by #29, and partly by #50, #63 etc, so I am closing it.

However, as of now, there are some missing parts as #36, #44 etc.