-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding support for Alternate Tunings #4
Comments
Alternate tuning would be a great addition to the library! I've played around with it, and thought about how to implement it optimally, but I haven't really reached any conclusion, so your code would be greatly appreciated, just submit a PR and we'll take a look at it from there. |
Awesome, I will work on adding this tuning class. |
Great, but is there a need for a complete tuning "class"? When you say tuning do you mean the equal temperaments and the like? Or do you mean everything from western tunings to non-TET, say Indian tunings? My concern is about the different notes, and their names. For example, are we to implement support for 24 tone scales? Or does we preserve only 12 tones per octave? |
I was thinking that a note would be composed of a tuning. This is how we were originally developing it in music.js. Here is an unfinished demo I made last year to showcase the different tuning calculations: http://code.gregjopa.com/html5/audio/music.js/tuning/ (the audio only works in firefox) You make a good point that handling note names will be difficult and may add to much bloat to the library. I need to give this some more thought on how it would work with teoria. |
Cool, I also predict some conflicts with the Interval class, as it presumes 12TET (like the rest of the library). How are developers to make a note jump a "Lesser septimal tritone" up/down. For example the 19TET tuning introduces all these new intervals. Maybe one could go in a "driver" direction? Where each tuning is implemented as a "driver"/interface, which implement the same methods (such as |
I like your idea of implementing each tuning as a "driver". If you look at the music.js code from my tuning demo I think we use a similar approach except we grouped tunings into two classes: Linear and Irregular. These two classes work for frequency calculations but wouldn't work for intervals so each tuning would need its own class/interface. We could start out with 12 tet and then slowly implement the rest of the different tunings out there around the world. Do you know of any other js libraries that use this "driver" design pattern? I'd like to learn more about it. I started brainstorming this design and created the following gist: https://gist.github.com/3292167. I added a few questions for you in the comments. |
@gregj I'm sure there must exist some, but I think it's just something that I've picked up as a sort of "implementation of an interface" OOP-style. I use it whenever I get the chance, for example the parsers in Subito where they must implement a (simple) interface to be a "valid" parser. The design pattern is an important question, but I'm afraid that I simply do not have enough knowledge on the subject pt. to make a reasonable decision. I need the following answered:
I'm sorry for this lack of knowledge, and if you can, then please enlighten me on this subject or point me in direction of some articles/books I can read to grasp the subject a little better :) About the design pattern: I agree totally that it seems only reasonable to start with implementing the 12TET tuning, and then work our way from there. I'd love to see a interface-like implementation of each tuning, which exposes the same methods so that all other logic is blissfully unaware of which tuning is being used. Because of this, I'd also love to decouple the // Set tuning to 12TET
teoria.tuning('12TET');
var cis5 = teoria.note('C#5');
cis5.fq(); // 554.3652619537442
teoria.note('C4').scale('minor').forEach(function(note) {
console.log(note.fq());
});
// Set tuning to 19TET
teoria.tuning('19TET');
cis5.fq(); // Something else than 554.3652619537442
// ... etc To answer the questions from the gist: TeoriaNote constructorI've though about making the constructors (all of them) only taking one argument: A parameter object. Seems like a good idea, when we get all these optionals ( TeoriaNote#keyYes it would need to be "moved" to the tuning class. That does not mean that we remove the method, but that it will work as a proxy for calling the active tuning class. And of course the namedTuning methodWhat about storing all the tuning classes in a hash table? Like TeoriaTuning.Tunings = {
'12tet': TeoriaTuning12TET,
'19tet': TeoriaTuning19TET,
'22tet': TeoriaTuning22TET,
// ...etc
}; Then we could just check if the tuning was valid by a simple Tuning constructorsRight now I can't think of anything they'd need to know from the outside of their own scope - But that might be because I don't fully understand them yet - so let's take that up later. Phew, what a screed - Hope you have the patience to read it all ;) |
Hey Jakob, see my responses inline. FYI, I did not study music theory in On Wed, Aug 8, 2012 at 4:17 AM, Jakob Miland notifications@git.luolix.topwrote:
For all tunings greater than 19TET I think the extra notes have sharps and Tunings like pythagorean Intonation, mean-tone system, just intonation, and
http://cnx.org/content/m11639/latest/
Great responses. Tuning systems are really complex but I think we are
|
Hey @gregjopa, any advancements on this? Not that we're in a hurry but I'm curious :) |
Hey @saebekassebil, I have been slackin on this. Last time I worked on it I ended up getting really confused and wasn't making any progress. So I did some googling and found an old book about musical temperament: "An Elementary Treatise on Musical Intervals and Temperament" by Robert Halford M. Bosanquet. Here is the link to the free e-book: https://play.google.com/store/books/details?id=CiwDAAAAQAAJ&rdid=book-CiwDAAAAQAAJ&rdot=1 The book has lots of info on intervals and has a lot of formulas. My plan is to document all the formulas for the different temperaments out there. Then see how we can integrate it into teoria. |
I'm slowly beginning to comprehend the extensiveness of the refactoring work this is going to take. Below I've included a list of every function/functionality that needs to be refactored to make it tuning-agnostic. I'd really like to go through with this, but it might take some time.
including everywhere these functions are used internally and possibly more...
where activeTuning is a tuning interface that implements all the needed functionality for a tuning (a note-name parser, interval measuring, etc.) I'm posting this here, just for everyone (myself included) to see, so that we might choose a good refactoring strategy. |
This is a good thread, I wish I was as advanced as you guy on the topic! But for what it's worth, when I read @gregjopa's line "This is why well temperament and equal temperament were invented, so an instrument wouldn't have to be re-tuned every time you wanted to play in a different key." I ask myself then: Is it not the instrument that need to be tuned and not the whole scale, notes and chords? My understanding of music theory is barely a month old but what I understand from Boesendorfer Pianos is that a musician will read the same sheet music, will play the same keys, but the tuning is entirely different. I'm not clear now on exactly how this applies to your implementation ideas, but I thought maybe a little abstract thinking could help. It could for example, be the job of an Instrument class to adapt itself to a Scale according it's Tuning? |
Actually tuning and temperament isn't the same. Tuning is how you tune your instrument, that is screwing the nuts on the guitar head, or inside the piano to tighten or loosen the strings to fit into the temperament. The temperament describes how the notes "relates" to each other - how big interval (in cents/hertz/ratio) is there between them. For example the temperament we use in modern western music is called 12TET - Twelve tone equal temperament - we've cut up the octave in twelve exactly similar pieces. This is however a (gross) approximation for a "just" tuning - which relates the tones by ratios and sounds much richer, but only in one key. For example if the tune you're playing modulates from F major to Bb major, then suddenly Bb will sound odd in some weird places, because some of the intervals (relative to Bb - the new root), aren't the correct size. I'm really puzzled on how to implement this correctly, and in a way that makes it possible to extend with a lot of other temperaments, but I hope that we can find some good way of creating a general interface for a temperament. |
I see. Thank you for the explaining the distinction. Until I get my nose deep into the code I can't be much help on this, but at least I'll have it in my back-burner as I play around in the source! |
Are you interested in adding support for other types of tunings like 5-tet and Pythagorean? Piers Titus has a tuning exploration demo that compares the different musical tunings out there: http://www.toverlamp.org/static/wickisynth/wickisynth.html (this demo only works in Firefox).
I have some code for a tuning class that I was going to add to music.js but honestly I like this library better. If your game I can take a stab at adding a tuning class to teoria.
The text was updated successfully, but these errors were encountered: