I don't have time to continue my work on this project. New cards will not be supported. Dynamic DSP code support will not be written.

same page in Russian

Since 2004/01/11 02:30:56 PST FreeBSD 5.x has Audigy (and Audigy2) support in kernel in emu10k1 driver. It is based on patch by Orlando Bassotto and does not support complex mixer settings and MIDI I/O. You can use it if you do not use MIDI or other features of emu10kx driver.

For Linux driver please visit ALSA Project
For Windows driver you can look at KX Project if you don't like Creative driver

This driver is for FreeBSD only!

WARNING: -CURRENT since 2004/05/31 23:22:59 PDT does not have MIDI subsystem!
NEWMIDI was removed without replacement.

WARNING: -CURRENT since 2004/07/16 has new sound module naming scheme. It is supported in emu10kx revision 2004-07-16a and later.

News

  1. [2005-10-15] To make audio/emu10kx port maintainer life easier only tested releases will be published as emu10kx-<date>.tar.bz2. Intermediate releases will be published as "snapshots" at emu10kx-snap.tar.bz2.
  2. [2005-10-15] Add workaround that allows user to set recording level. Proper fix require better AC97 emulation code. You should use emuctrl rset mix0 XX:YY to set recording volume to XX:YY, because 'rec' level is not available through the mixer on recent FreeBSD versions. Recording is tested on Audigy 2 Value at 48kHz / 16bit / stereo.
  3. [2005-10-14] Got Audigy 2 Value card. It should work now. You need to set DIGITAL output volume to non-zero value to listen to your music.
  4. [2005-09-24] New emuctrl command: save. Also add emuctrl rc.d script (not connected to install) that should save / restore emu10kx settings much like mixer rc.d.
  5. [2005-09-16] There is a FreeBSD port (audio/emu10kx) for this driver. I'll try to fix bugs, but I don't want to add new features.
  6. [2005-04-23] Rewrote AC97 emulation for Audigy. Driver will use slightly less memory.
  7. [2004-05-23] Make main mix visible from emuctrl. Main mix volume and main mix recording volume now can be changed on Live! cards.
  8. [2005-04-21] Added support for Audigy 2 Value cards (PCI chip ID = 0x00081102). Not tested.

Compiling and loading emu10kx driver

  1. You should have FreeBSD source code installed in /usr/src.
  2. If you have to use midi2: download, unpack and install midi2. Check Supported configurations section if you unsure. Build instructions for midi2 are inside midi2 archive.
  3. Download and unpack emu10kx archive.
  4. Enable MIDI in Makefile if you need MIDI support.
  5. make clean, make, make install.
  6. If you don't use devfs: make device file in /dev. Default values for emu10kx0 are major 201, minor 0. If you have other device with major 201, change Makefile and rebuild driver. If you have more than one Audigy card, second one gets minor 1, third gets minor 2. Use
    /sbin/mknod /dev/emu10kx0 c <major> <minor>
    
    command to create device file.
  7. Select driver loading option:
    1) via loader.conf, if you don't use midi2:
    add
    #snd_pcm_load="YES"		# Digital sound subsystem , FreeBSD 4 and 5 before
    						# snd_pcm -> sound change
    sound_load="YES"		# FreeBSD 5 with new sound naming
    midi_load="NO"			# Do not load midi2 - read Known Bugs section.
    snd_emu10k1_load="NO" 		# do not load Creative Sound Blaster Live
    snd_emu10kx_load="YES" 		# Creative Sound Blaster Live / Audigy
    
    to your loader.conf. You should disable emu10k1 driver (they are for the same hardware).
    2) via rc.local: add
    # Add if you use midi2. 
    /sbin/kldload midi		
    # Creative Sound Blaster Live / Audigy
    /sbin/kldload snd_emu10kx	
    
    to your /etc/rc.local.
  8. You should see something similar to
    emu10kx0: <Creative EMU10K2 (Audigy)> port 0xd000-0xd01f irq 12 at device 10.0 on pci0
    midi0: <EMU10Kx MIDI Interface (midi2)> on emu10kx0
    midi0: midi interrupt 00000080 without interrupt handler, force mread!
    midi0: midi interrupt 00000080 without interrupt handler, force mread!
    midi1: <EMU10Kx MIDI Interface (midi2)> on emu10kx0
    midi1: midi interrupt 08000000 without interrupt handler, force mread!
    midi1: midi interrupt 08000000 without interrupt handler, force mread!
    pcm0: <EMU10Kx PCM Interface> on emu10kx0
    pcm0: <TriTech TR28602 AC97 Codec>
    
    on your console, if you use midi2, or
    emu10kx0: <Creative EMU10K2 (Audigy)> port 0xd000-0xd01f irq 12 at device 10.0 on pci0
    midi0: <EMU10Kx MIDI Interface (NEWMIDI)> on emu10kx0
    midi1: <EMU10Kx MIDI Interface (NEWMIDI)> on emu10kx0
    pcm0: <EMU10Kx PCM Interface> on emu10kx0
    pcm0: <TriTech TR28602 AC97 Codec>
    
    if you use NEWMIDI.
  9. Set card mode and default volume: for example, add
    # Set card in analog mode
    /usr/sbin/emuctrl mode analog
    # Set AudigyDrive Headphones (out3) to full volume
    /usr/sbin/emuctrl set out3 100
    # Enable MIDI IR events
    /usr/sbin/emuctrl ir enable
    
    
    to your /etc/rc.local. Use emuctrl list to list available connectors. You may find that PCM volume in emu10kx driver is lower than if you use emu10k1 driver. This happens because emu10k1 driver has additional amplification in DSP code (all pcm samples are multipled by 4).

