Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
8bit_chiptune:sn76489 [2019/11/19 15:59] admin [4. SN76489 registers] |
8bit_chiptune:sn76489 [2019/11/19 16:14] admin [7. Playing samples on the SN76489] |
||
---|---|---|---|
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: | ||
- | -___ | + | +-___ |
- | -----+ | + | -----+ |
- | | + | |
- | - - - - -|-___-----+- - - - -|-___---------------+- - - - -|-___-----+- | + | +- - - - -|-___-----+- - - - -|-___---------------+- - - - -|-___-----+- |
- | | + | |
- | The empirical effects are: | + | The empirical effects are:\\ |
- | - The sound of tones is changed very slightly | + | - The sound of tones is changed very slightly\\ |
- | - Noise sounds a bit louder | + | - Noise sounds a bit louder\\ |
- | - Voices sound slightly different | + | - Voices sound slightly different\\ |
Some games were programmed with the SN76489 considered to be a perfect | Some games were programmed with the SN76489 considered to be a perfect | ||
Line 526: | Line 526: | ||
- | 6.1 Noise volume | + | === 6.1 Noise volume === |
- | ================ | + | |
As previously described, the noise output is either 0 or +1, multiplied | As previously described, the noise output is either 0 or +1, multiplied | ||
Line 542: | Line 541: | ||
noise volume when mixing the channels together. | noise volume when mixing the channels together. | ||
- | + | ---- | |
- | 7. Playing samples on the SN76489 | + | ==== 7. Playing samples on the SN76489 ==== |
- | ================================= | + | |
This is for the reference of those wishing to put sample playback in | This is for the reference of those wishing to put sample playback in | ||
Line 551: | 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 | + | |
- | 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 | + | |
- | tone channels to give more output levels, but this additional | + | |
- | | + | |
- | | + | |
- | 2. Pulse Width Modulation | + | 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). |
- | This works by outputting pulses at constant volume whose pattern | + | One could use the combined logarithmic volume levels |
- | | + | |
- | how samples are played on PC internal speakers and some CD players. | + | |
- | | + | |
- | 1. Setting all 3 tone channels to frequency 0x000 | + | === 2. Pulse Width Modulation === |
- | 2. At rapid, closely timed intervals, setting | + | This works by outputting pulses at constant volume whose pattern gives the effect |
- | all 3 to either 0xf (off) or 0x0 (full) depending | + | |
- | stored in ROM. | + | |
- | All three channels | + | 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 | ||
- | This is equivalent | + | All three channels are used to get maximum volume. |
- | | + | |
- | an 8kHz 8-bit sample can be output as a 64kHz 1-bit sample and it | + | |
- | 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 | + | This is equivalent |
- | | + | |
- | 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 | + | |
- | etc. This can be severely limiting for the qaulity. | + | |
- | | + | 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 unintelligible, for example Alex Kidd: the Lost Stars' " | + | |
- | the Miracle Ball" | + | |
- | | + | |
+ | On the Master System, PWM is not very good quality (often the sound is unintelligible, | ||
- | 8. Game Gear stereo extension | + | ---- |
- | ============================= | + | ==== 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 |