[linux-audio-user] Digital audio files for hardware verification
Markus Schwarzenberg
schwarzb at ipms.fraunhofer.de
Tue Oct 25 03:49:06 EDT 2005
On Mon, 24 Oct 2005 11:22:36 -0700 Mark Knecht <markknecht at gmail.com>
wrote:
> 2) Assume I've chosen a sample rate and bit-depth. Now want to
> generate a hex file with sine wave data, again with each sample
> written to its own line. Any easy way to do it?
awk is your friend (at least, mine ;-), put the following command
in a single line:
gawk -vt=1 -vf=2 -vr=220 -vd=6 'BEGIN{z=lshift(1,d-1);w=(d-1)/4+1;for(i=0;i<=r*t;i++)printf("0x%0*x\n",w,z+0.5+(z-1)*sin((f/r)*i*2*3.1415926));exit}' > outfile.dat
Arguments (-vVARIABLE=...)
VARIABLEs: t ... total time to generate/seconds
f ... frequency/Hz
r ... sample rate/Hz
d ... depth/bit
Output has an offset of 1<<(depth - 1).
--
Markus Schwarzenberg
More information about the Linux-audio-user
mailing list