MIDI

This driver can be compiled with MIDI I/O support. It provides only basic MPU UART interface and can't be used to play MIDI files without external synthesizer. On Live! cards you will get one MIDI device, on Audigy - two devices, one for on-card DB15 (joystick) connector and one for MIDI ports on AudigyDrive.

  1. Supported driver configurations
    Makefile variable vs FreeBSD version FreeBSD 4.x,
    no MIDI
    FreeBSD 5.x,
    -CURRENT with NEWMIDI
    FreeBSD 5.x,
    -CURRENT without NEWMIDI
    FreeBSD 5.x,
    -CURRENT with midi2 (*)
    EMU10KX_WITH_MIDI=yes
    (NEWMIDI MIDI I/O)
    No Yes,
    should have device midi. Driver cannot be unloaded.
    No No
    EMU10KX_WITH_MIDI2=yes
    (midi2 MIDI I/O)
    No Yes(**),
    should install midi2
    Yes(**),
    should install midi2
    Yes(**)
    Without MIDI I/O Yes Yes Yes Yes

    (*) not committed to -CURRENT, but I hope to see it soon.
    (**) Cannot be loaded at boot time via loader.conf. Read Known bugs section for more information.
  2. You should have "device midi" in your running kernel if you want to load emu10kx driver with NEWMIDI MIDI support. If you run GENERIC you should build your custom kernel because MIDI is not included in GENERIC kernel.
  3. You should not have "device midi" in your running kernel if you want to load emu10kx driver with midi2 MIDI support. If you run GENERIC you do not need to build your custom kernel because MIDI is not included in GENERIC kernel.
MIDI and IR

IR receiver on Live!Drive and AudigyDrive is an internal MIDI controller. If you have an AudigyDrive, you can use rcenter and xmmspipe by Bejamin Lynn to control your xmms (or any other software) from remote control.
You may need to replace -lpthread with -lthr in rcenter Makefile, if you run FreeBSD version that does not have libpthread.
IR receiver MIDI device for Audigy Platinum is /dev/midi1 with NEWMIDI MIDI and /dev/midi1.0 with midi2 MIDI code.

You can enable LiveDrive! or AudigyDrive IR receiver by running emuctrl ir enable.

IR events cannot be disabled.

Digital and analog mode of SBLive! and Audigy cards

EMU10K-based sound cards from Creative have two operating modes: analog and digital-only. When you load emu10kx driver, it puts Audigy card into 'digital-only' mode unless your card is reported to be broken in digital mode. In later case card will be set to analog mode. SB Live! cards are initialized in analog mode. You can check current operating mode using emuctrl mode command and switch between them using emuctrl mode [analog|digital] command.

