Sound Blaster 16: Difference between revisions

m
Bot: Replace deprecated source tag with syntaxhighlight
[unchecked revision][unchecked revision]
m (Bot: Replace deprecated source tag with syntaxhighlight)
 
(12 intermediate revisions by 8 users not shown)
Line 41:
|-
| 0xD0 || Stop playing 8 bit channel ||
|-
| 0xD4 || Resume playback of 8 bit channel ||
|-
| 0xD5 || Stop playing 16 bit channel ||
|-
| 0xD6 || Resume playback of 16 bit channel ||
|-
| 0xE1 || Get DSP version || major version/minor version
Line 76 ⟶ 80:
 
===Programming DMA===
ThisYou portscan areget formore channelinfo 1about (8programming bitDMA transfers),on if you want use another channel, checkpage [http://homepages.cae.wisc.edu/~brodskye/sb16doc/sb16doc.html] .
 
# Disable channel by writing to port 0x0A value (channel number + 0x04)
Programming 8 bit transfers throught channel 1 (channel number is 1):
# Disable channel by writing to port 0x0A value 0x05 (channel number + 0x04)
# Write value to flip-flop port 0x0C (any value e.g. 1)
# Send transfer mode to 0x0B (0x48 for single mode/0x58 for auto mode + channel number)
# Send page number to 0x83(page port of channel 1) For example if you have sound data at 0x100450, page is 0x10.
# Send low bits of position to port 0x02(posaddr. port of channel 1) For example(see above) is 0x50.
# Send high bits of position to port 0x02(posaddr. port of channel 1) For example(see above) is 0x04.
# Send low bits of lenghtlength of data to port 0x03(count port of channel 1) For example if is lenghtlength 0x0FFF, send 0xFF
# Send high bits of lenghtlength of data to port 0x03(count port of channel 1) For example if is lenghtlength 0x0FFF, send 0x0F
# Enable channel by writing channel number to port 0x0A
 
Programming 16 bit transfers throught channel 5 (channel number is 1 too):
# Disable channel by writing to port 0xD4 value 0x05 (channel number + 0x04)
# Write value to flip-flop port 0xD8 (any value e.g. 1)
# Send transfer mode to 0xD6 (0x48 for single mode/0x58 for auto mode + channel number)
# Send page number to 0x8B(page port of channel 5) For example if you have sound data at 0x100450, page is 0x10.
# Send low bits of position to port 0xC4(addr. port of channel 5) For example(see above) is 0x50.
# Send high bits of position to port 0xC4(pos. port of channel 5) For example(see above) is 0x04.
# Send low bits of length of data to port 0xC6(count port of channel 5) For example if is length 0x0FFF, send 0xFF
# Send high bits of length of data to port 0xC6(count port of channel 5) For example if is length 0x0FFF, send 0x0F
# Enable channel by writing channel number to port 0xD4
 
===Writing transfer mode to DSP===
Line 123 ⟶ 140:
# Reset DSP
# Load sound data to memory
# Set master volume
# Turn speaker on
# Program ISA DMA to transfer
# Set time constant. Notice that the Sound Blaster 16 is able to use sample rates instead of time constants using command 0x41 instead of 0x40. <br> You can calculate the time constant like this: Time constant = 65536 - (256000000 / (channels * sampling rate))
# Set time constant
# Set output sample rate
# Write transfer mode to DSP
# Write type of sound data
# Write data lenghtlength to DSP(Low byte/High byte) (You must calculate LENGHTLENGTH-1 e.g. if is your real lenghtlength 0x0FFF, you must send 0xFE and 0x0F)
 
==Code==
<sourcesyntaxhighlight lang="asm">
%macro OUTB 2
mov dx, %1
Line 174 ⟶ 192:
OUTB 0x22C, 0xC0 ;8 bit sound
OUTB 0x22C, 0x00 ;mono and unsigned sound data
OUTB 0x22C, 0xFE ;COUNT LOW BIT - COUNT LENGHTLENGTH-1 (EXAMPLE 0x0FFF SO 0x0FFE) - SET THIS VALUE FOR YOU
OUTB 0x22C, 0x0F ;COUNT HIGH BIT - COUNT LENGHTLENGTH-1 (EXAMPLE 0x0FFF SO 0x0FFE) - SET THIS VALUE FOR YOU
 
;now transfer start - dontdon't forget to handle irq
</syntaxhighlight>
 
==QEMU support==
QEMU is one of the few hypervisors/emulators that support this sound card.
To run QEMU with Sound Blaster 16 emulation, use the <code>-soundhw sb16</code> option.
 
'''Warning''': recent versions of QEMU (>= 4.0) have a broken support for
this sound card. See bug: [https://bugs.launchpad.net/qemu/+bug/1873769].
Briefly, when QEMU's GTK UI is used and audio is playing, you'll experience
the QEMU window freezing. In addition, there will be flickering in the audio
as well.
 
===Workarounds===
 
# Use an older version of QEMU. With QEMU 2.11 the problem simply does not exist.
;now transfer start - dont forget to handle irq
# Use [https://virt-manager.org virt-manager] which connects to QEMU using Spice. The problem does not exist in this case because QEMU's GTK UI is not used. BUT, configuring QEMU to emulate Sound Blaster 16 through virt-manager requires some tricky settings:
</source>
## Add any sound card to the VM
## In virt-manager's Edit -> Preferences menu check the "Enable XML editing" box.
## Open VM's hardware and after selecting the sound card, click on the XML tab and replace its contents with:<syntaxhighlight lang="xml"><sound model="sb16"/></syntaxhighlight>
# Run the OS using QEMU's <code>-curses</code> option or use QEMU's <code>-kernel</code> and <code>-nographic</code> (serial console): in this case, there will be no "freeze", but there still be some flickering in the audio.
 
==See Also==