LinuxDevCenter.com

oreilly.comSafari Books Online.Conferences.

We've expanded our Linux news coverage and improved our search! Search for all things Linux across O'Reilly!

Search
Search Tips

advertisement

Listen Print Subscribe to Linux Subscribe to Newsletters

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




Tagged Articles

Be the first to post this article to del.icio.us

Sponsored Resources

  • Inside Lightroom
Advertisement

Sponsored by:

O'Reilly Media

©2009, O'Reilly Media, Inc.
(707) 827-7000 / (800) 998-9938
All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.
About O'Reilly
Academic Solutions
Authors
Contacts
Customer Service
Jobs
Newsletters
O'Reilly Labs
Press Room
Privacy Policy
RSS Feeds
Terms of Service
User Groups
Writing for O'Reilly
Content Archive
Business Technology
Computer Technology
Google
Microsoft
Mobile
Network
Operating System
Digital Photography
Programming
Software
Web
Web Design
More O'Reilly Sites
O'Reilly Radar
Ignite
Tools of Change for Publishing
Digital Media
Inside iPhone
O'Reilly FYI
makezine.com
craftzine.com
hackszine.com
perl.com
xml.com

Partner Sites
InsideRIA
java.net
O'Reilly Insights on Forbes.com