Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ sb(4) — NEWS-os 4.2.1R

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

sbrec(1)

sbplay(1)

sbset(1)

sbchk(1)

sbconv(1)

xsed(1)

soundlib(3X)

SB(4)  —  NEWS-OS Programmer’s Manual

NAME

sb, sbe − NEWS built-in/expansion audio interface

SYNOPSIS

device sb0 at hb0 priority 116
device sbe0 at hb0 priority 116
device sb0 at iop0 priority 116
device sb0 at ap0 priority 44

DESCRIPTION

It is possible to use the audio interface built into some NEWS workstations (NWA-033 or standard built-in audio interface) or an expansion audio interface board (NWB-260) with the device driver sb.  On the NWS-1200/1400/1500/1700/1800/3200/3400/3700/3800/5000/5900 series workstations, through the use any of these boards and this device driver, it is possible to record and playback three types of PCM data, straight PCM data (both 16-bit and 8-bit formats), ADPCM format audio data conforming to CD-I and CD-ROM XA specifications, as well as logarithmically compressed PCM format audio data (8-bit) corresponding to the mu-law and A-law data formats. 
Each format can handle either mono or stereo data and the sampling frequency and the bit width may be chosen.

On the NWS-3100 series workstations, it is possible to record and playback two types of PCM data, straight PCM data (both 16-bit and 8-bit formats), logarithmically compressed PCM format audio data (8-bit) corresponding to the mu-law and A-law data formats.  On NWS-3100 series workstations, each format can handle mono data and sampling frequency is fixed at 8 KHz.  NWS-3100, 5000 and 5900 also support full-duplex operation. 

Even though the major numbers of an internal audio interface board and an expansion audio interface board are different since their hardware configurations are different, the software interface specifications of all the board at the device driver level are essentially the same.  The correspondence between each respective special device name and its device number (major and minor numbers) is as follows. 

File NameDevice No.Board
/dev/sb0  35,0        Built-in interface
/dev/sbe0 36,0        Expansion interface
/dev/sbec036,1        sbed daemon and data transfer (sbe0 only)

The data formats which can be handled by each respective board are as follows.  [NWS-1200/1400/1500/1700/1800/3200/3400/3700/3800]

Sampling Frequency Straight PCM mu-law A-law ADPCM
16bit 8bit 8bit 8bit 8bit 4bit
8.000 KHz % % % % − −
9.450 KHz % % % % − ∗
18.900 KHz % % % % − ∗
37.800 KHz % % % % ∗ ∗

[NWS-3100]

Sampling Frequency Straight PCM mu-law A-law ADPCM
16bit 8bit 8bit 8bit 8bit 4bit
8.000 KHz % % % % − −

[NWS-5000/5900]

Sampling Frequency Straight PCM mu-law A-law ADPCM
16bit 8bit 8bit 8bit 8bit 4bit
8.000 KHz % % % % − −
9.450 KHz % % % % − ∗
11.025 KHz % % % % − −
12.000 KHz % % % % − −
16.000 KHz % % % % − −
18.900 KHz % % % % − ∗
22.050 KHz % % % % − −
24.000 KHz % % % % − −
32.000 KHz % % % % − −
37.800 KHz % % % % ∗ ∗
44.056 KHz % % % % − −
44.100 KHz % % % % − −
48.000 KHz % % % % − −

% : Record/Playback
∗ : Playback only
− : Not supported

Include Files

The following header files must be included in order to operate these devices. 

#include <stdio.h>
#include <newsiodev/sound.h>

Opening Devices

Devices which do not support full-duplex are exclusively opened by using the system call open(2).  The error EBUSY is returned if the board is already open.  Devices which support two way (?)  are non-exclusively opened.  Read/write to the same device from multiple processes can be issued; however, in this case, input/output data are all mixed. 
In addition, non-blocking I/O mode can be specified as shown below when opening the board. 

int sbfd;
sbfd = open("/dev/sb0", O_RDWR|O_NDELAY);   /∗ Non-Blocking I/O ∗/

Read/Write

