Comments (5)
Generally, Music21Objects should not hash to each other and in fact we're removing the simple == comparison from those that have them. The two ChordSymbols may have different placement in a score so they wouldn't hash to be the same. You can override the hash function if you'd like in your own work.
from music21.
I understand your point and hope you understand that devoid of context as in the example above, a ChordSymbol should hash equally.
Thank you.
from music21.
If you want to hash equally just hash the string "C7" and use a lookup table to map that to an object. If you set a hash function for a Music21Object so that multiple objects hash equally you will find that there are major problems. They are not equal in any real sense except that they happen to point to the same notes.
from music21.
It's also pretty easy to "monkey patch" a Python object with a custom equality function by overriding the __eq__
method on an object:
In [1]: class Chord(object):
...: pass
...:
In [2]: x = Chord()
In [3]: y = Chord()
In [4]: x == y
Out[4]: False
In [5]: def __eq__(self, other):
...: return True
...:
In [6]: Chord.__eq__ = __eq__
In [7]: x == y
Out[7]: True
In this case, the two objects will always be equal since my custom equality object always returns True
. If you want to just compare pitches in a Chord you can define the parameters for equality and it will work as you expect.
I think Myke's right on this one, though -- just because two chords share the same pitch content doesn't make them the same.
from music21.
Consider computing pitch transition probabilities, or any ingredient your prefer, given chord.
from music21.
Related Issues (20)
- In ABC notation, inline notation of key and time signature changes in the middle of a song using [] does not convert correctly to MusicXML.
- Diminuendo doesn't span all elements that are part of it HOT 2
- Chord symbol "Co omit5" does not parse
- Chatgpt--Music21 HOT 1
- simplifyMultipleEnharmonics gives different spellings in different octaves
- MusicXML import of scores which include drumset parts loses most of instrument information HOT 1
- Chord clarifciation HOT 2
- Issues with install the music21 library in kaggle notebook HOT 1
- Missing humdrumPosition in thisSpine.stream.flatten() with root cause analysis HOT 1
- Measure.rightBarline not being correctly set when appending bar.Repeat HOT 1
- Incorrect Key Signature Parsing in MEI Files
- can't run tests because of lilypond import issue HOT 1
- tinyNotation --> tiny doc clarification ;)
- Voices changing staffs
- Tiny doc clarification HOT 3
- Allow objects to be in multiple sites
- expandRepeats don't work as expected HOT 1
- Loading `MusicXML` file produces error
- Extra rest inserted when parsing MusicXML with backup/forward tags
- MusicXML writer: Ottavas that start or end in the middle of a multi-voice measure get the wrong notes from the other voices HOT 7
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 music21.