Pro Audio Spectrum 16 PCM Hardware Register Functions Brought to you by "Code Blue" from IRC's #coders channel. Version 1.0 -- "Code Blue" -- Oct. 7, 1993 This textfile is a reference to the PAS-16's PCM hardware register functions. Both the high and low-level function call interfaces are built upon this interface. PCM hardware register functions provide you with ultimate control over PCM programming. The PAS-16's PCM circuitry, aided by DMA, samples and plays back PCM waveforms. With DMA, the PAS-16 sends or receives data samples without direct program involvement. You must ensure that the DMA is set up with a dedicated memory area to process DMA transfers. Using double-buffering techniques, you can create continuous sound waveforms by simply filling one buffer area while the other is being played. * Audio Filter Control * Register B8Ah Use the Audio Filter Control Register to set bit masks that enable and disable counters and allow the system to generate interrupts, mute and reset the board; and, select filtering for PCM playback. D7 = Sample Buffer Counter Gate D6 = Sample Rate Timer Gate D5 = Audio Mute D4 = Filter Select Bit 4 D3 = Filter Select Bit 3 D2 = Filter Select Bit 2 D1 = Filter Select Bit 1 D0 = Filter Select Bit 0 Sample Buffer Counter Gate (D7) Use this bit to enable the Sample Buffer Count register. More info on this follows later in this text file (Sample Buffer Count Register 1389h). [ D7 ] [ Description ] Settings: 1 Enable Sample Buffer Counter. 0 Disable Sample Buffer Counter. Default: 0 Sample Rate Timer Gate (D6) Use this bit to enable the Sample Rate Timer Register. More info on this follows later in this text file (Sample Rate Timer Register 1388h). [ D6 ] [ Description ] Settings: 1 Enable Sample Rate Timer 0 Disable Sample Rate Timer Default: 0 Audio Mute (D5) Use this bit to enable and disable the PAS-16 audio output. When the PAS-16 is enabled, all audio sources (including PC speaker) can be mixed and output to speakers or headphones. When the PAS-16 is disabled, only the PC speaker can output sound. [ D5 ] [ Description ] Settings: 1 Enable PAS-16 0 Disable PAS-16 Default: 0 Filter Select (D4 through D0) Use these bits to select a filter to eliminate unwanted high-frequency harmonics. For proper filtering and playback, select a filter with a limiting frequency equal to half the sample rate. If more than one audio signal source is combined in the input mixer, a lower quality audio signal should dictate the filter selection. All filter settings below have a low-end threshold of 20Hz. [ D4 ] [ D3 ] [ D2 ] [ D1 ] [ D0 ] [ Description ] Settings: 0 0 0 0 1 Select filter rate of 17.897 kHz 0 0 0 1 0 Select filter rate of 15.909 kHz 0 1 0 0 1 Select filter rate of 11.931 kHz 1 0 0 0 1 Select filter rate of 8.948 kHz 1 1 0 0 1 Select filter rate of 5.965 kHz 0 0 1 0 0 Select filter rate of 2.982 kHz Default: 0 0 0 0 0 No filter * PCM Data * Register F88h Use the PCM Data register to read samples from the A/D Converter (ADC) and write data to the D/A Converter (DAC). All 8 bits of this register are programmed as a group. Use the PCM Data Register only for direct mode transfers, not for non-DMA PCM. D7 = PCM Data Bit 7 D6 = PCM Data Bit 6 D5 = PCM Data Bit 5 D4 = PCM Data Bit 4 D3 = PCM Data Bit 3 D2 = PCM Data Bit 2 D1 = PCM Data Bit 1 D0 = PCM Data Bit 0 * Cross Channel Control * Register F8Ah Use Cross Chanel Control register to manage the PCM hardware and DMA interface; and to configure the channel connections between mixers. When the PAS-16 is reset, all bits in this register are cleared (set to 0). D7 = DMA Enable D6 = PCM Enable D5 = Mono/Stereo Mode D4 = DAC/ADC Mode D3 = Left to Left D2 = Right to Left D1 = Left to Right D0 = Right to Right DMA Enable (D7) USe this bit to turn DMA on between the PAS-16 DMA circuitry and the PC's motherboard. When D7 is set to 1, DMA can occur. When D7 is set to 0, the PAS-16's DMA circuitry is logically removed from the PC bus and other boards can use a shared DMA channel without conflict. You should set this bit only when using PCM I/O. You must set DMA Enable to 1 before programming the PC's DMA controller. [ D7 ] [ Description ] Settings: 1 Enable PAS-16 DMA 0 Disable PAS-16 DMA Default: 0 PCM Enable (D6) Use this bit to enable the PCM state machine. You must initialize the sample timer before enabling the PCM state machine. To enable the sample timer, see "Local Timer Control Register 138Bh" found later in this text file. [ D6 ] [ Description ] Settings: 1 Enable PCM state machine. 0 Disable PCM state machine. Default: 0 Mono/Stereo Mode (D5) Use this bit to set the PCM circuitry to either mono or stereo mode. In stereo mode, the first byte is left channel data and the second byte is right channel data. You can determine whether the next byte is from the left or right channel by reading the interrupt status register at address B89h. [ D5 ] [ Description ] Settings: 1 Set PCM to stereo mode 0 Set PCM to mono mode Default: 0 DAC/ADC Mode (D4) Use this bit to set the PCM circuitry to either output (DAC) or input (ADC) mode. [ D4 ] [ Description ] Settings: 1 Enable output (DAC) mode. 0 Enable input (ADC) mode. Default: 0 Left to Left (D3) Use this bit to connect the left output channel of the Input Mixer to the left input channel of the Output Mixer. [ D3 ] [ Description ] Settings: 1 Connect left output to left input 0 Disabled. Default: 0 Right to Left (D2) Use this bit to connect the right output channel of the Input Mixer to the left input channel of the Output Mixer. [ D2 ] [ Description ] Settings: 1 Connect right output to left input 0 Disabled. Default: 0 Left to Right (D1) Use this bit to connect the left output channel of the Input Mixer to the right input channel of the Output Mixer. [ D1 ] [ Description ] Settings: 1 Connect left output to right input 0 Disabled. Default: 0 Right to Right (D0) Use this bit to connect the right output channel of the Input Mixer to the right input channel of the Output Mixer. [ D0 ] [ Description ] Settings: 1 Connect right output to right input 0 Disabled. Default: 0 * Sample Rate Timer * Register 1388h Use the Sample Rate Timer to set the interval for processing PCM samples. The PAS-16 processes a sample and then waits a specific period of time before processing the next one. You use the Sample Rate Timer Register to specify this period of time. Program all 16 bits of this register by writing a value representing the interval between samples. To determine the proper programming sequence, see "Local Timer Control Register 138Bh", found later in this text file. For stereo sampling, load the timer with an interval value half that of the mono sample rate, since twice the number of samples are required per sound. Calculate interval values as follows: Interval = 1,193,180 / sample rate For example, a 22kHz sample rate would calculate as follows: Interval = 1,193,180 / 22,050 = 54 Note: Before setting the sample rate interval, be sure to select the Sample Rate Timer using Local Timer Control Register 138Bh. Also remember to set the Sample Rate Timer Gate of the Audio Filter Control Register B8Ah to 0 before programming the timer. D7 = Interval Bit 7 D6 = Interval Bit 6 . . . D0 = Interval Bit 0 * Sample Buffer Count * Register 1389h Use the Sample Buffer Count register to set number of bytes in the DMA buffer division. This register holds a 16-bit value. When using a 16-bit DMA channel, the Sample Buffer Count must be divided by two. For example, to set up a 2K DMA buffer division, you must program a count of 1K into the counter. Once the counter decrements to zero, a Sample Buffer Counter Interrupt is generated and enabled. D7 = Counter Bit 7 D6 = Counter Bit 6 . . . D0 = Counter Bit 0 Note: To determine the proper programming sequence for this register, see "Local Time Control Register 138Bh", found later in this text file. The Sample Buffer Counter Gate in the filter register (B8Ah) must be set to zero before programming the counter. * Local Time Control * Register 138Bh Use the Local Timer Control Register to enable and disable timers; set read and write modes; set timer generator modes; and select binary or BCD counting modes. D7 = Timer Select Bit 1 D6 = Timer Select Bit 0 D5 = Read/Write Bit 1 D4 = Read/Write Bit 0 D3 = Timer Mode Bit 2 D2 = Timer Mode Bit 1 D1 = Timer Mode Bit 0 D0 = Binary/BCD Timer Select (D7 and D6) Use these two bits to select the Sample Rate Counter, Sample Buffer Counter, or the Local Speaker Timer Counter. You must enable these functions before programming other PCM registers. [ D7 ] [ D6 ] [ Description ] Settings: 0 0 Select Sample Rate Timer. 0 1 Select Sample Buffer Counter. 1 0 Select Local Speaker Timer Counter Default: N/A N/A Read/Write (D5 and D4) Use these two bits to enable the 16-bit sample timer. In 16-bit mode, read or write the least significant byte first, then the most significant byte. [ D5 ] [ D4 ] [ Description ] Settings: 1 1 Enable 16-bit timer. Default: 0 0 Timer Mode (D3 through D1) Use these three bits to select a timer mode. Timer Mode must be matched to the timer you have enabled: (*) For Sample Rate Timer, set Timer Mode to >> Square Wave Generator << (*) For Sample Buffer Count, set Timer Mode to >> Rate Generator << [ D3 ] [ D2 ] [ D1 ] [ Description ] Settings: 0 1 0 Select Rate Generator (Sample Rate Timer) 0 1 1 Select Square Wave Generator (Sample Buffer Cnt) Default: 0 0 Binary/BCD (D0) Use this bit to set the timer counting mode to binary or BCD. This bit should normally be set to binary mode. [ D0 ] [ Description ] Settings: 0 Set counting mode to binary. 1 Set counting mode to BCD. Default: 0 * Sample Size Configuration * Register 8389h Use the Sample Size Configuration Register to select output sample compression ratios and 8 or 16-bit audio. D7,D6,D5,D4,D3 = Reserved D2 = 8/16-bit Audio D1 = Over Sampling Bit 1 D0 = Over Sampling Bit 0 Reserved (D7 through D3) These bits should not be programmed by application developers. Modifying any of these bits will result in unpredictable behavior by the PAS-16. 8/16-bit Audio (D2) Use this bit to select either 8 or 16-bit audio. Choosing 16-bit audio results in better sound quality (no shit). [ D2 ] [ Description ] Settings: 0 Set audio byte size to 8-bit 1 Set audio byte size to 16-bit Default: 0 Over Sampling (D1 and D0) Use these bits to select over-sampling rates of 1,2, or 4 times. [ D1 ] [ D0 ] [ Description ] Settings: 0 0 Set over sampling rate to 1X 0 1 Set over sampling rate to 2X 1 1 Set over sampling rate to 4X Default: 0 0 ---------------------------------------------------------------------------- INT 2F Function Calls The INT 2F multiplex interrupt is used by applications to talk directly to the control devices on the PAS-16 like the mixers and volume control. INT 2F calls are made directly to the MVSOUND.SYS device driver rather than through MS-DOS. This interface is non-reentrant and uses a semaphore to control entry. Return values indicate whether calls were successful or whether a collision occured with another process. Common function call method All functions share a common method for function call entry and exit. They are called through a single entry point using appropriate function numbers in register AX and function number variables in register BX, CX, and DX. Return values are placed in registers AX, BX, CX, and DX. The normal return values are listed below: Register Normal Return Value AX 'MV' if the call was successful not 'MV' if the call failed BX,CX,DX Varies by function call Example below shows the common calling method. Prototype function call entry/exit code can be found on the developer's kit disk in the MIXERS.H file. ASM include binary.inc AH 0xBC ;Mediavision INT2F identifier AX function ;Mediavision function number (0xBChh) BX (call dependent) CX (call dependent) DX (call dependent) Check for Driver * Function 0 Checks to see if the MVSOUND.SYS device driver is loaded. If the device driver is loaded, the function returns a unique set of values in variables AX and BX. Input parameters AX 0xBC00 BX 0x3F3F Return values If the driver is loaded: AX 0xBC00 (unchanged) BX 0x6D00 (M) CX 0x0076 (V) DX 0x2020 XORING CX and DX into BX returns the ASCII characters "MV". If the driver isn't loaded, values in the registers are unknown. Get DMA/IRQ/INT * Function 4 Returns the DMA, IRQ, and INT numbers that were selected when the MVSOUND.SYS driver was loaded. These numbers are specified in the Device command line in CONFIG.SYS Input Parameters AX 0xBC04 Return Values If successful: AX 'MV' BX DMA Channel number (1-3,5-7) CX IRQ Channel number (3-15) DX INT number (unused) If failed: AX doesn't contain 'MV' BX,CX,DX undefined