On both Live! and Audigy cards, operating mode controls use of 'Analog/Digital Out' connector. On Live! cards it also controls sound on 'Rear Out' connector.

Card outputs and connectors

SB Live! card outputs and connectors
emuctrl output name analog mode digital-only mode
AC97 (Front Speakers) Line Out Line Out,
Analog/Digital Out(?)
TOS Link D/K D/K
DIGITAL: Center Silent Analog/Digital Out
DIGITAL: Subwoofer Silent Analog/Digital Out
Headphones Live!Drive Headphones(?) D/K
Rear Speakers Rear Out Analog/Digital Out
Center Analog/Digital Out Silent
Subwoofer Analog/Digital Out Silent

Where 'D/K' means 'Don't Know', 'Silent' means that signal, controlled by this volume control, does not appear on card connectors. Other names are connector names from my Audigy 'Getting Started' manual

Audigy card outputs and connectors
emuctrl output name analog mode digital-only mode
DIGITAL: Front D/K Analog/Digital Out
DIGITAL: Center D/K Analog/Digital Out
DIGITAL: Subwoofer D/K Analog/Digital Out
Headphones AudigyDrive Headphones AudigyDrive Headphones
DIGITAL: Rear D/K Analog/Digital Out
Front Line Out Line Out
Center Analog/Digital Out Silent
Subwoofer Analog/Digital Out Silent
Rear Rear Out Rear Out
AC97 ?? D/K D/K

Where 'D/K' means 'Don't Know', 'Silent' means that signal, controlled by this volume control, does not appear on card connectors. Other names are connector names from my Audigy 'Getting Started' manual

It seems that in both 'analog' and 'digital-only' modes you will get some sound on S/PDIF connectors on AudigyDrive.

Sound routing

I'm not an ASCII-art master, but I hope this will help you understand all volume controls and sound flow in emu10kx driver.

