Forums

Any PCM audio amplitude manipulation libraries available?

Started by Verified by Kerberos September 2, 2003
Hi,

I'm working on an embedded ARM board running Linux 2.4.18. The
processor is a Hynix 7201 based on ARM720T core, running at 60MHz (25
BogoMIPS), with a Piccolo DSP.

I want to change audio volume by software, however the board
doesnt have any hardware mixer for audio. So changing the volume via
OSS etc. is not possible.

Since I require only to playback WAV PCM files, i figure that instead
of using a hardware mixer, i can amplify/de-amplify the signals inside
the file as required, to get the required volume. I'm not quite sure
how to do this. Does the transformation have to be applied before
playing the WAV file or while the file is being played, at real-time?

Can someone please point me to libraries that allow amplifications of
signals stored in a PCM file? 

TIA,
Deathstar


deathstar@altern.org (Deathstar) wrote in message news:<yviznhnw07t.fsf@jpff.cs.bath.ac.uk>...
> Hi, > > I'm working on an embedded ARM board running Linux 2.4.18. The > processor is a Hynix 7201 based on ARM720T core, running at 60MHz (25 > BogoMIPS), with a Piccolo DSP. > > I want to change audio volume by software, however the board > doesnt have any hardware mixer for audio. So changing the volume via > OSS etc. is not possible. > > Since I require only to playback WAV PCM files, i figure that instead > of using a hardware mixer, i can amplify/de-amplify the signals inside > the file as required, to get the required volume. I'm not quite sure > how to do this. Does the transformation have to be applied before > playing the WAV file or while the file is being played, at real-time? > > Can someone please point me to libraries that allow amplifications of > signals stored in a PCM file? > > TIA, > Deathstar
Look for the sox project. Sox is pretty much the swiss army knife of audio processing. It is GNU GPL, so you can lift code from it, provided that your project is GPL or inhouse. Cheers, Herman http://www.AerospaceSoftware.com
> Since I require only to playback WAV PCM files, i figure that instead > of using a hardware mixer, i can amplify/de-amplify the signals inside
I don't know if you'll find libraries for this, because it is kind of trivial. If you're playing back in software (with interrupt-driven or polled loops) then you can apply the volume in realtime to each sample word being pushed to the DAC. If you're using DMA then you'll have to render the entire DMA buffer before starting the DMA op. The arithmetic is trivial, at least as long as you don't care about additional aliasing artifacts being introduced into the output. No significant extra CPU loading. How many bits of sample do you have to play with? How many volume levels do you require? Is this signed or unsigned audio (i.e. is the centerline 0 or 128?) The exact details of what you subtract/shift vary according to the nature of the sampled data, but it should be fairly obvious how to achieve it. You might want to search for MOD playback sourcecode for PCs. This will show you very nicely how to implement software volume ramping to at least 64 levels (with 8-bit sample data).
Deathstar wrote:
> > Hi, > > I'm working on an embedded ARM board running Linux 2.4.18. The > processor is a Hynix 7201 based on ARM720T core, running at 60MHz (25 > BogoMIPS), with a Piccolo DSP. > > I want to change audio volume by software, however the board > doesnt have any hardware mixer for audio. So changing the volume via > OSS etc. is not possible. > > Since I require only to playback WAV PCM files, i figure that instead > of using a hardware mixer, i can amplify/de-amplify the signals inside > the file as required, to get the required volume. I'm not quite sure > how to do this. Does the transformation have to be applied before > playing the WAV file or while the file is being played, at real-time? > > Can someone please point me to libraries that allow amplifications of > signals stored in a PCM file? > > TIA, > Deathstar
Read the file, multiply each data word by a factor, and write the result to a new file. Be careful about overflowing or losing precision. Jerry -- Engineering is the art of making what you want from things you can get. &#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;
deathstar@altern.org (Deathstar) wrote in message news:<yviznhnw07t.fsf@jpff.cs.bath.ac.uk>...
> Hi, > > I'm working on an embedded ARM board running Linux 2.4.18. The > processor is a Hynix 7201 based on ARM720T core, running at 60MHz (25 > BogoMIPS), with a Piccolo DSP. > > I want to change audio volume by software, however the board > doesnt have any hardware mixer for audio. So changing the volume via > OSS etc. is not possible. > > Since I require only to playback WAV PCM files, i figure that instead > of using a hardware mixer, i can amplify/de-amplify the signals inside > the file as required, to get the required volume. I'm not quite sure > how to do this. Does the transformation have to be applied before > playing the WAV file or while the file is being played, at real-time?
Do the multiplications on blocks of data while playing. Note that you have to linearize the data before multiplying.
> > Can someone please point me to libraries that allow amplifications of > signals stored in a PCM file?
Search the web for the sox project. Cheers, Herman http://www.AerospaceSoftware.com