Comments (21)
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.
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.
Thomas,
I'll implement the feature within this issue so please don't close it.
from drywetmidi.
👍👍
from drywetmidi.
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.
Great, thanks a lot!! I will test it and give you response!!
Best regards
Thomas
from drywetmidi.
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)
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.
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);_
And this works fast enough in the Paint-method......
from drywetmidi.
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 isC E G
. With addition ofE
andC
on top of it stillC
chord? chord.ToString()
just prints notes of a chord so it's not a name of chord.
from drywetmidi.
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.
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.
Maybe that can help:
https://github.com/DrA1ex/GuitarHelper/blob/master/PianoKeyEmulator/Chords.cs
from drywetmidi.
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.
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.
Added more records to chords names table (CNT).
from drywetmidi.
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#
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:
from drywetmidi.
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.
Thanks to you, Max!! 👍
from drywetmidi.
Added chords inversions to CNT lookup. @FischertBilligheim Please check out.
from drywetmidi.
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.
from drywetmidi.
Related Issues (20)
- HELP !!! Notes in panel to midi file?? HOT 9
- please help a noob HOT 6
- Remove all notes example from the README not working HOT 9
- Using wetdrymidi in C# project causes error CS0009
- InputDevice event listening crash HOT 2
- Crash when running in Unity on M2 MacBook HOT 3
- MidiDeviceException Internal error HOT 9
- Android Support
- Unity cannot exit after use HOT 10
- MidiClock sync problem HOT 6
- MIDI Tempo changes count returns 1 but the song has 6 tempo changes. HOT 1
- add il2cpp mode HOT 5
- CustomChunk no mididata throw error HOT 4
- CSharp Code Error HOT 2
- MIDI File returns error: InvalidMetaEventParameterValueException HOT 1
- Unable to send Note-On event to device HOT 8
- Cannot get track name to change HOT 10
- How to use DryWetMidi in Visual Basic (VS 2022) ? HOT 20
- Plans for MIDI 2.0 Support? HOT 2
- Skipping notes HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from drywetmidi.