GithubHelp home page GithubHelp logo

Comments (21)

melanchall avatar melanchall commented on July 3, 2024

Hi Thomas,

Do you want to have method like ToMusicalName on Interaction.Chord or Parse one? At now you cannot get musical name neither for MusicTheory.Chord nor for Interaction.Chord. But it looks like useful feature. So I'll add it to my backlog. Thank you!

Max

from drywetmidi.

FischertBilligheim avatar FischertBilligheim commented on July 3, 2024

Hi Max,

Yes, this is the idea: With the chord-manager, I‘m getting all the chords - e.g. from a chunk. But I would like to show the „musical name“ of these chords in my GUI.
My proposal: Interaction.Chord.ToString() could do that....

Thanks to you, Max!
Regards
Thomas

from drywetmidi.

melanchall avatar melanchall commented on July 3, 2024

Thomas,

I'll implement the feature within this issue so please don't close it.

from drywetmidi.

FischertBilligheim avatar FischertBilligheim commented on July 3, 2024

👍👍

from drywetmidi.

melanchall avatar melanchall commented on July 3, 2024

Hi,

I've added method GetMusicTheoryChord for Interaction.Chord and GetChordDefinitions for MusicTheory.Chord. Last one is what you need.

GetChordDefinitions returns collection of "musical" definitions of a chord as instances of ChordDefinition class. Its ToString method returns musical name of the chord. Definitions are sorted by complexity so I suppose the first one is what you need.

For example, for chord A C E you'll get these definitions:

Am
Ab3
Adim#5
Aaugb3b5

Determining chord's definitions is pretty tricky. I don't use chords tables, the library tries to infer definitions algorithmically, so I sure there are errors and some chords may not be analyzed correctly (or analyzed at all). Please test the new API and if you'll notice issues, report me.

from drywetmidi.

FischertBilligheim avatar FischertBilligheim commented on July 3, 2024

Great, thanks a lot!! I will test it and give you response!!
Best regards
Thomas

from drywetmidi.

FischertBilligheim avatar FischertBilligheim commented on July 3, 2024

Hi Max,

in a first test, I used the following code:

        _IEnumerable<Melanchall.DryWetMidi.Interaction.Chord> chords = gActTrack.GetChords(20);
        foreach (Melanchall.DryWetMidi.Interaction.Chord chord in chords)
        {
                if (chord.Time + chord.Length > nt && chord.Time < mt)
                {
                    Melanchall.DryWetMidi.MusicTheory.Chord mChord   = chord.GetMusicTheoryChord();
                    IReadOnlyCollection<ChordDefinition> musicChords = mChord.GetChordDefinitions();

                    if (musicChords.Count > 0)
                        utils.DrawChord(chord.Time, musicChords.First().ToString(), Color.Red);
                }
        }_

I showed the result in my current implementation of my midi-editor/sequencer (red line on the top)

Chords

You see a chord-track of the song "Angel of Harlem from U2". The first chord has the notes "E,C,G,E,C" - I would expect, that this is the Chord "C-Maj", but not "C7#9#7"....

Another result:
I cannot call these new methods in my draw-routine - the redraw is far too slow now.....

from drywetmidi.

FischertBilligheim avatar FischertBilligheim commented on July 3, 2024

Hi Max,

additional hint:
If I'm using this code:

        _IEnumerable<Melanchall.DryWetMidi.Interaction.Chord> chords = gActTrack.GetChords(20);

        foreach (Melanchall.DryWetMidi.Interaction.Chord chord in chords)
        {
                if (chord.Time + chord.Length > nt && chord.Time < mt)
                {
                utils.DrawChord(chord.Time, chord.ToString(), Color.Red);_

this is the result:
image

And this works fast enough in the Paint-method......

from drywetmidi.

melanchall avatar melanchall commented on July 3, 2024

Hi Thomas,

Thanks for your tests. It seems it would be better to analyze chords by tables :)

But I have a couple of comments:

  • First chord is C E G C E. C chord is C E G. With addition of E and C on top of it still C chord?
  • chord.ToString() just prints notes of a chord so it's not a name of chord.

from drywetmidi.

FischertBilligheim avatar FischertBilligheim commented on July 3, 2024

Hi Max,

To be honest: I have not much knowledge about music theory. But I assume, that if there are duplicate notes in different octaves ( like in my sample) - these notes can be ignored.

I think a good reference is here:
http://www.sengpielaudio.com/ChordNameFinder.htm.

To the second comment:
Yes, sure - I’m aware of that. I only mentioned that to give you the info, that this is fast enough to call these functions in the paint/redraw method.

from drywetmidi.

melanchall avatar melanchall commented on July 3, 2024

Yes, I'm looking to the same article :)

Well, I'll try to rewrite my methods to use chords tables prior to current algorithm.

from drywetmidi.

FischertBilligheim avatar FischertBilligheim commented on July 3, 2024

Maybe that can help:

https://github.com/DrA1ex/GuitarHelper/blob/master/PianoKeyEmulator/Chords.cs

from drywetmidi.

FischertBilligheim avatar FischertBilligheim commented on July 3, 2024

I meanwhile tested the „PianoKeyEmulator“-Approach - it looks pretty good.
I‘m currently adapting the algorithm to the classes of drywetmidi.
If you are interested, I can - if I finished - send you the implementation, you can adapt it to your coding-style, and integrate it....

from drywetmidi.

melanchall avatar melanchall commented on July 3, 2024

Hi Thomas,

I've removed GetChordDefinitions method and added GetNames one. It returns list of names of the chord using chord table. At now the table is not complete but I'll add more records to it.

Also I asked my friend from symphony orchestra about duplicated notes in a chord. You're right, C E G C E is indeed C chord, it doesn't matter how many duplicated notes are on top of C E G triad.

Please test new API. I'm waiting for your feedback.

from drywetmidi.

melanchall avatar melanchall commented on July 3, 2024

Added more records to chords names table (CNT).

from drywetmidi.

FischertBilligheim avatar FischertBilligheim commented on July 3, 2024

Hi Max,

I did a first short test: It looks better, and I don't have Performance issues any more…

But furthermore a lot of chords are not recognized:
e.g: E,G,C:-> C-Maj
C A,F -> F-Maj
D#,G#,C -> G#

image

The mentioned "PianoKeyEmulator" has an interesting approach:
"Permutations" of the chords are generated and tested - maybe you can have a look to that:

It's the first result from me from today... it's a in-work version:

MidiChords.zip

from drywetmidi.

melanchall avatar melanchall commented on July 3, 2024

Thanks Thomas. Yes, these permutations are called chord inversions. I'll include them to the CNT lookup. But I think it will degrade performance. I'll test and let you know.

Thanks again.

from drywetmidi.

FischertBilligheim avatar FischertBilligheim commented on July 3, 2024

Thanks to you, Max!! 👍

from drywetmidi.

melanchall avatar melanchall commented on July 3, 2024

Added chords inversions to CNT lookup. @FischertBilligheim Please check out.

from drywetmidi.

FischertBilligheim avatar FischertBilligheim commented on July 3, 2024

Hi Max,

wow - the current implementation is really great!
Congratulations - how you realized that new functionality in that short time!!

Best regards
Thomas

from drywetmidi.

FischertBilligheim avatar FischertBilligheim commented on July 3, 2024

image

from drywetmidi.

Related Issues (20)

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.