Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - Games out of tune?

Reply to topic
Author Message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14735
  • Location: London
Reply with quote
Games out of tune?
Post Posted: Sat Nov 10, 2001 5:21 pm
I've just finished adding interpretation to my VGM command lister... so it can read this:

50 8d 50 0f


and output this:


PSG: Freq 1
PSG: Freq 2: ch 0 -> 0x0fd = 442.13 Hz = A4 +8
^^^^^ ^^^^^^^^^ ^
PSG frequency data / Frequency Note, octave,
(actually number of in Hertz "cents"
clocks per half wave)


The thing is... the PSG has limited accuracy for notes, due to the way it works. You're highly unlikely to get an exact note, so the "cents" is likely to be a small amount (there are 100 cents between adjacent notes, so it can be up to 50). However, I have noticed that some games are way off... in particular, Alex Kidd in Miracle World is almost entirely off by 20 or 30 cents (for comparison, Green Hill is mostly <10 although some are also bad). Now, I'm about as musically inclined as a brick and I can't tell if a note's in tune or not, but if I was a musician type, wouldn't that be incredibly annoying? Or is it OK, just so long as the game is "tuned to itself" by maintaining a constant offset from the correct frequency?

Maxim
  View user's profile Send private message Visit poster's website
Shaka
  • Guest
Reply with quote
Post Posted: Sat Nov 10, 2001 7:03 pm
Quote
>
50 8d 50 0f


means nothing to me.. sorry..

Quote
> and output this:
>


> PSG: Freq 1
> PSG: Freq 2: ch 0 -> 0x0fd = 442.13 Hz = A4 +8
> ^^^^^ ^^^^^^^^^ ^
> PSG frequency data / Frequency Note, octave,
> (actually number of in Hertz "cents"
> clocks per half wave)
>




what you're asking is ?
if i play the entire song in a A4 442hz.. it wont sound weird..
but if only in determined notes you go a little up or down.. then well.. it will sound horrible.. like a screaming cat in a rainy night..

a few examples..

Rock And Roll All nite (KISS) is entire played in Ab - 450.. and its great.. :)

Enter Sandman (Metallica) is entire played in A - 440.. and its great also..

its just a different tunning..

in my guitar i use Ab Tuning (half step down, 440hz).

but all strings are half step down.. so it doesnt sound weird..

i hope i understood what you're asking.. if not.. then sorry.
but i have alanguage barrier to break when comes down to technical words. :)

Quote
> The thing is... the PSG has limited accuracy for notes, due to the way it works. You're highly unlikely to get an exact note, so the "cents" is likely to be a small amount (there are 100 cents between adjacent notes, so it can be up to 50). However, I have noticed that some games are way off... in particular, Alex Kidd in Miracle World is almost entirely off by 20 or 30 cents (for comparison, Green Hill is mostly <10 although some are also bad). Now, I'm about as musically inclined as a brick and I can't tell if a note's in tune or not, but if I was a musician type, wouldn't that be incredibly annoying? Or is it OK, just so long as the game is "tuned to itself" by maintaining a constant offset from the correct frequency?


question : are you saying that alex kidd vgm is 20,30 cents off tune by the real thing ?

if so.. that might explain a few things.. if not.. then i need more ear training. :)


--Shaka
 
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14735
  • Location: London
Reply with quote
Post Posted: Sat Nov 10, 2001 10:12 pm
Quote
> what you're asking is ?
> if i play the entire song in a A4 442hz.. it wont sound weird..
> but if only in determined notes you go a little up or down.. then well.. it will sound horrible.. like a screaming cat in a rainy night..

Ah, right... yes, I had difficulty phrasing it properly. What I meant was, if the entire track is (say) -20 cents, does it matter - answer, no. On the PSG you can't really avoid a variation of about 10 cents it would appear, because you're limited to certain values for the frequency which aren't spaced musically (it has linear wavelength variation giving 1/f distribution, musical notes are spaced logarithmically).

Also, I realised something else - a lot of PSG tracks use a bit of vibrato, mainly because it sounds a lot better than plain square waves. This would of course explain some of the variations, since vibrato will cause variation by less than a semitone (? correct word? Musical brick, remember).

Quote
> question : are you saying that alex kidd vgm is 20,30 cents off tune by the real thing ?

Yeah - it's mostly at about -20 to -30. Sonic is about -5. It looks like it was worth me figuring out the frequency to note conversion after all :)

(thinking out loud) I wonder how VGM2MID handles this effect?

Maxim
  View user's profile Send private message Visit poster's website
Paul Jensen (vgm2mid)
  • Guest
Reply with quote
With pitch wheel changes (more...)
Post Posted: Sun Nov 11, 2001 12:30 am
Quote
> (thinking out loud) I wonder how VGM2MID handles this effect?

Basically, vgm2mid finds the note closest to the one that matches the given frequency, and then uses MIDI pitch wheel events to give the correct tune. The end result is that every MIDI note event has a MIDI pitch wheel event preceeding it to create the 'exact' note. It seems odd that sound engine coders would use Hz values that differ from the 'standard' 440Hz=A4, but I guess that's the way most of them did it.

Here's a little more information just for kicks:

vgm2mid finds MIDI notes by dividing the log of the given frequency by the log of the 12th root of 2...

MIDINOTE = log(Hz) / log [2^(1/12)]

...this took me three years and a math class to figure out. There are twelve notes in an octave, which is why the 12th root is used. My lunch hour just ended, so I can't explain more right now.

Paul
 
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14735
  • Location: London
Reply with quote
3 years...
Post Posted: Sun Nov 11, 2001 10:27 am
Quote
> vgm2mid finds MIDI notes by dividing the log of the given frequency by the log of the 12th root of 2...

