Teletype “JI” harmonic series (Bug??)

Hello everyone, this is my very first post. I got a Teletype about a month ago without any previous coding experience and I’m enjoying it very much! So much to learn :slight_smile:

So, the reason for my post:

I was playing around with the “JI” OP and wanted to simply have a oscillator climbing up the harmonic series. But I noticed that some harmonics aren’t right. The first 16 harmonics are right but then the 17th outputs 0 Volts. Then 18 is right but 19 is 0 V again. This keeps happening every few harmonics while I go up further the series. Like on 23,29,31,34,37…

The little script I’m using:

CV 1 JI X 1
X + X 1

Anyone else noticed that? Is that a bug in the firmware?

From my understanding JI requires two arguments, since it’s expecting the just intonation ratio, not a single number, maybe that’s what’s casing problems?

I the example was meant to be

JI X 1

…but I do think there’s a bug. If the first parameter is 17, 19, 23, 29 or 31 or a multiple of those (possibly others), the output is 0 regardless of the second parameter.

I haven’t used the JI op myself but it could be that at the 17th harmonic and above are creating voltage values that are too large to express in 16-bit signed arithmetic.

A harmonic at a 17:1 ratio is slightly over 4 octaves so that is getting close to the maximum of what’s expressible with V/oct (assuming a -5V to 5V range is being expressed using all 16-bit values).

Yes, you’re totally right. It’s a typo, my bad. I’ll edit it now…
I did use a second number and as Starthief says, it doesn’t matter what the second number is. It’s always 0V.

Another thing to mention is that it works with Just Friends over I2c. Using JF.TUNE X 1

The range is 0 to +10V. I’m not having a problem with JI 128 1 producing 7V aside from it being unpleasantly high-pitched to listen to :grin:

Also I’m finding that the same numbers that fail as the numerator also fail as the denominator – JI 16 17 is also 0, but should be just under V 1.

1 Like

The 0 result indicates that the JI algorithm is failing to find the prime factorization of either the numerator or the denominator.

The algo checks numerator’s divisibility against primes 2 thru 13, so it makes sense it would fail for bigger primes like 17. It’s recursive, so it will also fail against numbers like 34 whose prime factors include primes larger than 13.

The math used to generate the magic numbers in ji_const[] could be used to expand the primes table, but I’m unsure whether we’d bump up against the limits of 32-bit math… haven’t had my coffee yet :slightly_smiling_face:

:telephone_receiver: paging Dr. @Galapagoose and Prof. @simondemeule

5 Likes

Once upon a time I made a tweak to my TT firmware to allow up to 23-limit JI intervals – just pushed it to GitHub in case it’s useful:

The ji_const[] array there was actually generated using either Python or bc, and I was a little surprised to see that the results were a little different from the originals. I chalked it up to some kind of rounding issue somewhere and haven’t investigated further.

4 Likes

In my research of just intonation, I never saw any practical usage which used ratios beyond 13-limit just intonation. I never considered that the operator would be used as a harmonic-series-to-voltage calculator. (Nice idea!)

The implementation is capped at 13-limit as a result. I don’t think Teletype has support for logarithms (this is a baseless assumption), hence the pre-calculated logarithm-of-primes table. You could extend the limit as @synthetivv did, but at some point before “arbitrary ratios” you’ll need to switch to the slow logarithm approach.

Personally I don’t consider this a bug (because it’s outside the intended use of JI), but if people feel otherwise, feel free to submit a PR with a general solution!

2 Likes

It’s not common but it’s not unheard of, either. There are definitely situations in which higher prime limits are useful, especially if one treats “prime limit” as a kind of color expansion/subset, rather than intending “all primes up to…” which can indeed get messy. Lots of beautiful music using 17s, 31s, and other “unusual” suspects. See for example Polansky, Lamb, and several others.

1 Like

For sure my ‘research’ was very limited and mostly coloured by works of Harry Partch. Happy for anyone to add a few extra primes (they don’t have to be sequential if only 17 & 31 are interesting) - it’s only 2 lines that need to be changed (see @synthetivv 's fork for an example).

On a side note, I’d love some links / names of compositions that use these extended ratios if you have em :slight_smile:

4 Likes

For sure!

psaltery is one of several pieces by Larry Polansky that morphs between related harmonic series, usually going up to the 17th harmonic in each (so effectively up to 85:64 in the furthest series)

Cat Lamb’s point/wave (my recording) sticks to the 3rd, 7th, 11th and 31st prime axis (without any 5-factor intervals):

I’d also look at the music of James Tenney and Marc Sabat for higher-prime explorations.

5 Likes

Thanks everyone for replying. I already like this place a lot :slight_smile:
This was quite educational and deeper then I thought.
For me personally it doesn’t matter. I just stumbled upon it and was curious why that is.

1 Like