The hardware begins recording with a call to the system call read(2).  The system call returns the error EIO when the data cannot be transferred in time and spills over. 
In addition, in the NWS-1200/1400/1500/1700/1800/3200/3400/3700/3800/5000/5900 series workstations, the hardware will continue to operate even after the read ends (as long as it is not stopped forcefully with SBIOCABORT or SBIOCRESET) and will stop after FIFO becomes full. If this happens, be sure to initialize the board using SBIOCABORT because any reads attempted thereafter will result in an EIO error. The hardware will begin playback when the total amount of data written using the system call write(2) exceeds 32KB (512Byte for NWS-3100 series).  The hardware can be forced to begin playback by using SBIOCFLUSH if the total amount of data is less than 32KB (512Byte for NWS-3100 series) after the data is written.  In non-blocking I/O mode, the number of bytes to actually be read/written in the region not blocked by the system call is returned. 

int sbfd;/∗ file descriptor ∗/
char ∗data;/∗ pointer to the data buffer ∗/
int cnt;/∗ number of bytes to read/write ∗/
read(sbfd, data, cnt);/∗ record ∗/
write(sbfd, data, cnt);/∗ playback ∗/

Closing Devices

Devices are closed by close(2) after they have been used.  close waits until all of the data in FIFO has been played back. 

int sbfd;
close(sbfd);

IOCTL

SBIOCSETPARAM

SBIOCGETPARAM

SBIOCRSETPARAM(NWS-5000/5900)

SBIOCRGETPARAM(NWS-5000/5900)

SBIOCWSETPARAM(NWS-5000/5900)

SBIOCWGETPARAM(NWS-5000/5900)
These are used by the function ioctl in setting the device’s operational mode and getting its operational parameters. 

/∗ sbparam ∗/
struct sbparam {

int sb_mode;     /∗ mode ∗/
int sb_format;   /∗ ADPCM file format ∗/
int sb_compress; /∗ LogPCM data compression function ∗/
int sb_rate;     /∗ sampling frequency ∗/
int sb_channel;  /∗ No. of channels ∗/
int sb_bitwidth; /∗ bit width ∗/
int sb_emphasis; /∗ emphasis on/off ∗/

};
 struct sbparam sbp;
ioctl(sbfd, SBIOCSETPARAM, &sbp);/∗ to set parameters ∗/
ioctl(sbfd, SBIOCGETPARAM, &sbp);/∗ to get parameters ∗/
 /∗ mode ∗/
#define ADPCM 0/∗ ADPCM ∗/
#define STRPCM1/∗ Straight PCM ∗/
#define LOGPCM2/∗ Log-PCM (mu-law/A-law) ∗/
 /∗ file format (ADPCM mode) ∗/
#define BSZ128 0/∗ Sony standard sound data format ∗/
#define BSZ23361/∗ user data for CD-ROM mode 2 ∗/
 /∗ data compression function (LOGPCM mode) ∗/
#define MULAW0/∗ mu-law ∗/
#define ALAW 1/∗ A-law ∗/
 /∗ sampling frequency ∗/
#define RATE8000 8000/∗  8.000 kHz ∗/
#define RATE9450 9450/∗  9.450 kHz ∗/
#define RATE1890018900/∗ 18.900 kHz ∗/
#define RATE3780037800/∗ 37.800 kHz ∗/
#define RATE1200012000/∗ 12.000 kHz ∗/
#define RATE2400024000/∗ 24.000 kHz ∗/
#define RATE4800048000/∗ 48.000 kHz ∗/
#define RATE1102511025/∗ 11.025 kHz ∗/
#define RATE2205022050/∗ 22.050 kHz ∗/
#define RATE4410044100/∗ 44.100 kHz ∗/
#define RATE1600016000/∗ 16.000 kHz ∗/
#define RATE3200032000/∗ 32.000 kHz ∗/
#define RATE4405644056/∗ 44.056 kHz ∗/
 /∗ No. of channels ∗/
#define MONO  1/∗ MONAURAL ∗/
#define STEREO2/∗ STEREO ∗/
 /∗ bit width ∗/
#define RES16B16/∗ 16bit ∗/
#define RES8B 8/∗ 8bit ∗/
#define RES4B 4/∗ 4bit (ADPCM mode) ∗/
 /∗ emphasis ∗/
#define EMPH_OFF0/∗ Emphasis OFF ∗/
#define EMPH_ON 1/∗ Emphasis ON ∗/