> MIDINOTE = log(Hz) / log [2^(1/12)]

> ...this took me three years and a math class to figure out. There are twelve notes in an octave, which is why the 12th root is used.

Or you could have done what I did... look online :) Here's what was on the page I found:

Freq2Midi converts a frequency to a MIDI note number using the following formula:

midi_note = (log(frequency) - log(freq_ref)) / log(2) * degrees + midi_ref

A fractional result is truncated to the integer below. By default, freq_ref, midi_ref and degrees default to 440.0 Hz, 69 and 12 to support standard western chromatic scale, but can be changed to support different transpositions or subdivisions of the octave.


Add a little simple maths and it's easy to convert this to A#5 etc. To get mathematical on you...

log(x^y) = y log x

so your equation is...

MIDINOTE = log(Hz) / log [2^(1/12)] = log(Hz) / [1/12 * log(2)] = log (Hz) / log (2) * 12

However, since I'm sure you only calculate log [2^(1/12)] once it's not necessary to simplify it like this, except that I think it looks simpler :)

The extra stuff in the quoted formula is so you get A4 440Hz = 69 which I believe is what MIDI likes. You can take the non-integer part and multiply by 100 to get cents too.

Maxim
  View user's profile Send private message Visit poster's website
  • Joined: 12 Jul 1999
  • Posts: 891
Reply with quote
Equal Temperament vs. Just Intonation
Post Posted: Mon Nov 12, 2001 2:57 pm
Quote
> The thing is... the PSG has limited accuracy for notes, due to the way it works. You're highly unlikely to get an exact note, so the "cents" is likely to be a small amount (there are 100 cents between adjacent notes, so it can be up to 50). However, I have noticed that some games are way off... in particular, Alex Kidd in Miracle World is almost entirely off by 20 or 30 cents (for comparison, Green Hill is mostly <10 although some are also bad). Now, I'm about as musically inclined as a brick and I can't tell if a note's in tune or not, but if I was a musician type, wouldn't that be incredibly annoying? Or is it OK, just so long as the game is "tuned to itself" by maintaining a constant offset from the correct frequency?

> Maxim

I had a little rant on the whole "Equal Temperament" and "Just Intonation" tuining systems in another thread a while back, so I'm not about to jump into it again :)

What it all boils down to is that if all the notes are off by the same amount (like tuning a guitar to Ab - which is really 415.305Hz), then it's OK - That's Equal Temperament (the circle of fifths - which only works for five octaves)
If there's variations in the distance between the semitones, then it could be intentional, as human musicians often change the 'tuning' of the note that they play ever so slightly (1/80th of a semitone is audible) so that it sounds 'better' and more 'in tune' with the other notes. ("Just Intonation")

Mind you, it's probably just a niggling feature of the SMS soundchip that it can't play actual notes. But I find it interesting that it can play floating-point frequencies (such as 442.13Hz) - my Amstrad CPC128 can't. Maybe you should be looking at other limits of the soundchip to see why it doesn't play certain notes?

~unfnknblvbl, BMus (in three years)
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14735
  • Location: London
Reply with quote
PSG note values
Post Posted: Mon Nov 12, 2001 10:20 pm
Quote
> Mind you, it's probably just a niggling feature of the SMS soundchip that it can't play actual notes. But I find it interesting that it can play floating-point frequencies (such as 442.13Hz) - my Amstrad CPC128 can't.

The PSG works by producing notes with wavelengths an integer number of clock cycles long. Divide 3576945 by 32, then by the PSG integer value to get the frequency in Hz.

Quote
> Maybe you should be looking at other limits of the soundchip to see why it doesn't play certain notes?

Well, these are its limits... :) I think some games deliberately use "off" notes (by less than a semitone) deliberately because careful choices can probably yield less variation in the "off"ness (10 or so cents, as I mentioned before).

Quote
> ~unfnknblvbl, BMus (in three years)

Maxim, BSc
  View user's profile Send private message Visit poster's website
  • Joined: 29 Jun 1999
  • Posts: 254
  • Location: California, USA; Hiroshima, Japan
Reply with quote
Re: 3 years...
Post Posted: Wed Nov 14, 2001 4:16 pm
Quote
> Add a little simple maths and it's easy to convert this to A#5 etc. To get mathematical on you...

> log(x^y) = y log x

Right.

Quote
> so your equation is...

> MIDINOTE = log(Hz) / log [2^(1/12)] = log(Hz) / [1/12 * log(2)] = log (Hz) / log (2) * 12

Is that a secret or something? That wasn't mentioned anywhere in my college algebra textbook. I don't remember my professor mentioning it, either. It works, though.

Quote
> The extra stuff in the quoted formula is so you get A4 440Hz = 69 which I believe is what MIDI likes. You can take the non-integer part and multiply by 100 to get cents too.

Yeah. That's basically what I'd been doing, anyway, but the code you posted surely helped a great deal. Thanks.

Paul

  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14735
  • Location: London
Reply with quote
Maths (OT)
Post Posted: Wed Nov 14, 2001 4:44 pm
Quote
> > log(x^y) = y log x

> Right.

> > so your equation is...

> > MIDINOTE = log(Hz) / log [2^(1/12)] = log(Hz) / [1/12 * log(2)] = log (Hz) / log (2) * 12

> Is that a secret or something? That wasn't mentioned anywhere in my college algebra textbook. I don't remember my professor mentioning it, either. It works, though.

Well... it's before college level (I think I did it at A-level here in the UK, whatever that is equivalent to). They probably expected you to know it. There's:

log (x^y) = y log x
log (xy) = log x + log y
log (x/y) = log x - log y

although I don't think the last two are much use to you.

Maxim
  View user's profile Send private message Visit poster's website
Reply to topic



Back to the top of this page

Back to SMS Power!