Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
8bit_chiptune:sn76489 [2019/11/19 16:08]
admin [6. The imperfect SN76489]
8bit_chiptune:sn76489 [2019/11/19 16:16] (current)
admin [8. Game Gear stereo extension]
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.\\
  
-   1Setting all 3 tone channels to frequency 0x000 +In other words, the volume setting is used as a 4-bit DACAll three tone channels are usually used together to get maximum volume.
-   2. At rapid, closely timed intervals, setting the output volume of +
-      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:+
  
                                  | Linear                                  | Linear
    | ||||| | | |  |      |                             | SN76489    | ||||| | | |  |      |                             | SN76489
  
-   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 "normal" linear 4-bit data will generally sound good, but significantly quieter than it would be on a linear scale.
-   specialised software, but I am not aware of any consumer-level wave +
-   editor capable of doing this. However, ignoring this and outputting +
-   "normal" linear 4-bit data will generally sound good, but +
-   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 are used to get maximum volume.
-   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.+
  
-   All three channels are used to get maximum volume.+This is equivalent to dithering the sound to one bit per sample instead of however many bits per sample are in the input data. Thus, 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 frequency being above the range of hearing.
  
-   This is equivalent to dithering the sound to one bit per sample +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 20kHzfor example, one may choose a 6.67kHz 3-bit source sample5kHz 4-bit source sample, etcThis can be severely limiting for the qaulity.
-   instead of however many bits per sample are in the input data. Thus, +
-   an 8kHz 8-bit sample can be output as 64kHz 1-bit sample and it +
-   will sound much the sameIt is somewhat dependent on the output +
-   frequency being above the range of hearing.+
  
-   The advantage of this is that it allows for a sample based on a +On the Master SystemPWM is not very good quality (often the sound is unintelligiblefor example Alex Kidd: the Lost Stars' "Find/I'the Miracle Ball" and Shooting Gallery's "Perfect")but it is the loudest way to play samples.
-   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 thatwith 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 20kHzfor 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, for example Alex Kidd: the Lost Stars' "Find/I'+==== 8. Game Gear stereo extension ====
-   the Miracle Ball" and Shooting Gallery's "Perfect"), but it is the +
-   loudest way to play samples. +
- +
- +
-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/8/2002: +
-Charles MacDonald sampled GG and Genesis noise for me, it's the same +
-bit pattern as SMS noise. +
- +
-Updated 20/10/2002: +
-Fixed some typos. +
- +
-Updated 21/3/2003: +
-Added SC-3000H noise feedback pattern, thanks to Charles MacDonald for +
-getting the data for me. +
- +
-Updated 21/4/2003: +
-Charles MacDonald sampled SMS1 noise, it's the same bit pattern as the +
-SMS2, GG and Genesis. +
- +
-Updated 27/4/2005: +
-Added sections on 15-bit shift registers and volume/attenuation. Most  +
-sections tweaked, clarified, corrected and extended. +
- +