Hi everyone, I'm relatively new to the Pd community so I'm not quite sure where would be a good place to announce this, so I guessed that this would be a good place:
I have written an external object that takes a float with amount of Hz a sound is and determines the note of this tone. I.e, 440 is A, 415 is a 1¢ low Ab with a 0.174 Hz error (thus not quite as low as 1¢, but almost 1¢). It uses the pyext extention (available from Thomas Grill at http://grrrr.org/ext/py/) and is released under a two-clause BSD license (meaning you can use it at will as long as you keep my copyright statement available in source and binary).
It's available from: http://blog.saers.com/archives/2004/11/25/note-determining-object/
I'd really like to hear back from you with comments in the blog and here (or private email), both with regards to the object and if this is not a suitable place for object announcements.
Cheers
Nik
On Thu, 25 Nov 2004, Niklas Saers wrote:
I'm relatively new to the Pd community so I'm not quite sure where would be a good place to announce this, so I guessed that this would be a good place: I have written an external object that takes a float with amount of Hz a sound is and determines the note of this tone. I.e, 440 is A, 415 is a 1¢ low Ab with a 0.174 Hz error (thus not quite as low as 1¢, but almost 1¢).
Candid question: what's the advantage of that over the builtin [mtof] class?...
Then it's easy to postprocess the result of mtof to split it into:
(Hz) | [mtof] | [expr int($f1+0.5); $f1-int($f1+0.5)] | | [expr int($f1/12); $f1%12] | | | | (octave) (note) (cents)
(caveat: ideally, % and int would be replaced by mod and floor, but the latter aren't in pd afaik)
Mathieu Bouchard -=- Montréal QC Canada -=- http://artengine.ca/matju
Hi Mathieu,
Mathieu Bouchard wrote:
Candid question: what's the advantage of that over the builtin [mtof] class?...
Mea culpa, I have not used expr much, so when I copied your example below into Pd I got "no such var 'fl'" when using ftom (I expected this was what you wanted as the idea was going from a frequency to a number representation of the note). Using motf I get a syntax error.
The advantage of the implementation is that it really makes it easy to make other scales. Most litterature on tempered scales I've read starts with the equal tempered scale and says how many cent certain tones deviate from the equal tempered scale. Thus, with this basis it's rather simple to make a meantone, werkmeister, valotti, kirnberger and other scales. That's where I'm heading next. (just need to dig up the books again and get an exam passed) :-)
Would you check if your solution described below works and possibly send me a Pd file with it? I'd really like to try it out. Performance-wise I'm not very happy with the Python implementation as I find it too slow for real-time use and need to make it less responsive by use of a metro or similar for my hardware, so I'm considering rewriting it in C.
Cheers
Nik
On Thu, 25 Nov 2004, Niklas Saers wrote:
Candid question: what's the advantage of that over the builtin [mtof] class?...
Mea culpa, I have not used expr much, so when I copied your example below into Pd I got "no such var 'fl'" when using ftom
That's probably because your font doesn't make a difference between the digit one and the lowercase L. That or you didn't see it.
(I expected this was what you wanted as the idea was going from a frequency to a number representation of the note).
Yes, my mistake, should've been [ftom].
Using motf I get a syntax error.
I hope so, because the other one is actually called [mtof]... it's not completely spelt backwards... it's not as in Bash or Algol.
Performance-wise I'm not very happy with the Python implementation as I find it too slow for real-time use
depends on how many times you need to use it per second. I don't see why Python would not be fast enough unless you process literally thousands of notes per second... (no?) but then I haven't tried pyext.
Mathieu Bouchard -=- Montréal QC Canada -=- http://artengine.ca/matju
Hi Niklas,
I have already implemented exactly what you have described as an external called 'spectonote' written in C. It can be found at www.postlude.co.uk/download.
I apologise profusely for not announcing this properly on the list, and adding it to the pdb (which I have now done). The code can be implemented very easily in vanilla pd, so I assumed no-one would be interested. Obviously I was wrong.
I should also change the name to fton (frequency to note) to fit in with convention.
Regards,
Jamie
On Thu, 2004-11-25 at 13:29, Niklas Saers wrote:
Hi Mathieu,
Mathieu Bouchard wrote:
Candid question: what's the advantage of that over the builtin [mtof] class?...
Mea culpa, I have not used expr much, so when I copied your example below into Pd I got "no such var 'fl'" when using ftom (I expected this was what you wanted as the idea was going from a frequency to a number representation of the note). Using motf I get a syntax error.
The advantage of the implementation is that it really makes it easy to make other scales. Most litterature on tempered scales I've read starts with the equal tempered scale and says how many cent certain tones deviate from the equal tempered scale. Thus, with this basis it's rather simple to make a meantone, werkmeister, valotti, kirnberger and other scales. That's where I'm heading next. (just need to dig up the books again and get an exam passed) :-)
Would you check if your solution described below works and possibly send me a Pd file with it? I'd really like to try it out. Performance-wise I'm not very happy with the Python implementation as I find it too slow for real-time use and need to make it less responsive by use of a metro or similar for my hardware, so I'm considering rewriting it in C.
Cheers
Nik
PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://iem.at/cgi-bin/mailman/listinfo/pd-list
On Sat, 27 Nov 2004, Frank Barknecht wrote:
(caveat: ideally, % and int would be replaced by mod and floor, but the latter aren't in pd afaik)
"mod" is, AFAIK.
But there is no trivial way to make a flooring division, which is the complementary operation of mod.
The basic pattern of decomposing X into An+B where A,B are integers and B is taken from a finite set, is typically done in two ways, one being done with % and / and int, and the other being done with mod and / and floor. But floor is missing. If you use mod with int then you are getting results not consistent with the usual X=An+B assumption, which is not nice.
Or is floor available under another name?
Mathieu Bouchard -=- Montréal QC Canada -=- http://artengine.ca/matju
I read:
Or is floor available under another name?
I made (very simple) ceil and floor objects a while ago:
http://test.pilot.fm/pd/externs/ceilfloor.tar.gz
regards,
x
Pd offers a 'div' which should perhaps have been named 'floor'. It does 'correct' integer division so that Y = X * div(Y,X) + mod(Y,X).
cheers Miller
On Sat, Nov 27, 2004 at 01:56:18PM -0500, Mathieu Bouchard wrote:
On Sat, 27 Nov 2004, Frank Barknecht wrote:
(caveat: ideally, % and int would be replaced by mod and floor, but the latter aren't in pd afaik)
"mod" is, AFAIK.
But there is no trivial way to make a flooring division, which is the complementary operation of mod.
The basic pattern of decomposing X into An+B where A,B are integers and B is taken from a finite set, is typically done in two ways, one being done with % and / and int, and the other being done with mod and / and floor. But floor is missing. If you use mod with int then you are getting results not consistent with the usual X=An+B assumption, which is not nice.
Or is floor available under another name?
Mathieu Bouchard -=- Montréal QC Canada -=- http://artengine.ca/matju
PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://iem.at/cgi-bin/mailman/listinfo/pd-list
Hallo, Miller Puckette hat gesagt: // Miller Puckette wrote:
Pd offers a 'div' which should perhaps have been named 'floor'. It does 'correct' integer division so that Y = X * div(Y,X) + mod(Y,X).
I didn't know "div" so far. I see, that it has no help file, or rather, that the math help file is missing "div" and "mod", too.
Frank Barknecht _ ______footils.org__
On Sat, 27 Nov 2004, Miller Puckette wrote:
Pd offers a 'div' which should perhaps have been named 'floor'. It does 'correct' integer division so that Y = X * div(Y,X) + mod(Y,X).
Well, in C/C++, floor is a function with only one argument, and in Ruby it's a method of the Float class with zero arguments, and that covers pretty much everything called "floor" that I am aware of, so it shouldn't be called floor; there's the special case [div 1] which would be a special case of floor, but the rest doesn't follow: the only other argument I could imagine to floor that would make sense would be a granularity setting, like:
| [div g] | [* g] |
The defining feature of floor(x,g) being that x=floor(x,g) exactly when x is a multiple of g. This is most especially useful (and usual) as floor(x,0.01) for rounding to two decimals, or floor(x,pow(10,-n)) for rounding to n decimals.
Mathieu Bouchard -=- Montréal QC Canada -=- http://artengine.ca/matju