Audio programming

From wikiPodLinux

The iPod is an audio object, so programming audio applications for iPod should be really cool, right? Right.


Audio within a podzilla2 module

Podzilla2 modules can output sound. Note that Podzilla2 modules can't be threaded, so there's a significant problem if you want to output continuous sound yet be able to respond to user interaction (e.g. the ability to exit the module!).

API

Podzilla2's API (http://www.get-linux.org/~oremanj/t/pz2-api.pdf) includes some wrapper functions for the audio interface, allowing for audio input and output. The following example is just about outputting audio from a pz2 module.

To open the DSP for audio output, use

 dspret = pz_dsp_open(&my_dspz, PZ_DSP_LINEOUT);

where my_dspz is a variable of type pz_dsp_st. dspret will hold an integer indicating success or failure.

To write data to the audio output, use

 pz_dsp_write(&my_dspz, outbuf, outbufsize);

where outbuf is a reference to an array of shorts, and outbufsize is the number of bytes you want to output (typically equal to the number of elements in the array multiplied by sizeof(short)).

Then to free the DSP, use

 pz_dsp_close(&my_dspz);

You need to do this when you're finished, to make sure that your module and other modules can access the DSP in future.

Limits

According to this test by Dan Stowell (http://mcld.co.uk/ipodlinux/), a podzilla2 module can produce something like 36 sinewaves simultaneously. It's not clear what imposes this limit, but possibly it's due to the limited RAM.

Navigation



  • Google Search (http://www.google.com/custom?sa=Google+Search&cof=S%3Ahttp%3A%2F%2Fwww.ipodlinux.org%3BVLC%3Apurple%3BAH%3Acenter%3BBGC%3Awhite%3BLH%3A141%3BLC%3Ablue%3BL%3Ahttp%3A%2F%2Fipodlinux.org%2Fstylesheets%2Fimages%2Fwiki.png%3BALC%3Ablue%3BLW%3A128%3BT%3Ablack%3BAWFID%3A70a74ab66f4d59ae%3B&domains=ipodlinux.org&sitesearch=ipodlinux.org)