Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
8bit_chiptune:sn76489 [2019/11/19 16:08]
admin [6. The imperfect SN76489]
8bit_chiptune:sn76489 [2019/11/19 16:14]
admin [7. Playing samples on the SN76489]
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 +
-   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 +
-   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.+
  
-2Pulse 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 of the three tone channels to give more output levelsbut 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.
-   gives the effect of different frequencies and volumes. This is also +
-   how samples are played on PC internal speakers and some CD players. +
-   On the SN76489, this is done by:+
  
-   1Setting all 3 tone channels to frequency 0x000 +=== 2Pulse Width Modulation === 
-   2. At rapid, closely timed intervals, setting the output volume of +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.
-      all 3 to either 0xf (off) or 0x0 (full) depending on valuues +
-      stored in ROM.+
  
-   All three channels are used to get maximum volume.+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 either 0xf (off) or 0x0 (full) depending on valuues stored in ROM.\\
  
-   This is equivalent to dithering the sound to one bit per sample +All three channels are used to get maximum volume.
-   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.+
  
-   The advantage of this is that it allows for a sample based on a +This is equivalent to dithering the sound to one bit per sample instead of however many bits per sample are in the input data. Thusan 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.
-   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.+
  
-   On the Master SystemPWM is not very good quality (often the sound +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 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.
-   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.+
  
 +On the Master System, PWM is not very good quality (often the sound is unintelligible, for example Alex Kidd: the Lost Stars' "Find/I'm the Miracle Ball" and Shooting Gallery's "Perfect"), but it is the loudest way to play samples.
  
-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