LinuxDevCenter.com
oreilly.comSafari Books Online.Conferences.

advertisement


OpenAL Development: The Programmer's View
Pages: 1, 2, 3

An example: coding an object for movement and sound, part 1

Before delving into some source code, let's take a quick look at the basic services provided by the OpenAL programming interface. The API describes a collection of library services including listener and sound source orientation, a sample data specification, and an I3DL2-compliant reverberation environment description (I3DL2 is the IASIG 3D audio Level 2 specification). Loki's implementation of the API includes resource configuration scripting and functional extensibility via plugins.



All actions performed by the library work upon objects known as Buffers, Sources, Context, and Listeners. Buffers hold the actual audio data and its format characteristics (such as sample rate and length). However, a Buffer can not be played directly: it must be bound to a Source (a Source can be played), and multiple Sources can simultaneously share access to a single Buffer. At least one Context object must be created before calling any library functions: Context handles the actual audio device interface for the library, and thus for the application as well.

Incidentally, supported audio devices for Linux currently include OSS/Free (/dev/dsp), ESD (the Enlightened Sound Daemon), ALSA (the Advanced Linux Sound Architecture), SDL (the Simple DirectMedia Layer), aRts (a realtime sound synthesis environment), and WAV file output.

Each object includes attributes for the dynamic modification of a sound's perceived location and movement within a changing environment. The Listener object is the sample position within a given Context, receiving and interpreting data from multichannel audio streams generated by Sources. Its parameter list includes these attributes:

  • GAIN -- a scalar amplitude modifier.
  • POSITION -- current location in the virtual space.
  • VELOCITY -- speed and direction in the virtual world.
  • ORIENTATION -- "up" and "at" direction vector.
  • ENVIRONMENT_IASIG -- IASIG reverberation characteristics.

The Source object contains these attributes:

  • CONE_INNER_ANGLE -- inside angle of an imaginary cone expanding outwards from each ear.
  • CONE_OUTER_ANGLE -- outside angle.
  • GAIN
  • PITCH -- pitch-shifting factor.
  • POSITION
  • DIRECTION -- specifies that the Source is directional and specifies its current direction.
  • VELOCITY
  • LOOP -- loops the buffer.
  • BUFFER -- specifies the buffer for sampled sound data.
  • BYTE_LOKI -- sample byte offset in buffer.
  • ENVIRONMENT_IASIG
  • DIRECT_IASIG -- more IASIG reverberation environment variables.
  • DIRECT_HIGH_FREQUENCY_IASIG
  • ROOM_IASIG
  • ROOM_HIGH_FREQUENCY_IASIG

As might be expected, the Buffer object includes the variables describing the sample data:

  • FREQUENCY -- sampling rate, e.g., 22050 Hz.
  • BITS -- sample bit resolution.
  • CHANNELS -- channels provided by Buffer, usually only one.
  • SIZE -- sample size in bytes.

Now that we've met our objects, let's see how they're employed in a real code example on the next page.

Pages: 1, 2, 3

Next Pagearrow




Linux Online Certification

Linux/Unix System Administration Certificate Series
Linux/Unix System Administration Certificate Series — This course series targets both beginning and intermediate Linux/Unix users who want to acquire advanced system administration skills, and to back those skills up with a Certificate from the University of Illinois Office of Continuing Education.

Enroll today!


Linux Resources
  • Linux Online
  • The Linux FAQ
  • linux.java.net
  • Linux Kernel Archives
  • Kernel Traffic
  • DistroWatch.com


  • Sponsored by: