Musical structures #13
Replies: 19 comments 6 replies
-
Tone.js has a class called |
Beta Was this translation helpful? Give feedback.
-
I am not sure you can use polysynth for different timbres but worth exploring. |
Beta Was this translation helpful? Give feedback.
-
I have some decent Python code for temperament and key signature now that, when converted to JavaScript, could replace much of the code in musicutils.js Still trying to work out how to best adapt the non-equal-temperament tuning to our key/mode structure. |
Beta Was this translation helpful? Give feedback.
-
I was trying to get some states sorted. Realized that we need a good idea of what and exactly how the key, mode, and scales come together. Perhaps we should have a diatonic scale representation and work on top of that; I think all we should need is an array of notes (pitch in hertz) and everything else just uses the indices of that array. But, I'm very confused with the key/mode. |
Beta Was this translation helpful? Give feedback.
-
I have a plan... hope to be able to show you something soon. |
Beta Was this translation helpful? Give feedback.
-
t = Temperament() |
Beta Was this translation helpful? Give feedback.
-
We can use the generic note names directly when the temperament has more than 12 notes... |
Beta Was this translation helpful? Give feedback.
-
Whenever you generate a new temperament, you need to specify the number of steps in the octave. A generic note name is calculated for each step: "n0", "n1",... "n11" for a 12-semitone temperament. The temperaments with 12 steps also get assigned letter names, e.g., C# and Db. We need to convert those to the generic names to map to the temperament and get the frequencies. |
Beta Was this translation helpful? Give feedback.
-
I'm still cleaning up the key signature code so that you can define modes for non-12-step temperaments. But I have a simple framework now for doing that :) |
Beta Was this translation helpful? Give feedback.
-
I need to do more testing, but I think it is all basically working now. You can create custom modes for any temperament, navigate intervals, both scalar and semitone, and get back hertz for any note. I am not sure how to handle cents for most temperaments. I need to wrap my head around the math. |
Beta Was this translation helpful? Give feedback.
-
I also want to add some inverse functions: frequency to generic note name and generic note name to letter name. |
Beta Was this translation helpful? Give feedback.
-
class Temperament(builtins.object)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| class KeySignature(builtins.object)
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Beta Was this translation helpful? Give feedback.
-
Almost everything is now in place.
To do:
|
Beta Was this translation helpful? Give feedback.
-
392.0290500506298
392.0290500506298
392.0290500506298
392.0290500506298
392.0290500506298 |
Beta Was this translation helpful? Give feedback.
-
The only constant is the base frequency for the temperament (C in octave 0 by default). The rest of the frequencies are defined per octave based on the formula(s) associated with each temperament. I do have to add an offset in situations where you change the base frequency to, say, G. |
Beta Was this translation helpful? Give feedback.
-
I've got a little tweaking to do on the scale generation. Then I think it would make sense to make two more classes: one for the scale itself and one for a pitch name. Those will help clarify some of the code. |
Beta Was this translation helpful? Give feedback.
-
Should we add Tuning to your list at the top of this discussion? Not "Temperament Tuning", but "What do I tune my A string or Bb trumpet to" kind of tuning. This, I think, is a kind of meta, that may need to be embedded deep into code construct. This is the open-issue on the subject: sugarlabs/musicblocks#2460 |
Beta Was this translation helpful? Give feedback.
-
I guess the way I think about tuning -- correct me if I am wrong -- is that is should essentially impact the base pitch used for the generation of the mode. So for example, if you want to tune A4 to 440, then you are essentially saying, what base frequency do I need such that when I calculate A4, I get 440. Use that base frequency for all of my calculations. I should be able to figure that out in some closed formula. (But it suggests that when tuning, you need to specify an octave as well as a pitch.) |
Beta Was this translation helpful? Give feedback.
-
I added support for tuning. And the code for generating the scales is much more robust. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
There are some structures in music that we should capture in the design. (In Music Blocks 1.0, there were afterthoughts and hence they are not well reflected in the internal structure of the code, adding lots of unneed complexity and computation.
Key/Mode --- We should always have a key and mode defined and in that definition, we determine things like intervals, inversion, accidental preferences, etc. Right now, all of that is calculated on the fly for every note.
Temperament --- We default to equal temperament, which is fine, but to change to another temperament is onerous because there are so many things hardwired to equal temperament (e.g., the number of half-steps in an octave, the hertz associated with a note name, etc.) A temperament object could subsume all of this and make it much easier to work with non-equal temperaments.
Tempo and meter -- These are also better handled as a class rather than as globals. This will make concepts such as measure and beat much easier to expose/manage.
Timbre -- We may want to rethink how we do this. Right now, you can add drums to a note, but not change the timbre (or have multiple instruments playing at once) except by adding multiple turtles. This leads to come complexity in maintaining timing.
Beta Was this translation helpful? Give feedback.
All reactions