Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /storage/content/49/145849/famitracker.com/public_html/forum/classes/dbHandler.php on line 29 FamiTracker
Login:
Menu:
Post: Author:
FamiTracker > General > FamiTracker Talk > Question about Pxx Pitch effect Owner: clerian New post
Page 1 of 1 Sort:  
Question about Pxx Pitch effect Posted: 2012-02-17 21:31 Reply | Quote
clerian



Member for: 3786 days
Location: California
Status: Offline

#30492
Hello again!

I was taking apart a bunch of NSFs with the NSFImport tool (thanks Rainwarrior!), and after examining them, I've noticed that every note has a Pxx effect applied to it. It's clear that in many cases, it is being used as vibrato, and that makes sense.

The thing I don't understand is why it is being used for every note. Does this have to do with [url=http://en.wikipedia.org/wiki/Musical_temperament]musical temperament?

I did do a search on the forums for Pxx and pitch, and understand that the frequency registers are discrete and logarithmic in scale (meaning we can only approximate the pitch of notes in the diatonic scale and there is a bias of resolution on one end of the frequency spectrum), but unless composers are writing music in just intonation or something, I don't really see why they would be detuning every note in the whole song.

Are the old video game composers writing to different temperaments, or is there some other reason why they're using pitch like that?

Posted: 2012-02-17 21:47  (Last Edited: 2012-02-17 21:52) Reply | Quote
rainwarrior

Avatar

Member for: 4150 days
Location: Canada
Status: Offline

#30493
No, in general NES games are written with equal temperament in mind. There are a number of variations to equal temperament though. Here are some of the most likely differences:

1. Rounding. You need to round your intended pitch to the nearest NES register integer value. Some may have rounded up, rounded down, or rounded >= 0.5 up, < 0.5 down.

2. A440 is FamiTracker's reference pitch, but this is an arbitrary choice.

3. If the game was written for PAL territories first, they may not have converted their pitch table when making an NTSC version. This has the same result as #2, because the NTSC chip runs at a different clock speed.

Inside almost every NES ROM is a table of pitches mapping notes in the 12-tone scale to NES register numbers. So, most composers when they write their music are thinking in equal tempered notes, e.g. "C-4", and their playback engine looks up in that table what number to use for playback. There are many numbers in between that are used when applying vibrato or sliding.

So... how this table is generated is up to the programmer.

Posted: 2012-02-17 22:02 Reply | Quote
clerian



Member for: 3786 days
Location: California
Status: Offline

#30495
Ahhhh, they had to write their own pitch tables. That makes a LOT more sense why there is so much variation between NSFs.

Posted: 2012-02-17 22:08 Reply | Quote
jrlepage
Moderator

Avatar

Member for: 4982 days
Location: Canada
Status: Offline

#30496
As nothing more than a curiosity - bearing in mind I haven't checked on this - I think I remember reading that the game with the closest pitch table to FamiTracker's was none other than Super Mario Bros. Could be wrong though.

Posted: 2012-02-17 22:16 Reply | Quote
rainwarrior

Avatar

Member for: 4150 days
Location: Canada
Status: Offline

#30497
I was really surprised to find that most games are only off by 1 (P7F/P81) most of the time, which suggests that A440 was widely used, but rounding methods weren't consistent.

Also, I would suspect that Nintendo may have provided an example pitch table in their development guide that a lot of people just copy-pasted. (Or people sharing code, etc.)

Posted: 2012-02-17 23:37 Reply | Quote
clerian



Member for: 3786 days
Location: California
Status: Offline

#30498
Interesting. Most of the NSFs I've been looking at have much larger variation than that. One song I've been looking at goes to P73, and it seems the lower the note, the larger the variance in pitch. P73 is the largest variance I've observed, but many other songs I've been looking at will vary by up to 4.

Posted: 2012-02-18 00:21  (Last Edited: 2012-02-18 00:23) Reply | Quote
Dwedit

Avatar

Member for: 4972 days
Location: Chicago
Status: Offline

#30501
Maybe people were forgetting to add/subtract 1 while using the pitch formula.

For NTSC:
F = 111860.7917 / (P + 1)
P = (111860.7917 / F) - 1

For PAL, use 103912.9375 instead. For Dendy, use 110840.5 instead (similar to NTSC, but off by a little)

Some developers made their pitch tables by ear, and got several notes off by a bit.

Posted: 2012-02-18 10:56 Reply | Quote
nicetas_c



Member for: 4583 days
Location: AB, CA
Status: Offline

#30521
FamiTeacker's pitch table was based on Super Mario Bros. 1 until 0.3.5. beta. Whether the current pitch table is based on another game is unknown.

Posted: 2012-02-18 11:34  (Last Edited: 2012-02-18 11:44) Reply | Quote
rainwarrior

Avatar

Member for: 4150 days
Location: Canada
Status: Offline

#30522
The pitch table in FamiTracker is calculated at startup based on A440. It's not based on any game.

The calculation for it now is different than it used to be (it's more accurate and uses neutral rounding), but looking at the source as far back as it goes (0.2.2), it doesn't look like it was ever based on a game. It's always based on some way of calculating equal temperament at A440, and says so in the comments.

Page 1 of 1 Sort: