Frequency Table Read for Alternative Tuning


#1

Hi there . Im very new to Axoloti so please forgive me If I sound as newbie as Im.
I tried to use table/read to output frequencies that I previously stored in a float array inside the table object .
However the outcome of this is quite diferent from the values of my array . It must be somethign Im missing since Im very fresh to it .

This is how I imagined it . Im using pre calculated frequencies , in this case is just a 13-TET experiment .
I have my teensy polysynth reading the values from the midi note number , reading the array index of the corresponding note . In arduino IDE i just saved the array in a separate file and implementation was quite simple.

Im really curious why Im not able to get a float frequency output that corresponds to myArray[i]

Thanks a lot . I hope I will be able to share some parches soon regarding this matter . I will try to learn the logic and use a system to change the table im reading from , so I can have several scales in one "maqam" mode for ascending or descending behaviour etc .


#2

For Axoloti it is good practice to convert the table to int32_t, instead of floats. Floats uses a lot more resources, than int32_t.

It has been up here a few times over the last few weeks, check this thread, there are som info about how you can do it:

Another obvious thing I notice is that the values you send from the table is frequencies. The inlet you connected it to, accepts midi pitch(0-127), not frequencies. So if you feed the midi pitch with a value of 2423.54, for example, you can see that it will be way out of range, cause midi pitch is 0-127... The tuning will definitely not be correct, it will be way to high. If you want to keep your tables in frequency, you need to use another oscillator, that has a frequency input instead. But really depends on how you approach it all.

So there are a few things to start with :wink:


#3

The inlet you connected it to, accepts midi pitch(0-127), not frequencies

(facepalm) Thanks for that ! , I literally installed the software yesterday since a good friend landed me his axoloti to convince me for good about getting one .

I was quite sure that I saw somewhere and oscillator accepting hz values , and thought that all of them sorta worked on the same way .
I will check asap the link you attached , thanks again .
The idea of converting to integers make sense . Actually I could just code the coeficients and multiply them by a root note , but I thought that it would have been less intensive to read from a table of frequencies directly (no need of multipliying) but then I hit the floating point issue. Lets see where I get from the thread .
Will keep posted


#4

There are oscillators that takes frequency input.

To be honest I am not that much of an expert in the details what is most expensive floats or ints, but from what I have been told in this forum, floats are alot "heavier" than ints. So for Axoloti where you got a fairly limited amount of dsp and memory, its best to avoid using floats.

You will find more info in the link. But if you want more specific explanation on this some one else needs to chime in.

For the osc that takes freq, try osc/phasor lin or osc/sine lin for example, they both take frequency input.


#5

I got it now working with a bipolar2unipolar after the note in . But for some reason only works for the first three octaves . Then it just jitters a lot . I will keep trying tomorrow and see where it goes


#6

To me that sounds like you might be overflowing somewhere.... The number you send exceeds the limit of the format you are trying to input the value into..... Maybe... :slight_smile:


#7

Maybe you can use sputnki's sptnk/conv/ftom object. It converts frequency to midi values.


#8

I recently discovered for tuning there are some great objects in the harmony folder. Philoops microscaler object and SirSickSiks allEqtempScales object that might interest you.


#9

Thanks @jaffasplaffa and @bds . at the moment Im still very new to the particularities on axoloti software so cant ask for help without knowing the basis .

This is true , there are nice objects , but most of them detune each pitch . I find it hard to deal with and to find the correct notes, I could do it by ear with this technique but I would rather use tables , since I have all the frequencies I need . I might go into another direction if I cant find a way around.
Still I dint try converting the floats to integers multipliying by X etc.
But there it must be a way to read the table with indexes from 0 to 127 . Im getting -64 64 range from the midi object , tried many different objects but still no luck on doing the math on my own with this range.


#10

add a +64 offset. Then the range will be 0-127, instead of -64 to 64.


#11

Yes thats what I did a while ago , but keep having strange output. Negative numbers and other unexpected results.
It might be all wrong from the way I coded inside the table , and as you said @jaffasplaffa, the object cant handle the floats for some reason .

Will try tomorrow with your initial suggestion of converting them to int´s , and if that doesnt work , I just store 2 numbers of the ratios then multiply by a root note .


#12

Yes, that was what I wrote, that I think you migh be overflowing one of the formats in the conversion from floats to ints. The result of overflowing is exactly negative numbers.

And yeah, all this conversion, is one of those things with Axoloti that can be a real pain and can take a while to get used to. I do a lot of work in Pure Data too and some c++ stuff too and everything is just soo much easier with floats :wink:


#14

