I wrote a couple scale quantizer OPs for Teletype based on @discohead’s N.S lookup table. These are my first OPs and my C is rusty so I’m sure I’m missing something, but I can only get one of my two OPs (QT.S) to work correctly. nb: these OPs are just working with semitones; I might convert to volts later, I dunno.
QT.S simply checks the input semitones against all semitone values on the specified row of table_n_s until it finds the highest value less than the input. I feel like my code’s a bit messy (I wanted to wrap all the input values in useful ways) but it’s working great.
QT.SC is similar but the allowed values are selected by giving scale (0-8), degree (0-6) and chord type / voices (1-7). 1 voice gives a single note, 2 is a third, 3 is a triad, 4 is a seventh, etc. My problem is that my wrapping math is not working when a given degree + chord exceeds the length of the scale. This line: dix = (2 * i + degree) % 7; is supposed to pick the table index and wrap gracefully while checking the input semitones against the table_n_s value but when I test on TT it’s not selecting any values which occur after the wrapping starts. I could use a fresh set of eyes!
So for QT.SC do you also want the highest note less than or equal to the input? I apologize that my understanding of music theory is all but nonexistent so I don’t entirely follow the calculation here but it seems to me that this condition:
will select whichever value less than or equal to note_in gets hit last in the iteration, not necessarily the largest one. The final value of max_n_s_val is equal to the desired result in both the examples you gave but maybe this is not the correct answer in all cases? I also don’t quite understand this adjustment
if (!quant) note_out = max_n_s_val - 12;
since it seems like this would always give a negative value. What’s the desired behavior when note_in % 12 is 0? Find the least note in the chord?
Ohhh you definitely hit the nail on the head. It’s supposed to pick the highest note among the eligible notes, not the last eligible note.
If note_in isn’t bigger than any of the eligible notes in this octave, (!quant) is true and it picks the highest note from the lower octave. So that will always be a negative number of semitones when it needs to dip below the current octave.
QT.B and QT.BX are broken/bonkers with negative input voltages
n.b 10 1189 // scale = Bb, C, Eb, F, Ab or N=10,12,15,17,20
vn n.b 1 // return 10 OK
vn n.b -1 // return 5 OK
vn qt.bx 0 n 0 // return 0 OK
vn qt.b n 1 // return 0 OK
vn qt.b n 2 // return 3 OK
vn qt.b n 4 // return 3 OK
vn qt.b n 5 // return 5 OK
vn qt.b n 6 // return 5 OK
vn qt.b n 7 // return 8 OK
vn qt.b n 8 //return 8 OK
vn qt.b n 9 //return 10 OK
vn qt.bx 0 n -1 // return 0 OK
vn qt.bx 0 n -2 // return -3 should be -2
vn qt.b n -2 // return -3 should be -2
vn qt.b n -5 // return -5 should be -4
I hope whoever wrote this will look into it, not sure if it’s @desolationjones or someone else…