amplifying an audio signal

Please discuss general Delphi programming topics here.

amplifying an audio signal

Postby stef » September 18th, 2009, 8:11 am

hello,

On laptops, the recorded sound is often too weak.
So when I playback a recorded sound, I want to give the signal some extra gain.
Without knowing too many details about Wave Audio Package (and streams)
(other than that it's great package ;-)
I wrote the code below,
which give a read stream error.

Can anyone give me simple solution ?
(it concerns small audio snippets, so they always fit in the array "display_ar")

thanks,
Stef Mientki

Nsamp := WaveStorage_part.Wave.DataSize ; //length in bytes
Nsamp:=Nsamp div 2;

WaveStorage_part.Wave.BeginRead;
WaveStorage_part.WaveStream[0].ReadBuffer( display_ar, 2*Nsamp); // in bytes
WaveStorage_part.Wave.EndRead;

for i:= 0 to NSamp-1 do
display_ar[i] := 10 * display_ar[i] ;

WaveStorage_part.Wave.BeginRewritePCM (WaveStorage_part.Wave.PCMFormat);
WaveStorage_part.WaveStream[0].WriteBuffer( display_ar, 2*Nsamp); // in bytes
WaveStorage_part.Wave.EndReWrite;

WaveStorage_part.Wave.BeginRead;
WaveStorage_part.WaveStream[0].ReadBuffer( display_ar, 2*Nsamp); // in bytes
.... In the above line I get a stream read error
WaveStorage_part.Wave.EndRead;
stef
Active Member
Active Member
 
Posts: 18
Joined: July 15th, 2007, 1:35 pm

Re: amplifying an audio signal

Postby Kambiz » September 18th, 2009, 1:43 pm

Simply use ChangeVolume method of TWaveStreamAdaptor class.

For example, the following line of code increases the volume by 50%:

WaveStorage_part.Wave.ChangeVolume(50);
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Re: amplifying an audio signal

Postby stef » September 18th, 2009, 2:16 pm

thanks Kambiz,

unbelievable how simple (sometimes) things can be.

cheers,
Stef
stef
Active Member
Active Member
 
Posts: 18
Joined: July 15th, 2007, 1:35 pm


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 7 guests

cron