Same here , I'm too used to convert "freely" or without much impact on the system , I'm gonna need a time to get used to this BUT !

I found out that is not about the floats , at last not only. There is something much simpler that Im missing...

Here I tried to read from a 8 index array of integers , this didn't work as expected . Not even with phasor frequency input or any other translation that I can think of . Feeling overwhelmed and lost here myTableArray.axh (6.7 KB)

I ignored the oscilator part for a while cause I was reading in the docs about the -64 64 range. But then all sorts of questions comes to my mind . Why even with frequency input it doesnt output from the table/read as expected ? if selector sends integer 3 , it should go into the table read and return the index 3 of myArray[i]. But all I got is negative numbers and all sorts of misleading reads.


#15

I think maybe you should just get to know Axoloti a bit better before attempting further. Ad you said, you are very new to Axoloti, I think you should explore a bit, then some of these things will probably fall in place over a little bit of time.

Again, the minus and the weird values are probably because of overflowing a type some where in the chain.

To me it does not look like you are using the input to actually read the array.

Drop the for loop stuff, I dont think you need it to be honest. If you want to read out the myArray, try something like this:
outlet_X = myArray[inlet_Name]
Then you use the inlet to read the table values.

Anyway.... Ill still suggest to explore a bit. There are so many other things you can do, that you can play around with and when you have a better understanding of everything, then try again.


#16

Hey Carlo,

welcome to the board :slight_smile:

I tried chaning the table to 16b and that will give not these weird overflows.
The next thing is that I think the values you have in the table are somehow scales to the range of 0-64 that axoloti uses for float values.

If you want to hook up a frequency value to a (note) pitch input of an oscillator you need to convert it. This what I found about this.


#17

Pasting your data to the init section of table/load array seems an efficient way to get your frequency data in there. Hang in there you’ll get it working..

Those overflows that Jaffasplaffa mentions are tricky...

The biggest thing for me is to start thinking about the way the axoloti does a lot of its work in integer. The great thing about the axoloti is you can go really deep into things and the board and software is so well provisioned.


#18

Hey @bds I would really like to see how you did that, use the init to load table data. I did try this before but with no succes, I got some error I didnt know how to fix.. Would you care to share a screenshot? I would highly appreciate :slight_smile:

Thanks!


#19

I have been trying to understand how the numbers you write in the table translate into the axoloti environment.

With an 8bit table it's clear.

0-127 as integers will translate to a range of 0-63,5 so you get always value of table divided by 2.

float numbers didn't work!

When using a 16bit table the results where not that consistent...


#20

Hey there just hooked everything up with the 16bit table, and the result is 13Tet!

BlindDoctorKoma.axh (8.3 KB)

However from playing around with values in the init of the table I don't think the table really accepts floats.

That means you will have the frequencies rounded. In practice this means you will have more discrepancies from the intented tuning in the lower range and less in the higher.
(imagine you have 1hz and a 1,49hz value, theorically almost the intervall of a perfect fifth (practically out of the human hearing range) this would be rounded to to 1, resulting in the same intervall.

The more you go up the less dramatic this effect will be.

Eventually I think the best would be a dedicated object that can read multiple frequency files from sd card and convert them nicely.

EDIT: @johannes made an object that accepts scala files during Mtf 2 years ago, wich could be frequenciy lists as far as I know. Unfortunately I can't find the patch anymore...


#21

this can be made much more precise of course.

look at the remapaxis object i made the axis49 controller. while it is not what you are looking for exactly, it will give you strong hints.

the section in the k-rate code:


outlet_out= (reMap[(inlet_in >>21 ) + 63] - 64)<<21;

should get you started. i am reading out the reMap array (defined in the local data) with the values that come into the inlet. since those are fixed point numbers that represent midi values i shift them left by a factor of 21. (means 21times divided by 2) that gives me 7 bit numbers. i add 63 to that to get them into a range from 0-127.

now for your approach leave the - 64 and left shift out for the moment.

ask yourself this, how much precision do i want?

if you have a frequency for midi note number 60 (so the 60th place in your array) and it reads something like this in float: 320.32347 (just an example), you would

multiply that value x-times by two. if you want to go full resolution you would multiply the value 21 times by two and would not need the <<21 at the end of the code.

the -64 will then also become a much larger number. i.e. -64 multiplied by 21 times 2 as well (if you choose to multiply that much.

i hope this helps.

(as an aside i would still recommend to recalculate the values to something that represents midi notes rather then pitch. it would just work much better in the axoloti universe. so basically your 320.3247 hz would become something like 60.212393939 or whatever. you would then do the things i described above to that number)

the formula to convert from frequency to midi note number should be widely available...