The structure sbparam is used to set/get device parameters. 
sb_mode is used to determine the operational mode of the board.  sb_format specifies the data format being used when in ADPCM mode.  When BSZ128 is specified, any ADPCM data written is interpreted as being of the Sony standard sound data format and output as such.  When BSZ2336 is specified, the data is interpreted as user data for CD-ROM mode 2, having a 2336 byte per block configuration.  When BSZ128 or BSZ2336 (with sbe0) is specified, the sampling frequency, bit width, emphasis, and number of channels must also be set appropriately at the same time.  sb_compress is the function for compressing sound data in LOGPCM mode.  sb_rate specifies the sampling frequency being used.  Any of four allowed values from RATE8000 to RATE37800 can be specified in ADPCM mode.  only RATE37800 can be specified when using an 8-bit bit width.  With a 4-bit bit width, however, it is possible to specify values from RATE9450 to RATE37800.  sb_channel specifies the number of channels being used.  sb_bitwidth specifies the number of quantized bits to be used for sampling.  Be sure to make this specification in STRPCM or ADPCM mode.  RES8B and RES16B can be specified for STRPCM and RES4B or RES8B can be specified for ADPCM.  RES8B must be specified for LOGPCM data.  sb_emphasis specifies the emphasis on/off status in ADPCM mode.  Playback will be interrupted by SBIOCSETPARAM call on the devices which do not support full-duplex. To make sure playback will not be interrupted, SBIOCWAIT should be called before SBIOCSETPARAM is issued.
In NWS-3100 series, if SBIOCSETPARAM is issued while the device is in use, only when setting the same parameter as the one already set does not result in error. Specifying the different parameter results EBUSY.
NWS-5000/5900 sets and gets parameters on the record and playback sides according to the device mode at opening. It sets and gets the parameter on the record side when the device is opened with read only (O_RDONLY). It sets and gets the parameter on the playback side when the device is opened with write only (O_WRONLY). It sets and gets the parameters on both sides when the device is opened with read and write (O_RDWR). For setting and getting the parameters to the device opened with read and write, only when the same parameter is used on the record and playback sides, the parameter is returned. Otherwise, EINVAL is returned. When setting a different parameter to each operating device, EBUSY is returned. Otherwise, the parameter is returned. When setting and getting each parameter of the device opened with read and write, use SBIOC{R,W}{GET,SET}PARAM.

SBIOCSETINLVL

SBIOCSETOUTLVL

SBIOCGETINLVL

SBIOCGETOUTLVL
The above are used by the ioctl function for setting and getting the audio signal’s input/output gain specifications. The corresponding parameters are specified in the structure sblevel.

struct sblevel {

int sb_left;/∗ left channel ∗/
int sb_right;/∗ right channel ∗/

};
 struct sblevel sbinlevel;
int gain = -12;  /∗ -12dB ∗/
 sbinlevel.sb_left = sbinlevel.sb_right = gain << 16;
ioctl(sbfd, SBIOCSETINLVL, &sbinlevel);

The gain (in dB) for both the left and right channels is represented using a 31-bit, fixed point number. b31−b16 represents the integer part and b15−b1 represents the fractional part in two’s complement.  On those models which do not support full-duplex, input/output through the sb0 or sbe0 mic/speaker box can be specified to have a gain from 0 dB to −32 dB at an interval of 0.5 dB.  The line input for sbe0 can be specified from +7.5dB to −10dB at an interval of 2.5 dB.  The line output for sbe0 is fixed at 0 dB. 
In the NWS-3100 series workstations, the output can be specified from 8 dB to −8 dB at an interval of 2.0 dB. The value of channel is set in the member sb_left in the structure sblevel since the channel can be used only in monaural.  The value set in sb_right is ignored.  Since the input gain is fixed, SBIOCSETINLVL and SBIOCSETOUTLVL are not supported. 
In NWS-5000/5900, the input gain range can be specified from +16dB to -16dB at an interval of 0.5 dB. The least significant bit LSB (b0) represents muting.  muting is on (gain −∞ dB) when this bit is 1.  However, when the input selector is set to line in with sbe0 (See SBIOCSETINSW.), separate channels cannot be muted individually.  The gain for both channels is set to −∞ dB when the muting bit for both channels is 1.  Full scale digital data input of nearly 2 Vrms (root-mean-square value) can be obtained when the INPUT LEVEL of the mic/speaker box is set to 5 and the input gain is set to 0 dB. In addition, full scale digital data output of nearly 2 Vrms can be obtained when the volume of the mic/speaker box is set to 10 (maximum value) and the output gain is set to 0 dB.
The relationship between the specified value and the actual I/O gain used is as follows.

Value    I/O Gain
0x00100000+16.0dB
0x000f8000+15.5dB
 :            :
0x00078000+7.5dB
 :            :
0x00008000+0.5dB
0x0       0dB
0xffff8000−0.5dB
0xffff0000−1.0dB
0xfffe8000−1.5dB
 :            :
0xffe10000−31.0dB
0xffe08000−31.5dB
0xffe00000−32.0dB
 :            :
0x???????1−∞ dB

SBIOCGETPEAKINLVL(NWS-5000/5900)

SBIOCGETPEAKOUTLVL(NWS-5000/5900)
This ioctl gets the I/O peak level. When mono data is handled, the value is returned to the left channel.

struct sblevellevel;
ioctl(sb, SBIOCGETPEAKINLVL, &level);
 ioctl(sb, SBIOCGETPEAKOUTLVL, &level);

SBIOCMUTE
This is used to turn audio output on/off. The output gain setting remains unchanged.

int mflg = MUTE_ON;
ioctl(sbfd, SBIOCMUTE, &mflg);
 #define MUTE_OFF0/∗ Not Muting ∗/
#define MUTE_ON 1/∗ Muting ∗/

SBIOCFLUSH
The data in the buffer is flushed. Ioctl is called to begin playback when the amount of data to be written is less than 32KB (512Byte for NWS-3100 series). Ioctl must be called after all data has been written in ADPCM mode. The buffer is automatically flushed when the device being used is closed.

ioctl(sbfd, SBIOCFLUSH, 0);

SBIOCWAIT
It is possible to wait for all data left in the buffer to finish being played back by calling ioctl after writing all of the specified sound data. 

ioctl(sbfd, SBIOCWAIT, 0);

SBIOCSTOP

SBIOCRSTOP

SBIOCWSTOP
Here, ioctl can be used to stop the playback/record of data remaining in the buffer.  Only devices which support full-duplex can handle SBIOCRSTOP and SBIOCWSTOP.  When SBIOCSTOP is issued on such a device, the opening flag defines the operation.  If the device was opened with O_RDONLY, the record side stops temporarily.  If the device was opened with O_WRONLY, the playback side stops temporarily.  If the device was opened with O_RDWR, both record and playback sides stop temporarily. 
SBIOCRSTOP and SBIOCWSTOP temporarily stop record and play back. If the device was opened with O_WRONLY and if SBIOCRSTOP is issued, or if the device was opened with O_RDONLY and SBIOCWSTOP is issued, error EIO is returned.
On NWS-1200/1400/1500/1700/1800/3200/3400/3700/3800, Stop mode is released (even in stop mode) when a read is executed and the results of a write remaining in FIFO are greater than 32KB.

ioctl(sbfd, SBIOCSTOP, 0);
ioctl(sbfd, SBIOCRSTOP, 0);
ioctl(sbfd, SBIOCWSTOP, 0);

SBIOCSTART

SBIOCRSTART

SBIOCWSTART
Here, ioctl can be used to start the playback/record of data remaining in the buffer.  Only devices which support full-duplex can handle SBIOCRSTART and SBIOCWSTART.  When SBIOCSTART is issued on such a device, the opening flag defines the operation.  If the device was opened with O_RDONLY, the record side restarts.  If the device is opened with O_WRONLY, the playback side restarts.  If the device was opened with O_RDWR, both record and playback side restart. 
SBIOCRSTART and SBIOCWSTART restart record and play back. If the device was opened with O_WRONLY and SBIOCRSTART is issued, or if the device was opened with O_RDONLY and SBIOCWSTART is issued, error EIO is returned.

ioctl(sbfd, SBIOCSTART, 0);
ioctl(sbfd, SBIOCRSTART, 0);
ioctl(sbfd, SBIOCWSTART, 0);

SBIOCABORT

SBIOCRABORT

