Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
8bit_chiptune:sn76489 [2019/11/19 16:05] admin [6. The imperfect SN76489] |
8bit_chiptune:sn76489 [2019/11/19 16:16] (current) admin [8. Game Gear stereo extension] |
||
---|---|---|---|
Line 466: | Line 466: | ||
waves from this: | waves from this: | ||
- | | + | +---------+ |
- | | | + | |
- | | | + | |
- | - - - - -|- - - - -|- - - - -|- - - - -|- - - - -|- - - - -|- - - - -|- | + | +- - - - -|- - - - -|- - - - -|- - - - -|- - - - -|- - - - -|- - - - -|- |
- | | | + | |
- | | | + | |
- | +---------+ | + | |
to something like this: | to something like this: | ||
- | -___ | + | |
- | | + | -----+ |
- | | | + | |
- | _ _ _ _ _|_ _ _ _ _|_ _ _ _ _|_ _ _ _ _|_ _ _ _ _|_ _ _ _ _|_ _ _ _ _|_ | + | +_ _ _ _ _|_ _ _ _ _|_ _ _ _ _|_ _ _ _ _|_ _ _ _ _|_ _ _ _ _|_ _ _ _ _|_ |
- | | | + | |
- | | | + | |
- | | ___-----+ | + | |
- | +- +- +- +- | + | |
If the tone register value is large enough, they will decay close to | If the tone register value is large enough, they will decay close to | ||
Line 497: | Line 497: | ||
- | | + | +----+ +----+ |
- | - - | - -|- - | - -|- - | - -|- - | - -|- - | - -|- - | - -|- - | - -|- | + | + - - | - -|- - | - -|- - | - -|- - | - -|- - | - -|- - | - -|- - | - -|- |
- | | + | |
Perfect output (assuming output bit pattern of 10100101): | Perfect output (assuming output bit pattern of 10100101): | ||
- | | + | +---------+ |
- | | | + | |
- | | | + | |
- | - - - - -+---------+- - - - -+-------------------+- - - - -+---------+- | + | +- - - - -+---------+- - - - -+-------------------+- - - - -+---------+- |
Actual output: | Actual output: | ||
- | | + | +-___ |
- | | + | -----+ |
- | | | + | |
- | - - - - -|-___-----+- - - - -|-___---------------+- - - - -|-___-----+- | + | +- - - - -|-___-----+- - - - -|-___---------------+- - - - -|-___-----+- |
- | +- +- +- | + | |
Line 549: | Line 549: | ||
It is possible to play samples in two ways: | It is possible to play samples in two ways: | ||
- | 1. Pulse Code Modulation | + | === 1. Pulse Code Modulation |
- | This is the usual way to store, process and output waves. The data is | + | This is the usual way to store, process and output waves. The data is in the form of voltages (corresponding to the desired speaker position which in turn goves corresponding pressure waves in the air) which are stored digitally, often as 16-bit or 8-bit signed numbers. |
- | in the form of voltages (corresponding to the desired speaker | + | |
- | position which in turn goves corresponding pressure waves in the air) | + | |
- | which are stored digitally, often as 16-bit or 8-bit signed numbers. | + | |
- | On the SN76489, this is done by: | + | On the SN76489, this is done by:\\ |
+ | 1. Setting all 3 tone channels to frequency 0x000\\ | ||
+ | 2. At rapid, closely timed intervals, setting the output volume of all 3 to values stored in ROM.\\ | ||
- | 1. Setting all 3 tone channels to frequency 0x000 | + | In other words, the volume setting is used as a 4-bit DAC. All three tone channels |
- | 2. At rapid, closely timed intervals, setting the output | + | |
- | all 3 to values stored in ROM. | + | |
- | In other words, the volume setting is used as a 4-bit DAC. All three | + | The problem is that the output levels of the SN76489 are not linearly scaled: |
- | tone channels are usually used together to get maximum volume. | + | |
- | + | ||
- | The problem is that the output levels of the SN76489 are not linearly | + | |
- | scaled: | + | |
| | ||
| ||||| | | | | | | ||||| | | | | | ||
- | The source wave could be prepared with this in mind, using some | + | The source wave could be prepared with this in mind, using some specialised software, but I am not aware of any consumer-level wave editor capable of doing this. However, ignoring this and outputting " |
- | specialised software, but I am not aware of any consumer-level wave | + | |
- | editor capable of doing this. However, ignoring this and outputting | + | |
- | " | + | |
- | significantly quieter than it would be on a linear scale. | + | |
- | The quality depends on the rate at which data is sent to the chip; on | + | The quality depends on the rate at which data is sent to the chip; on most systems, the limit is more likely to be memory space than CPU speed (8kHz 4-bit audio will fit 4.1 seconds into 16KB). |
- | most systems, the limit is more likely to be memory space than CPU | + | |
- | speed (8kHz 4-bit audio will fit 4.1 seconds into 16KB). | + | |
- | One could use the combined logarithmic volume levels of the three | + | One could use the combined logarithmic volume levels of the three tone channels to give more output levels, but this additional complexity may not be worth the effort and the space these 12-bit samples would take up; it seems not to be found in existing software. |
- | tone channels to give more output levels, but this additional | + | |
- | complexity may not be worth the effort and the space these 12-bit | + | |
- | samples would take up; it seems not to be found in existing software. | + | |
- | 2. Pulse Width Modulation | + | === 2. Pulse Width Modulation |
+ | This works by outputting pulses at constant volume whose pattern gives the effect of different frequencies and volumes. This is also how samples are played on PC internal speakers and some CD players. | ||
- | This works by outputting pulses at constant volume whose pattern | + | On the SN76489, this is done by:\\ |
- | gives the effect of different frequencies and volumes. This is also | + | 1. Setting all 3 tone channels to frequency 0x000\\ |
- | how samples are played on PC internal speakers and some CD players. | + | 2. At rapid, closely timed intervals, setting the output volume of all 3 to either 0xf (off) or 0x0 (full) depending on valuues stored in ROM.\\ |
- | On the SN76489, this is done by: | + | |
- | 1. Setting all 3 tone channels to frequency 0x000 | + | All three channels |
- | 2. At rapid, closely timed intervals, setting the output | + | |
- | all 3 to either 0xf (off) or 0x0 (full) depending on valuues | + | |
- | stored in ROM. | + | |
- | All three channels are used to get maximum volume. | + | This is equivalent |
- | | + | The advantage of this is that it allows for a sample based on a linear PCM scale to be output accurately on the SN76489, (allowing for louder sounds) and it can potentially output any bitdepth source audio. The disadvantage is that, with a limited output rate, one is forced to trade off between the bitdepth and sampling rate of the input sample: with a maximum output rate of 20kHz, for example, one may choose a 6.67kHz 3-bit source |
- | | + | |
- | an 8kHz 8-bit sample | + | |
- | will sound much the same. It is somewhat dependent on the output | + | |
- | | + | |
- | The advantage of this is that it allows for a sample based on a | + | On the Master System, PWM is not very good quality |
- | | + | |
- | for louder sounds) and it can potentially output any bitdepth source | + | |
- | | + | |
- | | + | |
- | input sample: with a maximum output rate of 20kHz, for example, one | + | |
- | may choose a 6.67kHz 3-bit source sample, a 5kHz 4-bit source sample, | + | |
- | etc. This can be severely limiting for the qaulity. | + | |
- | On the Master System, PWM is not very good quality (often the sound | + | ---- |
- | is unintelligible, | + | ==== 8. Game Gear stereo extension ==== |
- | the Miracle Ball" and Shooting Gallery' | + | |
- | | + | |
- | + | ||
- | + | ||
- | 8. Game Gear stereo extension | + | |
- | ============================= | + | |
When a byte is written to port 0x06 on the Game Gear, the SN76489 | When a byte is written to port 0x06 on the Game Gear, the SN76489 | ||
Line 641: | Line 605: | ||
outputs to rhe left side only, etc. | outputs to rhe left side only, etc. | ||
- | + | ---- | |
- | Maxim | + | |
- | maxim@mwos.cjb.net | + | |
- | 27/4/2005 | + | |
- | + | ||
- | Updated 6/6/2002: | + | |
- | Clarification that SN76489 tones update immediately after latch byte. | + | |
- | Use of 2-stage volume writes found. | + | |
- | + | ||
- | Updated 22/ | + | |
- | Charles MacDonald sampled GG and Genesis noise for me, it's the same | + | |
- | bit pattern as SMS noise. | + | |
- | + | ||
- | Updated 20/ | + | |
- | Fixed some typos. | + | |
- | + | ||
- | Updated 21/ | + | |
- | Added SC-3000H noise feedback pattern, thanks to Charles MacDonald for | + | |
- | getting the data for me. | + | |
- | + | ||
- | Updated 21/ | + | |
- | Charles MacDonald sampled SMS1 noise, it's the same bit pattern as the | + | |
- | SMS2, GG and Genesis. | + | |
- | + | ||
- | Updated 27/ | + | |
- | Added sections on 15-bit shift registers and volume/ | + | |
- | sections tweaked, clarified, corrected and extended. | + | |
- | + |