Closed codingWhatzThat closed 5 years ago
I looked at this a long time ago when I developed the first version of this app. I will have another look.
Thanks much!
I have found a table of 32 temperaments that I must have got from somewhere when I was first developing. The method for calculating equal temperament, where reference
is the reference frequency (440Hz), and log2(n)
is log(n)/log(2)
is...
// Cents relative to reference
double cf = -12.0 * log2(reference / frequency);
// Note number
int note = (int) Math.round(cf) + C5_OFFSET;
The C5_OFFSET
is added because each octave starts at C, not A. Then to convert from equal temperament to the selected temperament, calculate the note number in the octave for that key, as any temperament other than equal is different for each key.
// Octave note number
int n = (note - key + OCTAVE) % OCTAVE;
// Temperament ratio
double tempRatio = temperaments[temperament][n] /
temperaments[temperament][A_OFFSET];
// Equal ratio
double equRatio = temperaments[EQUAL][n] /
temperaments[EQUAL][A_OFFSET];
// Temperament adjustment
double tempAdj = tempRatio / equRatio;
// Reference note
nearest = reference *
Math.pow(2.0, Math.round(cf) / 12.0) * tempAdj;
Then calculate a temperament adjustment to apply to the calculation of the nearest reference frequency for that note in that temperament in that key. This works for the key of C. I have to test it for other keys.
OK, that appears to work, it will be in the next version.
Great! I look forward to it!
I'm not sure I follow how the table of Chinese octave frequencies I found can be implemented yet, but I'll wait to see what you've done, and if there are further changes necessary for those tones, I can make another idea suggestion after I've come to understand better what I'll need to mention.
At this point, it seems that a basic functionality along those lines will be manageable with the added feature of allowing multiple user-specified temperaments to be stored in the apps settings, allowing to quickly and easily switch between different temperaments for octaves with starting points a semitone apart. I'll try it out to the extent I can with the next version.
Thank you so much for your work!
It would be possible to add user defined temperaments stored in a simple text file.
# User Temperaments
Pythagorean: 1.000000000, 1.067871094, 1.125000000, 1.185185185, \
1.265625000, 1.333333333, 1.423828125, 1.500000000, \
1.601806641, 1.687500000, 1.777777778, 1.898437500
There would need to be 12 values for each temperament, which can be simple ratios, like the example, or actual frequencies. All that matters is the ratios within each list. There is built in functionality to read a property list like this.
I've copied and pasted the example file into a "Custom.txt," and placed it in a directory called "Tuner" in "/storage/emulated/0/" on my phone's main internal SD card. I've also looked for a "Tuner" directory anywhere inside /storage/emulated/0/Android/data/," but I find no directory by the Tuner app's long name in that folder. Did you mean to include the text file at build time? I'm limited at this time to compiling on a java/android IDE on the phone itself, and it seems I'd need a walk-through of how to import the source files piecemeal into the IDE in order to compile a working .apk to install from source. Was the "Tuner/Custom.txt" file intended to be built into the .apk at build time?
That's in the next version, which might be on F-Droid today.
This way works!
1/1, 2187/2048, 9/8, 1968/1643, 81/64, 1771/1311, 729/512, 3/2, 6561/4096, 27/16, 5905/3277, 243/128
...Custom Temperaments Chinese: 1.000000000, 1.067871094, 1.125000000, 1.207361963, 1.265625000, 1.350877193, 1.423828125, 1.500000000, 1.601806641, 1.687500000, 1.801953006, 1.898437500
Thanks so much!
OK, thanks
The chart from which I got the preceding values was an image found at random by a webcrawling online image indexer. I think the calculations might be incorrect on some parts of the image I've been looking at here.
Since, I've found this explanation which provides C as a base pitch as a modern convention to compensate for different starting frequencies in different dynasties, and also provides whole number values involved in the Chinese temperament system and a description of the intervals being at a ratio of 3:2 (described as a kind of "just tuning"). The numbers I've posted above were the listed ratios from the source I had at that time, but this one, described as a "Chinese Relative Fifth" system seems more reliable, in the event a custom Chinese scale is desired:
http://2centsmusic.blogspot.com/2013/12/of-tuning-and-temperament.html?m=1
Perhaps such values could be derived more reliably from an understanding of this material.
(I was surprised to see the latest version of the tuner require SD card access - but reading up it is not really possible to postpone requiring this permission without sacrificing support for older Android versions so I created a separate issue (#35))
It's not possible to check for a user provided file without permission to read external storage or SD card according to the device. It would be possible for the user file to be in the app's external files directory (Android/data/<app id>/files
), which doesn't need permission, but this is deleted if the app is uninstalled. If you deny permission, possible in LineageOS, you just don't get the custom temperaments as the app assumes no file.
Hmm, having to re-upload any custom temperaments after app uninstall/reinstall sounds like a relatively small price to pay if it allows not requiring the 'SD card' permission... but this is obviously up to you to decide :smile:
This tuner app is the most complete I've yet stumbled upon. One possible addition it still seems to lack, however: I've used an android app from the google repository which also allows for other temperaments, even allowing user-specified frequency deviations in cents plus two decimal places from the equal tempered chromatic scale. I'm looking to tune to Pythagorean tuning values and Chinese tunings also. If this functionality could be worked into this already well established offering, it would indeed make it, so far as I've known anything of, the most complete manifestation of its kind.
I'm new to the subject of alternatives to the equal tempered tuning, and from what I've started to gather, an ability to input actual wave frequencies as opposed to inputing cents deviation might be a more precise and direct method of achieving software sensitivity to the desired frequencies for other temperaments as the relationships with these other tunings are a matter of arriving at products of rational numbers and a base frequency. How the relationships between the octaves are handled with regard to tuning and what I'm learning is called Pythagorean comma, is something that's still beyond me just at present. I'm just not sure, yet, how the pitches outside of the octave of the reference frequency are calculated, while I have seen regarding Chinese tuning, a chart of ratios from the fundamental, carrying up a note at a time, each new scale of sorts basing from one of the twelve calculated pitches of the base octave. How multiple octaves are handled with such tunings is more than I personally could advise about to date.
What do you think? Could this be of interest to you as an inclusion to your Tuner software?