SBIOCWABORT
Stops playback/record and initializes the board and the buffer. Parameters already set are maintained. Only devices which support full-duplex can handle SBIOCRABORT and SBIOCWABORT. If SBIOCABORT was issued on such a device, the opening flag defines the operation. If the device was opened with O_RDONLY, the record side is aborted. If the device was opened with O_WRONLY, the playback side is aborted. If the device was opened with O_RDWR, the record and playback sides are aborted. SBIOCRABORT and SBIOCWABORT aborts the devices on the record and playback sides. If the device was opened with O_WRONLY and SBIOCWABORT is issed, or the device was opened with O_RDONLY and SBIOCRABORT is issued, error EIO is returned.
However, the NWS-3100 series aborts the devices on both record and playback sides, and it is impossible to abort only one of them.

ioctl(sbfd, SBIOCABORT, 0);
ioctl(sbfd, SBIOCRABORT, 0);
ioctl(sbfd, SBIOCWABORT, 0);

SBIOCRESET

SBIOCRRESET

SBIOCWRESET
This is used to reset the board and the device driver. After reset, settings are made to be LOGPCM mode, compressed mu-law, at a sampling frequency of RATE8000, mono, with a bit width of RES8B, and emphasis OFF. All buffers are then cleared. The gain for both input/output are set to 0 dB. On NWS-1200/3100/3200/5000/5900, the gain is set so that the monitor is off. Only devices which support full-duplex can handle SBIOCRRESET and SBIOCWRESET. When the SBIOCRESET is issued on such a device, the opening flag defines the operation. If the device was opened with O_RDONLY, the record side is reset. If the device was opened with O_WRONLY, the playback side is reset. If the device was opened with O_RDWR, the record and playback sides are reset. SBIOCRRESET and SBIOCWRESET reset the devices on the record and playback sides. If the device was opened with O_WRONLY and SBIOCRESET is issued, or if the device is opened with O_RDONLY and SBIOCWRESET is issued, error EIO is returned.
However, the NWS-3100 series resets the devices on both record and playback sides, and it is impossible to reset only one of them.

ioctl(sbfd, SBIOCRESET, 0);
ioctl(sbfd, SBIOCRRESET, 0);
ioctl(sbfd, SBIOCWRESET, 0);

SBIOCBUFRESID

SBIOCRBUFRESID

SBIOCWBUFRESID
The number of bytes of data remaining in the buffer are gotten. Because a machine which supports full-duplex has two buffers for recording and playing back, it supports SBIOCRBUFRESID and SBIOCWBUFRESID for each buffer. When SBIOCBUFRESID is issued on a device which supports full-duplex, the flag at opening defines its operation. Namely, this ioctl gets the number of bytes of data remaining in the buffer on the record side if the device was opened with O_RDONLY, and it get the number of bytes of data remaining in the buffer on the playback side if the device was opened with O_WRONLY. If the device was opened with O_RDWR, the number of bytes of remaining in the buffers on both record and playback sides is returned. SBIOCRBUFRESID and SBIOCWBUFRESID get the number of bytes of data remaining in each buffer for recording and playback. If the device was opened with O_WRONLY and SBIOCRBUFRESID is issued, or if the device was opened with O_RDONLY and SBIOCWBUFRESID is issued, error EIO is returned.
The value obtained using ioctl has an error of up to 1KB (on NWS-3100 series, 256 bytes) when using sb0 and up to 4KB when using sbe0. 

int resid;
ioctl(sbfd, SBIOCBUFRESID, &resid);
ioctl(sbfd, SBIOCRBUFRESID, &resid);
ioctl(sbfd, SBIOCWBUFRESID, &resid);

SBIOCBUFSIZE

SBIOCRBUFSIZE

SBIOCWBUFSIZE
The total capacity of the buffer in bytes is gotten. Because a machine which supports full-duplex has two buffers for recording and playing back, it supports SBIOCRBUFSIZE and SBIOCWBUFSIZE for each buffer. SBIOCBUFSIZE is issued on a device which supports full-duplex, the flag at opening defines its operation. Namely, this ioctl gets the capacity on the record side if the device was opened with O_RDONLY, and it gets the capacity on the playback side if the device was opened with O_WRONLY, and it gets the total capacity on both record and playback sides if both devices were opened with O_RDWR. SBIOCRBUFSIZE and SBIOCWBUFSIZE gets the capacities of the buffers for record and playback. If the device was opened with O_WRONLY and SBIOCRBUFSIZE is issued, or if the device was opened with O_RDONLY and SBIOCWBUFSIZE is issued, error EIO is returned. The total capacity of the buffer when using sb0 differs in PCM mode.

