home *** CD-ROM | disk | FTP | other *** search
- Audio-Handler
-
- THIS INFORMATION IS PROVIDED "AS IS"; NO WARRANTIES ARE MADE.
- ALL USE IS AT YOUR OWN RISK, AND NO LIABILITY OR
- RESPONSIBILITY IS ASSUMED.
-
- The audio-handler is the DOS Interface to the audio hardware and its
- associated audio.device. It is opened (for example) by using Open()
- with the name
-
- AUD:
-
- The mountlist entry does look like the following:
-
- /* Mountlist for Audio Handler */
-
- AUD: Handler = L:Audio-Handler
- Priority = 5
- StackSize = 2000
- GlobVec = -1
- #
-
- This is a generic device. Any channel will be allocated when the
- device is opened, but you will keep the same channel when you feed
- more data into AUD: after opening, so that sound output will be
- continuous. A different channel might be allocated if the original
- channel is stolen by another, higher priority allocation request
- by another audio handler task or another program using audio.device.
-
- Once opened, you can feed audio bytes into the handler by using the
- AmigaDOS Write() library call. This call will not block if there is
- enough space left in the sound buffer. Multiple writes are played
- sequentially without glitch. There is no limit in the size of the
- write packets.
-
- You will have enough time to supply more data because written data
- is immediately processed and the write request is replied immediately
- as long there is space in the sound buffers. Guaranteed available time
- ranges between number_of_written_bytes/frequency and about
- buffer_size/frequency, where buffer_size is at least 2 kByte.
-
- Of course you can also use the dos packet-level interface and feed
- the handler dos write packets. This has the advantage that you can
- wait for write completion as well as other signals. See [2], page 639
- for an example of using asynchronous dos packets to copy a file.
- There is no limit in the number of packets you can send simultaneously.
-
- Parameters can be given with the device name, to control the volume,
- period and priority of the sound output. The syntax is similar to
- console names:
-
- AUD:[/OPTIONS]
-
- For a quick test, feed your favourite sample to the audio-handler:
-
- copy audio-handler L:
- mount AUD: from mountlist.aud
- copy <your_favourite_sample> AUD:
-
- You can also put the AUD icon into your devs:DosDrivers drawer so
- it will be automatically mounted when your Amiga executes the
- startup-sequence.
-
-
- OPTIONS may be one or more of the following:
-
- PERIOD p
- sets the sampling period (inverse of frequency) of the waveform
- to play. The default is to play the sound at 8 kHz sampling frequency.
- The minimum period is 124 because of hardware reasons (custom chip DMA
- allocation). The maximum is 65535 (size of the WORD custom chip register).
- This value goes into the AUDxPER custom chip register. Computing this
- value is explained in [3], pages 140-143. You can also specify the
- sampling frequency instead with the option explained below.
-
- FREQENCY f
- sets the sampling frequency of the waveform to play.
- This is an alternative to specifying PERIOD. The maximum usable
- frequency is 28603, the minimum is 55. This value gives the
- number of samples (bytes) per second to play.
-
- VOLUME v
- sets the overall volume of the sound. Valid numbers range from
- 0 (silent) to 64 (loudest), which is the default.
-
- PRIORITY pri
- is the priority used for precedence managment within the
- audio.device. Audio channels with low priority may be 'stolen' by
- other applications or different invocations of the audio-handler.
- Valid priorities range from -128 (always stoppable) to 127 (unstoppable).
- The default value is 0. See [1], page 22 for a suggested value of
- priority for different types of sound.
-
- BUFFER size
- is the buffer size allocated for sound. As explained above, this
- restricts how much time you have to update the buffer (write the
- next bunch of samples). The minimum is 4kB to allow for a safe
- continuation of play, the maximum is 256kB, allowing for double
- buffers of each 128kB, which is the maximum possible for the
- Amiga hardware. The buffers use CHIP memory.
-
- DEBUG n
- This is an option not normally used which outputs event information
- about incoming packets and io requests to the serial port. n is a
- number which is added to each information to show which handler
- task is doing the output.
-
- The following are special channel requests.
-
- CHANNEL n
- is an optional number between 0 and 3 (or maybe up to the number
- of supported channels, if ever implemented).
-
- LEFT
- The sample is to be played on one of the left channels.
-
- RIGHT
- The sample is to be played on one of the right channels.
-
- STEREO
- The sample is a stereo sample (alternating bytes) and is to be
- played at one left and one right channel simultaneously.
- (Not yet implemented)
-
- 16BIT
- This is set to specify that samples are Words instead of bytes.
- This is not yet implemented, anyway, the Amiga Audio hardware
- doesn't support it.
-
-
- Examples:
-
- Playing a sample with a sampling frequency of 4 kHz on a right
- channel only:
-
- AUD:FREQUENCY4000/RIGHT
-
- Playing a sample with a smaller buffer (8 KB total, 2 buffers of
- 4 KB each) and low priority:
-
- AUD:buffer0x2000/priority-100
-
-
- Technical details:
-
- * Lattice C 5.10 was used to compile the source.
-
- * Stolen channels are not automatically given away, but the lock
- protocol is used. When another process wants to steal the channel,
- the audio handler frees the channel at the next best time.
- This assures that the sample can be played glitch-free, if
- the handler can immediately allocate another channel, and it
- guarantees no sound is lost before the handler can allocate
- a channel again.
-
- * Each invocation of AUD: creates a new handler process, but the
- code and data segment is shared between all processes (resident).
-
-
- TODO:
-
- * Implement stereo samples.
-
- * Implement 16 bit samples. Might be interesting for 16 bit sound
- cards if they have a device similar to audio.device.
-
- * If sampling is implemented at some time, the audio handler might
- also be used for reading (sampling) from audio sources. This will
- require the user process to read data fast enough to keep in pace
- with the sampler.device delivering samples. Might as well use
- the parallel.device for well known samplers.
-
- * Makefiles for other compilers. Volunteers?
-
-
- The source and executable may be freely used in projects, but a
- notice of its origin must be given. If the program is to be included
- on a CDRom or disk being sold, one sample must be given to the author.
-
- Comments, ideas, bug reports please to (e-mail preferred):
-
- Martin Brenner
- Kaiserstr. 83
- 52134 Herzogenrath
- martin@ego.oche.de
-
- References:
-
- [1] AMIGA ROM Kernel Reference Manual: Devices, 3rd edition
- [2] Ralph Babel: The Amiga Guru Book
- [3] AMIGA Hardware Reference Manual, 3rd edition
-