Inside Macintosh: Sound Manager

| Previous | Chapter contents | Chapter top | Section top |

Legacy Documentclose button

Important: Sound Input Manager is deprecated as of Mac OS X v10.5. For new audio development in Mac OS X, use Core Audio. See the Audio page in the ADC Reference Library.

Sound Input Interrupt Routines

You can specify a sound input interrupt routine in the interruptRoutine field of the sound input parameter block that your application uses to initiate asynchronous recording directly from a device. Because the SPBRecordToFile function uses sound input interrupt routines to enable it to record sound data to disk during recording, you can use sound input interrupt routines only with the SPBRecord function.

MySIInterruptRoutine

A sound input interrupt routine has the following syntax:

PROCEDURE MySIInterruptRoutine;

DESCRIPTION

A sound input device driver executes the sound input interrupt routine associated with an asynchronous sound recording whenever the driver's internal buffers are full. The internal buffers contain raw samples taken directly from the input device. The interrupt routine can thus modify the samples in the buffer in any way it requires. After your sound input interrupt routine finishes processing the data, the sound input device driver compresses the data (if compression is enabled) and copies the data into your application's buffer.

SPECIAL CONSIDERATIONS

If your sound input interrupt routine accesses your application's global variables, it must ensure that the A5 register contains the address of the boundary between the application global variables and the application parameters. Your application can pass the value of the A5 register to the sound input interrupt routine in the userLong field of the sound input parameter block. For more information on ensuring the validity of the A5 register, see the chapter "Memory Management Utilities" in Inside Macintosh: Memory .

ASSEMBLY-LANGUAGE INFORMATION

Sound input interrupt routines are sometimes written in assembly language to maximize real-time performance in recording sound. On entry, registers are set up as follows:

Registers on entry

A0

Address of the sound parameter block passed to SPBRecord

A1

Address of the start of the sample buffer

D0

Peak amplitude for sample buffer if metering is on

D1

Size of the sample buffer in bytes

If you write a sound input interrupt routine in a high-level language like Pascal or C, you might need to write inline code to copy variables from the registers into local variables that your application defines.

Because a sound input interrupt routine is called at interrupt time, it must preserve all registers.

 


© 1999 Apple Computer, Inc.

Inside Macintosh: Sound Manager

| Previous | Chapter contents | Chapter top | Section top |

Legacy Documentclose button

Important: Sound Input Manager is deprecated as of Mac OS X v10.5. For new audio development in Mac OS X, use Core Audio. See the Audio page in the ADC Reference Library.