int bsize;
ioctl(sbfd, SBIOCBUFSIZE, &bsize);
ioctl(sbfd, SBIOCRBUFSIZE, &bsize);
ioctl(sbfd, SBIOCWBUFSIZE, &bsize);

SBIOCEMPHASIS(sbe0)
This is used to select emphasis on/off in ADPCM mode when using sbe0.

int emphasis = EMPH_OFF;
ioctl(sbfd, SBIOCEMPHASIS, &emphasis);
 #define EMPH_OFF0x0/∗ Emphasis OFF ∗/
#define EMPH_ON 0x1/∗ Emphasis ON ∗/

SBIOCSETLINESW(NWS-5000/5900)

SBIOCGETLINESW(NWS-5000/5900)
These ioctls set and get the LINE SELECTOR output. As the LINE SELECTOR output, select one from: mic input, line input or built-in CD-ROM. The default is the mic input.

int linesw = LINESW_LINE;
ioctl(sb, SBIOCSETLINESW, &linesw);
 ioctl(sb, SBIOCGETLINESW, &linesw);
 #define LINESW_MIC0/∗ mic ∗/
#define LINESW_LINE1/∗ line jack ∗/
#define LINESW_CDROM2/∗ cd-rom ∗/

SBIOCSETINSW(sbe0, NWS-5000/5900)

SBIOCGETINSW(sbe0, NWS-5000/5900)
This is the audio input selector. It is possible to select LINE IN (RCA pin jack) or the mic/speaker box for sbe0. In NWS-5000/5900, the LINE SELECTOR output or the slot input can be selected. It is possible to set selector switch and get its status. The initial values are set in accordance with the input select switch on the board when the device is opened for sbe0. On the NWS-5000/5900, the initial value is the LINE SELECTOR output.

int insel = MIC_SP_BOX;
ioctl(sbfd, SBIOCSETINSW, &insel);
 ioctl(sbfd, SBIOCGETINSW, &insel);
 #define RCALINE   0x0/∗ RCA pin ∗/
#define MIC_SP_BOX0x1/∗ MIC/SP BOX ∗/
#define INSW_LINE0x2/∗ LINE SELECTOR output ∗/
#define INSW_SLOT0x3/∗ SLOT input ∗/

SBIOCSETINCH(NWS-5000/5900)

SBIOCGETINCH(NWS-5000/5900)
These ioctls set and get the parameter which defines whether the data is input only to the left channel or to both channels when the LINE SELECTOR output is mono data. The default is mono data. The input from the SLOT is invalid. (The input from the SLOT is always mono data and it is distributed to both channels.)

int inch = INCH_STEREO;
ioctl(sb, SBIOCSETINCH, &inch);
 ioctl(sb, SBIOCGETINCH, &inch);
 #define INCH_MONO0/∗ mono ∗/
#define INCH_STEREO1/∗ stereo ∗/

SBIOCSETSP(NWS-5000/5900)

SBIOCGETSP(NWS-5000/5900)
NWS-5000/5900 can use the built-in speaker or built-in keyboard (NWP-5461) speaker as the output. These ioctls set and get the parameter to setup these speakers. It is possible to use both speakers at the same time. If keyboard NWP-410/411 is connected, error EINVAL occurs. The default is the built-in speaker.

int sp = OUTSP_KB;
ioctl(sb, SBIOCSETSP, &sp);
 ioctl(sb, SBIOCGETSP, &sp);
 #define OUTSP_SP1
#define OUTSP_KB2

SBIOCSETSLOTOUT(NWS-5000/5900)

SBIOCGETSLOTOUT(NWS-5000/5900)
These ioctls are used to set and get the parameter which defines the sound source output to the slot of the main unit. It is possible to select the D/A converter or MON_LINE to output the source of the sound to the slot.

