You’ve prototyped a DSL for music notation, which is invariably fun but also very specific.
Either way, for your code to integrate into the SC ecosystem, you must develop an OOP design for the elements (pitches, accidents, durations, tuplets, ties, dynamics, etc.). Perhaps the most logical step would be to think of a quark that exactly mirrors the elements of musicXML. No need to build a complex system at this point. Keep it simple there.
Then, in a separate quark, you implement your DSL, that will combine all these objects.
You already made a proof-of-concept, it works. Well done!
I found your stuff on rhythms quite exciting. It seems that this relationship between duration and traditional notation (tree) is a very slippery arithmetic. Not every rational number can be expressed as a duration; at the same time that of the rational numbers accepted by this arithmetic, some correspond to only one duration, while others can have 2, 3, or 4 different durations. Verifying this with QuickCheck tests (durationToRq . rqToDuration :: Duration → [Duration] ) was curious:
Strangely, some notation systems (such as GUIDO) only accept the Rq values, and it does not seem correct that it is possible to generalize an inference. Therefore, these systems will fail in less simple cases. (Correct me if I’m wrong.) As far as I understand, both representations are complementary.
I want to delve deeper if you have more references on this. I also see you have a lot of exciting stuff there, from Barlow to Larry Polansky and many others. I didn’t have time to check it out yet.
My programming skills are not professional. I cannot always be responsible. The first step in publishing should be to use Quarks, unless some people in the development department check and repackage my code.
While developing my idea, I also think transposition. For example,
\a4 + \p5 // midi pitch number + perfect fifth
returns:
e5
With OOP design, it would be as follows:
A4.() + P5.() // midi pitch number + perfect fifth
returns:
A5
Yes, I also think it! This is why I proposed the following classes (I changed the name as Notator):
However, there are some problems here:
Rest is already a subclass of Operand. So, I think the Note class and its subclasses should exist as the subclasses of Operand.
Then, SPN and PitchClass by @josh should also be under Operand?
The notation of such musical information using OOP design seems to lose readability… The code seems to be very complicated.
The code snippet you’ve shared doesn’t seem to follow a typical object-oriented design as in sc. In this kind of operation you posted, you’d have separate Pitch and Interval classes and functions defined between them. If you define classes for pitches and intervals, their interactions can be considered vector space arithmetic — or, more simply, “affine space”. For instance, you could subtract one pitch from another to derive an interval or add an interval to a pitch to determine a new pitch (as demonstrated in your example).
I imagine A4.() + P5.() are just pitch literals operating with interval literals, but even then, it’s not a very convenient literal.
How you will implement this can be a separate code from the code to create musicxml. This way, it will be more modular and more helpful to others. For example, I don’t see the need for an interval class in the musicxml quark.
My PitchClassSet class is independent of @josh’s PitchClass class.
Any comments are welcome, but we should discuss the subject on the thread which @semiquver made. That thread does not include musicXML-related perspectives.
Thank you for your opinion. I am also speculative to apply this notation (A4.(\eighth) etc.) It is complicated as my expectation.
I should have time to reflect the concept in the articles you mentioned (Affine Space, Representing Music with Prefix Trees, and the codes of @rdd). By August I should have finished what I did over the summer. My work process is not that fast due to many gaps in programming skills.
I have made a Quark library related to this thread. It seems to work with the examples given, but needs further work. SPN and PitchClassSet are in this quark library.
Detailed help documents are provided for each class, as well as a Notator score guide!