|
ForumsSega Master System / Mark III / Game GearSG-1000 / SC-3000 / SF-7000 / OMV |
Home - Forums - Games - Scans - Maps - Cheats - Credits Music - Videos - Development - Hacks - Translations - Homebrew |
Author | Message |
---|---|
|
Tuning the PSG to itself
Posted: Wed Jun 11, 2008 5:43 pm Last edited by Maxim on Wed Aug 19, 2009 4:28 pm; edited 1 time in total |
As you may know, the PSG's not-quite-1024 possible frequencies are based on the wavelength of the sound produced. This does not map linearly to the 12-tone equal temperament scale commonly used by musicians, which is logarithmic compared to wavelength or frequency. In particular, the PSG's resolution is relatively poor at high frequencies - a change of 1 produces ~3 semitones difference, compared with about 0.005 semitones - aka 0.5 cents - at the low end.
Thus, any mapping of a musical scale onto the PSG will always be somewhat "out of tune". This doesn't matter so long as it's not trying to be in tune with something else, or so long as the amount it's out of tune is very small. Wikipedia says a trained musician can only hear a difference of 5-6 cents. In particular, an exact octave difference can normally be represented on the PSG with relatively high accuracy, so the most noticeable cases are less bad. You can see a mapping to the standard notes here: http://www.smspower.org/maxim/forumstuff/psgtable.html There is a concept of "tuning something to itself", whereby it's not matching the standard (where A4 = 440Hz), but instead it's off-tune in a way that allows it to overall be more self-consistent in its tuning. I wondered if the PSG could be "tuned" this way. I made an unpublished modification of that page that, rather than using the standard A4=440Hz, ran through many possible values, from 415 to 467Hz (one semitone flat to 1 semitone sharp), in small steps. For each it calculated the RMS error, to find the value for A4 that produces the most self-consistent musical scale, for the lowest 5 octaves of the PSG (to exclude the always-pretty-bad higher frequencies). The result is: A4 = 436.67Hz produces an RMS error of 4.346 cents compared to 6.166 cents at the "standard" 440Hz tuning. So: for the lowest 5 octaves of the PSG, this is the best reference point to minimise the average out-of-tune-ness. However, even if you chose the very worst one, a trained musician would struggle to hear it, on average. But we're not dealing with averages; if all the notes are in tune but one, it'll have a low RMS and sound awful. So I ran another analysis that looked for the tuning that minimised the biggest out-of-tune-ness in the first 5 octaves. This gives the result: A4 = 437.23Hz has a maximum error of 12.6 cents; the worst case is about 25 cents. At 440Hz the maximum is 17.2 cents, at 436.67 it's 14.8. So, what's the conclusion? Whatever tuning standard you use, they're all pretty bad; 440Hz and the two results I gave above are all good ones to use, for various reasons, but the difference between them is not very much. |
|
|
Tuning the PSG to itself
Posted: Thu Jun 12, 2008 3:30 am
|
"Tuning the PSG to itself" makes perfect sense (unless you're going to have the SMS playing in an ensemble of other instruments of computers) there should be less dissidents between the 3 notes produced by the PSG using this method, over using register values 'as close to' the actual musical note frequencies.
There are also other techniques to reduce dissidents, like applying a gentle vibrato to extended notes. This technique is used by string instrument players like violinists. |
|
|
Posted: Thu Jun 12, 2008 8:18 am |
Yeah, but I was somewhat surprised at how little difference it makes to do so.
Certainly, if you can customise the vibrato for each note to take consideration of its error (effectively, making the average frequency be dead-on by distributing between the available values appropriately) it'd be a big help. But if you can really get away with 5-6 cents then you don't really need to care for at least the bottom 4 octaves. Maybe that's the source for the old inaccurate "4 octaves range" spec? |
|
|
Posted: Thu Jun 12, 2008 1:27 pm |
Since the PSG is poor at low frequencies (not accurycy-wise, but it just can't do them) I often change the tone to be able to just include the lowest frequency I need.
Last time I ended up with A slightly above 490Hz. Which is okay to me since it was a piece from Johann Sebastian Bach and as far as we know today (from the still existing organs he used) he placed A at about 480Hz. The pitch has changed a lot in the past. Today the standard is A at 440Hz, most professional musicians use 442 or 443 Hz, historically i varied between 380 and 480 Hz. Philipp |
|
|
Posted: Thu Jun 12, 2008 2:03 pm |
And here I was thinking the scales never changed. | |
|
Posted: Thu Jun 12, 2008 5:59 pm |
No, not at all. Do we really know the Hz from Bach's time? I mean, they went with a different type of temperament then because they simply didn't have the science to pull anything else off. However, it should be noted, well temperament was and still is considered superior by some musicians. I always wonder what Clavier sounded like in its intended temperament. I wonder if applying well to this problem would lead to a solution? It could perhaps lead to a more accurate system. I want to do some work on this when I get to it, and since I have perfect pitch maybe I can come up with something more usable and defined so there's little error going from a musical arrangement to the PSG. Any error could possibly be accomodated for easily if it would work out as I think it could. | |
|
Posted: Fri Jun 13, 2008 12:31 am |
Can I have your perfect pitch? As a musician myself I have been showing a lot of interest in this thread. Stan how do you clock the PSG to play lower frequencies, and is it possible to do this in Martins tracker? Thanks |
|
|
Posted: Fri Jun 13, 2008 8:46 am |
The PSG can't play lower frequencies (unless you go for periodic noise...), what he describes is the same as transposing the music you have up by just enough to let the lowest note equal the 109.35Hz that's the lowest regular tone the PSG can play. I have no idea if you can make Mod2PSG2 do that for you.
It is true that 12-TET is a fairly modern concept and there's plenty of music that wasn't composed for it; but if you're going to try to use it, you're going to have to be pretty musically talented as well as able to make a matching music engine. |
|
|
Posted: Fri Jun 13, 2008 11:35 am |
Jacko,
You can't do that in Mod2PSG2, except if you manually do the transposing+detuning. But it would be a nice feature I think. Maxim, what would it look like if you made a graph with RMS and out-of-tune-ness (on Y-axis) for a range of A4 frequencies (on X-axis)? Would that give a useful graph to search for a good compromise between RMS and out-of-tune-ness? |
|
|
Posted: Fri Jun 13, 2008 12:51 pm |
As you can see, it's periodic across a semitone, due to the logic that is looking only at the lowest 60 notes that can be produced. The max error trough at 437.2 lines up pretty well with a low RMS error. Edit: I wasted a lot of time in Excel now. Depending on how you weight the errors, you can get different results, but they're all close to 437.2. Spreadsheet attached. |
|
|
Posted: Sun Jun 15, 2008 4:49 pm |
Just so you know, I haven't actually started working the PSG yet, that was just an idea that popped in my head. When I work on it I'll see what I come up with, but I need to become uber familiar with it, like I did my drum machine. Once I figured out the inner workings of that computer, 2 on 3 became my bitch. | |
|
Posted: Sun Jun 15, 2008 5:39 pm |
Speaking of all this music, I doubt not, but if you h haven't, you should check out what some guy (I think from here) did withthis. | |
|
Posted: Sun Jun 15, 2008 5:52 pm |
So I'd like to mess around, but I'm a bit confused. I swear I found a link before to some program you can use to write SMS music. If this is merely a dream of mine that I remember as reality, can someone give me a link to a program that I can use to ONLY program music? Perhaps there is something I can use so I can hear tones as I work with them, similar to drum machine programs like Fastrack? | |
|
Posted: Sun Jun 15, 2008 6:22 pm |
MOD2PSG2 is something you can use to make music for GG/SMS... | |
|
Posted: Mon Jun 16, 2008 12:34 am |
That's the link I was looking for originally, thanks a bunch. | |
|
Posted: Tue Jun 17, 2008 2:55 pm |
Well, finally downloaded the PSG and had a chance last night to start working on it. Reminds me of my drum machine, and with that in mind, I will, in time, be able to TOTALLY destroy this thing. I was able to make a track last night and mixed some tunes with brief noise tones for an awesome effect. At any rate, it gave me a chance to compare this whole tuning issue. Really, as a musician whose been clasically trained for over 10 years, I found it quite easy to take something I wrote and put it to the PSG, it just takes a little tweaking to get it close, and when you do there's hardly any difference from even tempered tuning. If you have an ear for music, you can easily put your songs on this thing with no problem. | |
|
Posted: Tue Jun 17, 2008 4:31 pm |
Also, does anyone know of a good overview guide of how this thing works in detail? I'd hate to have to trudge through figuring out another piece of technology without some sort of manual. Just a simple thing describing how everything works is all I need. If not, whatever, I'll figure it out. | |
|
Posted: Tue Jun 17, 2008 5:44 pm |
I'm not sure what you're referring to, given that the thread is somewhat off-topic. How to use a tracker? How the PSG works? How to write a music engine? Feel free to start a new topic if it feels like something worth sharing/discussing. | |
redman
|
Posted: Fri Oct 03, 2008 5:36 pm |
Hi guys,
I was just doing scale mappings for the psg all day and then i found this thread. It's nice to see other people busy with the same concerns :) Anyway, i'm doing this stuff because i'm writing a tracker/player for MSX. What interested me was that people mention the psg cannot go lower than 109Hz or so. This does not seem the case for me! I can go almost 2 octaves lower (altho you would be just above 27Hz with that which is nt very usefull, especially because the output is a square and the harmonics will dominate heavily) Sounds in the 54Hz~109Hz octave sound good to me, although typical squarish. I was wondering, is there something about the SMS that prevents you from setting the full 12 bits of the registers? |
|
|
Posted: Fri Oct 03, 2008 5:42 pm |
Yes, it's only 10 bits ;) | |
redman
|
Posted: Fri Oct 03, 2008 6:33 pm |
well, makes sense then :)
thanks for the info! |
|
|
Posted: Thu Aug 13, 2009 9:11 am |
For completeness, here's the values used by most SMS games:
PSG Freq /Hz Nearest note MIDI name Error /cents
1023 109.346 45 A2 -10.3 967 115.678 46 A#2 -12.9 912 122.654 47 B2 -11.5 861 129.920 48 C3 -11.9 813 137.590 49 C#3 -12.6 767 145.842 50 D3 -11.7 724 154.504 51 D#3 -11.8 683 163.779 52 E3 -10.9 645 173.428 53 F3 -11.8 609 183.679 54 F#3 -12.4 575 194.540 55 G3 -12.9 542 206.385 56 G#3 -10.6 512 218.478 57 A3 -12 483 231.596 58 A#3 -11.1 456 245.309 59 B3 -11.5 431 259.538 60 C4 -13.9 406 275.519 61 C#4 -10.4 384 291.304 62 D4 -14 362 309.008 63 D#4 -11.8 342 327.078 64 E4 -13.4 323 346.318 65 F4 -14.5 304 367.963 66 F#4 - 9.5 287 389.759 67 G4 - 9.9 271 412.770 68 G#4 -10.6 256 436.956 69 A4 -12 242 462.235 70 A#4 -14.7 228 490.617 71 B4 -11.5 215 520.283 72 C5 - 9.8 203 551.038 73 C#5 -10.4 192 582.608 74 D5 -14 181 618.015 75 D#5 -11.8 171 654.157 76 E5 -13.4 161 694.787 77 F5 - 9.1 152 735.926 78 F#5 - 9.5 144 776.811 79 G5 -15.9 136 822.506 80 G#5 -17 128 873.912 81 A5 -12 121 924.469 82 A#5 -14.7 114 981.235 83 B5 -11.5 108 1035.748 84 C6 -17.9 102 1096.674 85 C#6 -18.9 96 1165.216 86 D6 -14 91 1229.239 87 D#6 -21.4 85 1316.009 88 E6 - 3.3 81 1380.997 89 F6 -19.8 76 1471.852 90 F#6 - 9.5 72 1553.622 91 G6 -15.9 68 1645.011 92 G#6 -17 64 1747.825 93 A6 -12 60 1864.346 94 A#6 - 0.3 57 1962.470 95 B6 -11.5 54 2071.496 96 C7 -17.9 51 2193.349 97 C#7 -18.9 48 2330.433 98 D7 -14 45 2485.795 99 D#7 - 2.2 43 2601.414 100 E7 -23.5 40 2796.520 101 F7 + 1.7 38 2943.705 102 F#7 -9.5 36 3107.244 103 G7 -15.9 34 3290.023 104 G#7 -17 32 3495.649 105 A7 -12 30 3728.693 106 A#7 - 0.3 28 3995.028 107 B7 +19.2 27 4142.992 108 C8 -17.9 25 4474.431 109 C#8 +15.4 24 4660.866 110 D8 -14 22 5084.581 111 D#8 +36.7 21 5326.704 112 E8 +17.2 20 5593.039 113 F8 + 1.7 19 5887.410 114 F#8 - 9.5 18 6214.488 115 G8 -15.9 17 6580.046 116 G#8 -17 This seems to be based on tuning it so that the lowest note possible (PSG value 1023) is A2 (the nearest "correct" note) and trying to tune the rest of the notes to work with that, possibly with some dodgy rounding along the way. |
|