int slotout = SLOTOUT_DA;
ioctl(sb, SBIOCSETSLOTOUT, &slotout);
 ioctl(sb, SBIOCGETSLOTOUT, &slotout);
 #define SLOTOUT_DA0
#define SLOTOUT_LINE1

SBIOCSETMON(NWS-5000/5900)

SBIOCGETMON(NWS-5000/5900)
NWS-5000/5900 can use the following three kinds of monitor:

MON_LINE: The LINE SELECTOR output monitor
MON_MON:  The monitor to listen to sound actually recorded
MON_SLOT: The SLOT input monitor

These ioctls set and get the parameter to setup these monitors.  If MON_MON is on, the sound on the playback side is not output.  It is possible to monitor the sound on MON_LINE and MON_SLOT regardless of what function is selected in SBIOCSETINSW.  If INSW_LINE is selected in SBIOCSETINSW, however, MON_LINE and MON_MON cannot be selected at the same time.  If INSW_SLOT is selected in SBIOCSETINSW, MON_SLOT and MON_MON also cannot be selected at the same time.  This is because, when MON_MON is selected, the monitor on the sound source input side is muted.  If the monitors are as indicated above, an EINVAL error occurs.  If the output side of the device tries to select MON_MON during operation, an EBUSY error is returned.  The monitor is not turned on by only selecting this ioctl.  It is necessary to select and turn the monitor on with SBIOCSETMONSW, after selection.  When selecting another monitor, the monitor is turned off.  The default is MON_LINE. 

int mon = MON_MON;
ioctl(sb, SBIOCSETMON, &mon)
 ioctl(sb, SBIOCGETMON, &mon)
 #define MON_LINE1
#define MON_MON2
#define MON_SLOT4

SBIOCSETMONLINELVL(NWS-5000/5900)

SBIOCGETMONLINELVL(NWS-5000/5900)
This ioctl sets and gets the MON_LINE monitor level. It is possible to set a value from 0 dB to -32 dB at intervals of 0.5 dB.

struct sblevel level;
ioctl(sb, SBIOCSETMONLINELVL, &level)
 ioctl(sb, SBIOCGETMONLINELVL, &level)

SBIOCSETMONMONLVL(NWS-5000/5900)

SBIOCGETMONMONLVL(NWS-5000/5900)
This ioctl sets and gets the MON_MON monitor level. It is possible to set a value from 0 dB to -32 dB at intervals of 0.5 dB.

struct sblevel level;
ioctl(sb, SBIOCSETMONMONLVL, &level)
 ioctl(sb, SBIOCGETMONMONLVL, &level)

SBIOCSETMONSLOTLVL(NWS-5000/5900)

SBIOCGETMONSLOTLVL(NWS-5000/5900)
This ioctl sets and gets the MON_SLOT monitor level. It is possible to set a value from 0 dB to -32 dB at intervals of 0.5 dB.

struct sblevel level;
ioctl(sb, SBIOCSETMONSLOTLVL, &level)
 ioctl(sb, SBIOCGETMONSLOTLVL, &level)

SBIOCSETMONSW(NWS-1200/3100/3200/5000/5900)

SBIOCGETMONSW(NWS-1200/3100/3200/5000/5900)
Monitor switching at recording time will be controlled by software in NWS-1200/3100/3200/5000/5900 series models. Monitor switch can be set (SBIOCSETMONSW) or get (SBIOCGETMONSW) by using ioctl.  Once monitor switch is set to ON, the mode will not be changed even when the device is closed using the system call, close(2), until the switch will be turned OFF.  On machines which do not support full-duplex, if write(2) or SBIOCRESET is executed to the device, the monitor switch is reset to off.  Only NWS-5000/5900 can turn the monitor selected in SBIOCSETMON on or off.  If MON_MON is selected in SBIOCSETMON and SBIOCSETMONSW is ON, the playback side does not output the sound. 

int monit = MONITOR_ON;
ioctl(sbfd, SBIOCSETMONSW, &monit);
 ioctl(sbfd, SBIOCGETMONSW, &monit);
 #define MONITOR_OFF0
#define MONITOR_ON1

SBIOCGETSTAT (NWS-3100/5000/5900)

SBIOCGETRSTAT (NWS-5000/5900)

