Can I process a list of frequencies and 'tune' them to quarter and eight notes.

Noisey Parker's icon

I have a list of frequencies that I want to tune to the closest quarter or eighth note. I have drawn a blank for some reason, does anyone know a way to do this?

metamax's icon

You need to specify the length of a quarter note ('beats per minute' bpm) which will let you calculate quarter notes per second (Hz). And then multiply that by .5 to get eighth notes per second.

From there you can adjust your frequencies to the nearest multiple of your Hz value.

ex. bpm = 120 quarter notes per minute = 2 Hz quarter notes

freq list: 144.56 1253.42 765.98
tuned list: 144 1254 766

Is that what you're talking about?

Max Patch
Copy patch and select New From Clipboard in Max.

toothpaste's icon

I believe he is trying to achieve some sort of microtonality and having a confusion between 'half note' and 'half tone'

metamax's icon

I thought about that but 'eighth tone' seems a bit out there.. ;)

metamax's icon

Is this accurate?

Max Patch
Copy patch and select New From Clipboard in Max.

Floating Point's icon

if it is to do with frequencies in the audio spectrum (as distinct from the event spectrum)

Max Patch
Copy patch and select New From Clipboard in Max.

I'd do it this way:

Roman Thilenius's icon

i would do it like this: first expand, so that you can just round to nearest integer:

1.) input*8

2.) round to int (for example [expr int($f1+0.5)])

3.) back to original base: / 8.

4.) probably [mtof] ...

Roman Thilenius's icon

it wasnt me, if i am not putting that all in one line:

truncatevaluesinalistoffloatstoclosest1/nandconverttofrequency! ;)

[vexpr (440.*exp(0.057762265)*(((int(($f1*$f2)+0.5))/$f2)-69.)))]

where $f2 is the scale division. (others would probably have preferred to do it on a steps-per-octave/temperament scale basis)

-110

Noisey Parker's icon

Hello,

Thank you all for you replies it is indeed microtonal tuning I am after, sorry for the confusion. I have been through the solutions you have offered...

Floating point - It seems I don't quite understand this solution?

Midi C4 = 523.25
midi C#4 = 554.36

so I would expect a quarter tone to be between these values? I worked it out as 538.8 Your patch doesn't seem to tune to the closest quarter tone value? For example if I put in 530. I would expect it to tune to 538.8 as the closest value. It actually tunes to 530.86.

The same for the other solutions offered. I already know the pitches, what I need is a patch that will round up and down any frequencies to those set pitches. You could do an incredibly long-winded

I also thought I could have the tunings in a coll and then scale my input from frequncy to the number of items in the coll, but when I tried it, it didn't seem acurate.

Thanks so much for your suggestions so far, any other ideas based on my making the requirements a bit clearer?

Roman Thilenius's icon

you are almost at it. but you should not start thinking in hertz, this leads to nowhere. do all these operations on the linear layer only. a quarter tone over C4 is 72.5. now make sure that 72.33 is rounded to 72.5. thats what my vexpr does unless it contains a typo.

Noisey Parker's icon

ROMAN THILENIUS, when I put your patch into MAX it says bad expression. I am not experienced with the VEXPR object and so am not quite sure why this is?

Roman Thilenius's icon

there is a ( missing .. lets see where ... i think ... at the beginning:

[vexpr ((440.*exp(0.057762265)*(((int(($f1*$f2)+0.5))/$f2)-69.)))]

a) send 2. or 4. or 8. into the second inlet to set the scale.

b.) then ... oh, i forgot something. because you said your list is in Hz, right? so we will have to convert that to note numbers first:

440.11 388.25 405.8777
|
[vexpr log($f1/8.175798)/log10(1.0594633)]

lets integrate that into the other expression:

[vexpr ((440.*exp(0.057762265)*(((int(((log($f1/8.175798)/log10(1.0594633))*$f2)+0.5))/$f2)-69.)))]

looks wonderful, doesnt it? hopefully with no errors left now. will check later when i am at max.

this will now convert a random list of frequencies in hertz directly into a list of closest-to-quarter-tone-scale freqencies in hertz when you send a 4. in the second inlet.

see the helpfiles of mtof, ftom, and vexpr for references.

-110

mzed's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Here's another way to do it:

Fewer parenthesis.

Stephane Morisse's icon

You 'expr guys' kill me :))

Emmanuel Jourdan's icon
Max Patch
Copy patch and select New From Clipboard in Max.

No expr, no manual rounding... just ftom/round/mtof ;-) If you are stuck in Max 4, Roman solution will work perfectly of course.

Roman Thilenius's icon

well yeah, just that you will still need stuff like !/ 1., zl len, iter, zl group and the like in addition to make it work. then your screen is full of objects and it´ll be totally unefficient.

but what really sucks with expr is to find and correct bugs. i just wrote "+05" instead of "+0.5" when i tested it in max and needed 3 minutes to find it out.

Roman Thilenius's icon

though you might say that mtof and round can process lists in max v6 .. but as long as not all objects can process lists ...

Floating Point's icon

NoiseyParker, you said

Floating point – It seems I don’t quite understand this solution?

Midi C4 = 523.25
midi C#4 = 554.36

so I would expect a quarter tone to be between these values? I worked it out as 538.8 Your patch doesn’t seem to tune to the closest quarter tone value? For example if I put in 530. I would expect it to tune to 538.8 as the closest value. It actually tunes to 530.86.

OK whoops--That's just because in my example patch I round to the nearest 1/8 tone, but in the comment box I stated it was 1/4 tone

Floating Point's icon
Max Patch
Copy patch and select New From Clipboard in Max.

here's a more illustrative patch:
edit: made a mistake; reposted patch which is now not misleading
`

Emmanuel Jourdan's icon

@roman that is what I was going to say ;-) mtof/ftom/round process list since Max 5.x.

Noisey Parker's icon

@roman I see where you're going, i'm not sure I completely understand. I have attached the quarter tone frequencies I have been using, which came from here...

these come out as different from the ones in your patch. I make the correct rounding for 250hz (one of the examples in your patch) 254.18hz but your patch rounds it to 250.53hz?

Quarter-tone-frequencies.pdf
pdf
Roman Thilenius's icon

hm. on the one hand, it might be that in my or others peoples example there is still something wrong. on the other hand, i would not use some third party pdf as reference. it is more useful to compare against "70.5" -> [mtof] == Hz.

button
uzi 256
* 0.5
mtof
prepend append
umenu

then save.

still wrong?

Roman Thilenius's icon
Roman Thilenius's icon

i am too tired now, but 250.53 seems right when a 4 is 440 Hz.

you can prove it by looking at the linear representation:

250.533493 -> ftom 0. -> 59.25 (exactly what you would expect an 1/8 tone to look.)

that 254.18 is the next tone when you use 1/4 tone scale. :)

what is wrong is my description in the posts above: an argument of 4 of course stands for 1/8 tone scale - because base 1 is a half tone scale already.

same with that [round 0.125] patch - this produces a 1/16 tone scale.

which is why i recommend to build it for steps per octave, and not for steps per chromatic step:

n -> [!/ 12.] -> $f2 of vexpr

Noisey Parker's icon

Ah! There's my confusion! I definitely thought 4 mean 1/4, Apologies and thanks for your help.