sound!
-
ASHLEY4
Re:sound!
It depends if you are talking about the internal speaker or the ones that plug in to the back of your pc.
The internal speaker is programed by in/out.
The ones that plug in the back need a driver for the soundcard(also by in/out ,but are different for each card),some that are 16SB compatible are well documented,but are not as common as they used to be.
ASHLEY4.
The internal speaker is programed by in/out.
The ones that plug in the back need a driver for the soundcard(also by in/out ,but are different for each card),some that are 16SB compatible are well documented,but are not as common as they used to be.
ASHLEY4.
-
mr. xsism
Re:sound!
well you need musical talent to play tunes on any of the hardware 
PC speaker only allows for 8bit tunes. SoundBlaser stuff is 16bit-32bit and im sure higer. I'm not sure about documentation for other nonSB cards but linux seems to get its filthy paws on specs for almost all hardware you would ever have one way or another
PC speaker only allows for 8bit tunes. SoundBlaser stuff is 16bit-32bit and im sure higer. I'm not sure about documentation for other nonSB cards but linux seems to get its filthy paws on specs for almost all hardware you would ever have one way or another
- Pype.Clicker
- Member

- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:sound!
okay. Time for 'real' info.
The PC speaker has just two states 'close' and 'far' and you can make it oscillate between those two states at any frequency using one of the PIT circuits. If you program that PIT to output a square wave at 440.0Hz, you'll get the main 'A' tune.
Check a tutorial on sound physicals to learn more, but basically, 220Hz is 'A' one octava bassa and 880Hz is 'A' octava alta etc. Other semi-tones are mapped exponentially between two 'A's...
If you want to play, say 'brother jack' "CDEC_CDEC_", you need a timer that will define the duration of each note and switch to the proper frequency or mask the PC speaker signal for one duration.
Sound Blasters are quite a different type of beast. They allow you to output any digitized signal to your speakers by allowing a larger range of 'states' of the speaker, thus rendering smoother sound waves. For instance, the diapason sound can be rendered with sample(time) = 127 + sin(time/frequency) * 128
The PC speaker has just two states 'close' and 'far' and you can make it oscillate between those two states at any frequency using one of the PIT circuits. If you program that PIT to output a square wave at 440.0Hz, you'll get the main 'A' tune.
Check a tutorial on sound physicals to learn more, but basically, 220Hz is 'A' one octava bassa and 880Hz is 'A' octava alta etc. Other semi-tones are mapped exponentially between two 'A's...
If you want to play, say 'brother jack' "CDEC_CDEC_", you need a timer that will define the duration of each note and switch to the proper frequency or mask the PC speaker signal for one duration.
Sound Blasters are quite a different type of beast. They allow you to output any digitized signal to your speakers by allowing a larger range of 'states' of the speaker, thus rendering smoother sound waves. For instance, the diapason sound can be rendered with sample(time) = 127 + sin(time/frequency) * 128
- Pype.Clicker
- Member

- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:sound!
Well, most of the audio chipsets (real cards become rare) do have a 'sound blaster emulatioin' feature that can be activated through BIOS. They indeed differ by the way you control them, which require documentation hunting and driver implementation. AC97 chip is one of the most supported on motherboards and CMI is one of the most frequent PCI card ... As both appear as PCI device, you don't need to probe each soundcard: just load the driver that match VID/PID with detected hardware.mr. x wrote: I'm not talking about the pc speaker :p
Full SoundBlaster compatibility seems quite rare today, how are the cards now a day differ from SoundBlaster? Every soundcard can't have it's own ports etc, and assume there's a driver for each card huh? I don't want that![]()
Note that there's nothing like "32bits sound output" iirc. Even 'soundblaster AWE32' was for '32 polyphonic channels", not "32 bits DSP" ... It would make no sense as our ears aren't able to distinguish that low amplitude variations
-
mystran
Re:sound!
Indeed PC speaker could be called 1bit and people have done tracker module player that do a good job at getting something more nice than beeps out of it, but it still sucks, don't bother.
There is a standard called AC97 (and it has some new version too with a totally different name) by Intel that some soundcard chips support. AC97 in theory can give you some kind of sound from most chips, the reality however is that most AC97 chips have so different implementations of the standard that you actually need different drivers.. in any case, I would take a look, YMMV. I think that even my Audigy can give some sound with AC97 drivers only.. not sure.
Original SB-support (including SB16) is starting to be quite useless as not many people have ISA-busses anymore. Most of the 100%SB-compatible ISA-boards where quite 100%-compatible in reality, while none of the PCI ones are, for obvious reasons. At some point Windows Sound System used to be another standard, but it's been largely forgotten I think.
Most basic cards should be quite easy to support and reading Linux sources might help in getting some idea how complex their drivers are (although I'd search for real specs too). "High-end" cards which rely on DSP patches are much harder, since you need to supply the patches too
There is a standard called AC97 (and it has some new version too with a totally different name) by Intel that some soundcard chips support. AC97 in theory can give you some kind of sound from most chips, the reality however is that most AC97 chips have so different implementations of the standard that you actually need different drivers.. in any case, I would take a look, YMMV. I think that even my Audigy can give some sound with AC97 drivers only.. not sure.
Original SB-support (including SB16) is starting to be quite useless as not many people have ISA-busses anymore. Most of the 100%SB-compatible ISA-boards where quite 100%-compatible in reality, while none of the PCI ones are, for obvious reasons. At some point Windows Sound System used to be another standard, but it's been largely forgotten I think.
Most basic cards should be quite easy to support and reading Linux sources might help in getting some idea how complex their drivers are (although I'd search for real specs too). "High-end" cards which rely on DSP patches are much harder, since you need to supply the patches too
- Pype.Clicker
- Member

- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
- Pype.Clicker
- Member

- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:sound!
you bet! yep. Especially if i can include it in my GPL project
If you have no website where to put it, you can mail it to me and i'll host it on clicker's website 
-
ASHLEY4
-
KieranFoot
Re:sound!
Its easy to write sound blaster drivers, but they only work with 100% SB Compatable hardware. These routines are available in many languages but I ahvent found any in ASM (Yet!). I am however with a bit of help translating SB code into ASM for inclusion into the basis of my operating system.
- Pype.Clicker
- Member

- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:sound!
if you're in realmode, yes (programming SB was one of my first asm programming attempt) ... in paged pmode, it will be more difficult as you have to deal with ISA dma transfers (which require extra work to have physically contiguous memory region below the 16MB barrier ...)KieranFoot wrote: Its easy to write sound blaster drivers
-
ASHLEY4
Re:sound!
@kieranfoot here's a start
.
ASHLEY4.
Code: Select all
;---------------------------------------------------------------------------
; SB_DSP.ASM -- Programmer's library for the Sound Blaster DSP interface
;---------------------------------------------------------------------------
IDEAL
MODEL small
DATASEG
SB_IO_Port DW 0220h ;These values are kept here to avoid add
DSP_Reset DW 0226h ;instructions in code that may be time-
DSP_RDData DW 022Ah ;sensitive.
DSP_Command DW 022Ch
DSP_RDAvail DW 022Eh
DSP_WRData EQU DSP_Command ;Aliases for the same variable name
DSP_Status EQU DSP_Command
CODESEG
PUBLIC _dsp_reset,_dsp_voice,_set_SB_address,_dsp_dma_prepare,_dsp_time
MACRO await_DSP
LOCAL @@Wait_Ready
push ax dx
@@Wait_Ready:
mov dx,[DSP_Status]
in al,dx
and al,128
jnz @@Wait_Ready
pop dx ax
ENDM MACRO
MACRO ten_microsec_delay
LOCAL @@KT ;If you know of a better, more accurate,
push cx ;more reliable, just plain smarter, way
mov cx,20000 ;to do this, PLEASE TELL ME.
@@KT: ;
nop ;(The idea is to kill 10 microseconds.)
loop @@KT ;
pop cx ;email: [email protected]
ENDM ten_microsec_delay
;---------------------------------------------------------------------------
; void far dsp_time(int pacing)
;---------------------------------------------------------------------------
; pacing = 255 - (1,000,000 / frequency)
;---------------------------------------------------------------------------
PROC _dsp_time FAR
ARG delay:WORD
push bp
mov bp,sp
push ax dx
await_DSP
mov dx,[DSP_Command]
mov al,040h
out dx,al
await_DSP
mov dx,[DSP_Command]
mov ax,[delay]
out dx,al
pop dx ax
pop bp
ret
ENDP _dsp_time
;---------------------------------------------------------------------------
; void far dsp_reset(void)
;---------------------------------------------------------------------------
PROC _dsp_reset FAR
push ax dx
mov dx,[DSP_Reset]
mov al,1
out dx,al
ten_microsec_delay
mov al,0
out dx,al
@@Wait_Ready:
mov dx,[DSP_RDAvail]
in al,dx
and al,128
jz @@Wait_Ready
mov dx,[DSP_RDData]
in al,dx
cmp al,0AAh
jne @@Wait_Ready
mov ax,165
push ax
call _dsp_time
pop ax
pop dx ax
ret
ENDP _dsp_reset
;---------------------------------------------------------------------------
; void far dsp_dma_prepare(int Dir,int Length)
;---------------------------------------------------------------------------
; Dir = 0 for Microphone Input, 1 for Speaker Output
; Length = Length of data to be sampled/played
;---------------------------------------------------------------------------
PROC _dsp_dma_prepare FAR
ARG Dir:WORD,Len:WORD
push bp
mov bp,sp
push ax dx
await_DSP
mov al,24h
cmp [Dir],0
jz @@Is_Read
mov al,14h
@@Is_Read:
mov dx,[DSP_Command]
out dx,al
await_DSP
mov ax,[Len]
out dx,al
await_DSP
mov al,ah
out dx,al
pop dx ax
pop bp
ret
ENDP _dsp_dma_prepare
;---------------------------------------------------------------------------
; void far dsp_voice(Activity)
;---------------------------------------------------------------------------
; Activity = 0 for silent, 1 for audible
;---------------------------------------------------------------------------
PROC _dsp_voice FAR
ARG Which:WORD
push bp
mov bp,sp
push dx ax
await_DSP
mov ax,[Which]
and al,1 ;Want a 1/0 parameter
xor al,1
shl al,1
or al,0D1h
mov dx,[DSP_Command]
out dx,al
pop ax dx
pop bp
ret
ENDP _dsp_voice
;---------------------------------------------------------------------------
; void far set_SB_address(int base)
;---------------------------------------------------------------------------
; Sets base port of SoundBlaster that other functions refer to.
; Most likely value (and the default): 0x220
;---------------------------------------------------------------------------
PROC _set_SB_address FAR
ARG Port:WORD
push bp
mov bp,sp
push ax
mov ax,[Port]
mov [SB_IO_Port],ax
add ax,6
mov [DSP_Reset],ax
add ax,4
mov [DSP_RDData],ax
add ax,2
mov [DSP_Command],ax
add ax,2
mov [DSP_RDAvail],ax
pop ax
pop bp
ret
ENDP _set_SB_address
END