SBIOCGETWSTAT (NWS-5000/5900)
This ioctl can get the status of a device. When the device is operating, SBSTAT_RUN is obtained. When the device is not working, SBSTAT_STOP is obtained. SBIOCGETSTAT in NWS-5000/5900 gets the status according to the device mode at opening. If the device was opened with read only (O_RDONLY), this ioctl gets the status on the record side. If the device was opened with write only (O_WRONLY), this ioctl gets the status on the playback side. When the devices are opened with read and write (O_RDWR), the SBSTAT_STOP is returned only when both devices are stopped. Use SBIOC{R,W}STAT to get the status of the device which is opened with read and write.

int stat;
ioctl(sbfd, SBIOCGETSTAT, &stat);
 #define SBSTAT_RUN1
#define SBSTAT_STOP2

SBIOCGETPARAMTBL (NWS-3100/5000/5900)
This ioctl gets the combination of the specified numbers from the parameter combination table which can be assigned by a device.

/∗ sb parameter table ∗/
struct sbptbl {

intsbtbl_no;/∗ number ∗/
struct sbparamsbtbl_param;/∗ parameter ∗/

};
 sbruct sbptbl sbptbl;
sbptbl.sbtbl_no = 0;
ioctl(sbfd, SBIOCGETPARAMTBL, &sbptbl);/∗ gets the number 0 combination ∗/

Struct sbptbl is used to get the number. 
Set the objective number to sbptbl construction unit member sbtbl_no and issue the ioctl, then the combination is returned to member sbtbl_param. Use SBIOCGETNPARAMTBL to get the total number of combinations. sb_format and sb_emphasis in sbtbl_param are not used.

SBIOCGETNPARAMTBL (NWS-3100/5000/5900)
This ioctl gets the total number of combinations which can be specified with a device.

int nparam;
ioctl (sbfd, SBIOCGETNPARAMTBL, &nparam);

SBIOCGETTYPE(NWS-5000/5900)
This ioctl gets the type of the audio interface.

int type;
ioctl(sb, SBIOCGETTPYE, &type)
 #define SBTYPE_AIF21/∗ NWS-1400/1500/1700/1800/3400/3700/3800 ∗/
#define SBTYPE_AIF2_L2/∗ NWS-1200/3200                          ∗/
#define SBTYPE_AIF2_E3/∗ sbe0                                   ∗/
#define SBTYPE_AIF34/∗ NWS-3100                               ∗/
#define SBTYPE_AIF55/∗ NWS-5000/5900                          ∗/

ERRORS

The system calls return −1 when errors occur and the value of the error code itself is returned as follows. 

[ENXIO] - undefined special device name specified for opening. 
- data read attempted in ADPCM mode.
- sbed (daemon) not running (when using sbe0).

[EBUSY] - device already open (On NWS-1200/1400/1500/1700/1800/3200/3400/3700/3800). 
- attempt to set a parameter different from that already set. (On NWS-3100 series)

[EINVAL] - ioctl request, argument not defined. 
- decode not possible due to error in the ADPCM data written (On NWS-1200/1400/1500/1700/1800/3200/3400/3700/3800).

[EINTR] - system call interrupted by another signal. 

[EFAULT] - outside specified address area allocated to the read/write buffer. 

[EIO] - FIFO overflow during reading. 

BUGS

Although it is possible to use sb0 and sbe0 simultaneously, it is not possible to more than one of the same type of board at once. 

The relative amount of data (per unit time) for transfer is directly proportional to the settings for the number of channels, the number of quantized bits, and the sampling frequency.  If the amount of data for transfer is large per unit time, data input may spill over into other areas of memory depending on the system load and the conditions of the file system being used.  Also, data output may be delayed.  When executing write() to a device, make the quantity written at one time an integer multiple of the block size.  If data is not output in time, the FIFO in the board is reset.  This is because if the first data written after resetting is not aligned, data cannot be played back normally. 

FILES

/dev/sb0  Built-in audio interface device file
/dev/sbe0 Expansion audio interface device file
/dev/sbec0Expansion audio interface device file (for use by Daemon)

SEE ALSO

sbrec(1), sbplay(1), sbset(1), sbchk(1), sbconv(1), xsed(1), soundlib(3X)

NEWS-OSRelease 4.2.1R

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026