![]() |
DevelopmentSega Master System / Mark III / Game Gear |
Home - Forums - Games - Scans - Maps - Cheats |
Sega8bit & SMS Power! 2013 Event - 10th August 11 weeks and 3 days from now
This is for the reference of those wishing to put sample playback in their demos, and for those whose sound core doesn't do voices. Emulator authors may wish to add implementation suggestions.
Sample playback is possible on the SN76489 but not the YM2413 FM chip.
It is possible to play samples in two ways:
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 gives corresponding pressure waves in the air) which are stored digitally, often as 16-bit or 8-bit signed numbers.
On the SN76489, this is usually done by:
In other words, the volume setting is used as a 4-bit DAC. All three 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 | ||||| | | | | | | | | | |SN76489
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.
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).
Instead of setting the volumes on all three tone channels in unison, it is possible to instead set the levels on all three independently. In theory this allows for 816 unique output levels, although they are not distributed regularly or linearly, and are concentrated in the lower half of the waveform; this is equivalent to about 9.7 bits of resolution (but "costs" 12 bits per sample for storage).
If only two channels are used (so the source can be 8 bits per sample rather than 12, to save ROM space), 136 unique levels are possible (7.1 bits of resolution), which seems to be a better trade-off. By outputting 4 bits to two channels and the other 4 bits to the third, the volume range for this 8-bit variation can be boosted at the expense of the uniformity of coverage.
No known software uses this technique.
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. On the SN76489, this is done by:
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.
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 sample, a 5kHz 4-bit source sample, etc. This can be severely limiting for the quality. (Note: the output limit, 20kHz in this example, has yet to be determined for the SMS and will vary depending on how the data is encoded and the playback efficiency.)
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.