All volume controls except "Master Vol" and "Master Rec Vol" are controlled from emuctrl.
On Audigy "Master Vol" and "Master Rec Vol" are controlled from mixer by it's "vol" and "rec" controls. Fx0 volume can be controlled from both emuctrl ("FX BUS 0") and mixer ("pcm").
On SBLive! and Audigy "Master Vol" and "Master Rec Vol" can be changed from emuctrl. On Audigy, if you change "fx0" playback and "mix0" playback or recording volume you will not see this changes in "vol", "rec" and "pcm" mixer values. This cannot be fixed (ac97.c FreeBSD AC97 driver does not query AC97 codec when it asked about volume values.

Playback:

         [InVolume0]
              |
              V                        [OutVol0]
[input0]---->[*]-----\                      |
   .                 |                      V
   .     [InVolumeN] .  [Master Vol]   /---[*]---->[output0]
   .          |      |       |        /
   .          V      V       V       /
[inputN]---->[*]--->[+]====>[*]======------>[*]---->[outputP]
                     ^                       ^
                     |                       |
[fx0]------->[*]--->[+]                    [OutVolP]
  .           ^      ^
  .           |      |
  .      [FxVolume0] |
[fxM]------->[*]----/
              ^     
              |      
         [FxVolumeM]  

where output0..P are non-recording STEREO and MONO outputs (on-card or on-Drive connectors).

If you want to listen to sound coming from AC97 codec (like analog CD Audio) on Audigy you should set "AC97 Codec" volume (usually in0) to non-zero (I like 75).

Mono outputs, like Center and Subwoofer, are just (Left + Right)/2.

Recording:

       [InRecVolume0]
              |
              V                         
[input0]---->[*]-----\                  
   .                 |                  
   .  [InRecVolumeN] . [Master Rec Vol] 
   .          |      |       |        
   .          V      V       V       
[inputN]---->[*]--->[+]====>[*]======------>[*]---->[outputX]
                     ^                       ^
                     |                       |
[fx0]------->[*]----[+]                  [OutRecVolX]
  .           ^      |
  .           |      |
  .   [FxRecVolume0] |
[fxM]------->[*]----/
              ^     
              |      
      [FxRecVolumeM]  

where outputX is a STEREO DSP recording output (usually named "A/D converter (REC)"). Recording on MONO DSP recording output ("Mic (REC)") does not supported. If you want to record sound you must set both "A/D converter" volume in emuctrl and "rec" volume in mixer (that controls "Master Rec Vol" on Audigy and AC97 recording level on SBLive!) to non-zero.

This card is capable of recording of up to 16 different streams (locked to 48Khz/16bit/Stereo) in addition to "A/D converter" (not locked to 48Khz/16Bit/Stereo). This driver does not support it.

Some math

Sound inside AC97 codec:

                    <input_i volume>
<ac97 sample> = SUM(---------------- * <input_i sample>)
                 i         100
where <input_i volume>s are labeled "speaker", "line", "cd", "line1", "phin", "video", "mic" (this list depends on AC97 codec features) in mixer. There is no separate "recording" and "playback" AC97 connections to Audigy DSP, therefore setting rec input is useless. AC97 codec should be set to always record sound from all inputs (so-called 'stereo mix').

In DSP <ac97 sample> will be sent to both recording an playback bus, with amp, "rec" and AC97 input vol/recvol volume controls applied. For recording bus:

                    rec       <DSP input_i recvol>                           
<DSP recB sample> = --- * SUM(-------------------- * <DSP input_i sample>) 
                    100    i         100

<DSP recB sample> = <DSP recB sample> * amp

After that it will go into all outputs that are marked as 'recording output' in driver (there are two inputs, but only one used because another one ('mic rec') is limited to 8Khz/8bit/mono):

                            <DSP rec output_j vol>
<DSP rec output_j sample> = --------------------- * <DSP recB sample>
                                     100
after that <DSP rec output sample> will be sent to FreeBSD driver in up to 8k blocks.

For playback bus:

                     vol       <DSP input_i vol>                           
<DSP playB sample> = --- * SUM(----------------- * <DSP input_i sample>) 
                     100    i        100

<DSP playB sample> = <DSP playB sample> * amp

And for each non-recording output (with mono downmix for mono outputs)

                             <DSP play output_k vol>
<DSP play output_k sample> = ----------------------- * <DSP playB sample>
                                      100

After that it will be sent to on-card DAC, AudigyDrive or S/PDIF connector.

S/PDIF I/O

AudigyDrive's 'SPDIF IN' is marked 'Optical S/PDIF' in emuctrl. I don't know, is 'Coaxial S/PDIF' connected to 'OPTICAL IN' (and labels in emuctrl just need to be swapped) or 'Connected S/PDIF'is connected to something else (or not connected at all).

S/PDIF input is 24bit/96kHz, PCM only (there is no DolbyDigital&tm; compatible decoder in driver and no way to get full stream to userland decoder).

You should set amplification to '1' to avoid clipping.

Sound recording

You need to make (at least) this steps to record sound:

  1. (Audigy only) Set master recording level using mixer rec <level> command (mixer rec 100 is a good starting point). On SBLive! cards master recording level is always 100%
  2. (SBLive! only) Set AC97 recording level using mixer rec <level> command (mixer rec 100 is a good starting point). On Audigy cards AC97 recording level is always 0% - you record AC97 playback signal.
  3. Set "REC" output level using emuctrl set outX <level>, where X is 6 on SBLive! and 13 on Audigy. 100% is good number to start with.
  4. If you record from input connected to AC97 codec you need to set correct volume using mixer command. Please note that on Audigy you always record a mix of all AC97 inputs, not 'recording source'!
  5. Set DSP input recording level using emuctrl rset inX <level>.

Example: recording from AUX2 (on AudigyDrive) on Audigy

mixer rec 100		## set record bus volume
emuctrl amp 4		## amplify every input four times
emuctrl set out13 100	## set recording volume for DSP output
emuctrl rset in6 100	## set recording volume for DSP input
wavrec test.wav		## record 10s using wavrec from ports/audio/wavplay port.

Basic troubleshooting tips

I hope that following checklist help you troubleshoot basic problems (like 'driver fails to load').

Look for /dev/emu10kx0

If you have it: Look inside this file ( cat /dev/emu10kx0 ). You should see something like this:

FreeBSD EMU10Kx Audio Driver

Hardware resource usage:
DSP General Purpose Registers: 154 used, 512 total
DSP Instruction Registers: 168 used, 1024 total
Card supports AC97 codec and 5.1 output, Audigy DSP code

Installed devices:
EMU10Kx Mixer Interface on emu10kx0
	          FX BUSes  Inputs    Outputs   
	Playback  1         8         18       
	Recording 1         8         0        
EMU10Kx PCM Interface on pcm0
	Digital mode, S/PDIF output is PCM stereo

If you see this message than driver is loaded. You may need to adjust volume or set analog / digital card mode using emuctrl program. Use emuctrl debug on to unhide some mixer controls. If you have mixer control that was hidden, but this control changes volume on your card outputs, or can't get any sound from your card with all controls at 100%, please send me information described in If above steps fails section.

If you see message on console 'Device not configured' than driver is not loaded.

Check for PCM sound subsystem - look for /dev/sndstat file

If you don't have it:
Your system cannot load sound subsystem module. Make shure that you have sound.ko or snd_pcm.ko module in your kernel modules directory. If you use MODULES_OVERRIDE option in your kernel configuration file, add "sound/sound" or "sound/pcm", depending on your OS version. If you have that module, try to load it (kldload sound or kldload snd_pcm) and watch for message on system console. For FreeBSD 5.3 and later you can include "device sound" in your kernel configuration.

You have it:
Look inside it (cat /dev/sndstat). You should see a list of installed devices. If you have any of the following lines

			
pcmX: <Creative EMU10K1> on pciX .... 
pcmX: <Creative Audigy (EMU10K2)> on pciX .... 
pcmX: <Creative Audigy 2 (EMU10K2)> on pciX .... 
than you have emu10k1 driver loaded and your card is supported by that driver. You need to disable emu10k1 driver.
For FreeBSD 5.2: If you have "device pcm" in your kernel configuration than you should remove it from kernel and build it as a module. If you don't have "device pcm" in your kernel than check your loader.conf and rc.local.
For FreeBSD 5.3 and later, 6.x and -CURRENT: remove "device snd_emu10k1" from your kernel configuration.

You don't have anything related to EMU10K1 or EMU10K2 in /dev/sndstat.
Check that your card is listed in pciconf -l -v output. If you can't find your card there, than something wrong with your hardware...

If above steps fails

I'll need some information about your system:

  1. dmesg output.
  2. pciconf -v -l output.
  3. kldstat output.
  4. cat /dev/sndstat output.
  5. cat /dev/emu10kx0 output.

Known bugs

  1. Machine hangs when you load emu10kx, snd_pcm and midi2 from loader.conf. It stops after
    Device configuration finished.
    procfs registered
    Timecounter "TSC" frequency 400910787 Hz quality 800
    Timecounters tick every 10.000 msec
    Linux ELF exec handler installed
    
    on my computer.
  2. Digital output is untested.
  3. panic if you unload driver while playing sound inside ac97 interface code on Audigy.

Plans

  1. detection of LiveDrive/AudigyDrive?
  2. dynamic loading of DSP code.

Not in my plans:

  1. Joystick support
  2. SoundFont etc.

driver

tools

  1. OSS playback test program (free-oss-tes.tar.gz)
  2. AC3 playback program (play-ac3.tar.gz), ported from Linux emu10k driver

Links to archive and other versions are removed. Latest version should work for all versions of FreeBSD 4.x and 5.x. Driver by Orlando Bassotto is committed to FreeBSD 5.

contact info

my e-mail: chibis @ gfk . ru .
please add "[AUDIGY]" or "[SBLIVE]", in Subject to help me filter your mail out of tons of SPAM.

You can discuss this driver with other users (_not_ me) on Audigy drivers Forums
I don't have time to track all posts on this forum.

Yuriy Tsibizov,
GfK RUS network admin

$Id: readme-en.htm,v 1.39 2005/10/15 19:53:23 chibis Exp $