[linux-audio-user] Digital audio files for hardware verification

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/25/05, Markus Schwarzenberg <schwarzb@xxxxxxxxxxxxxxxxxx> wrote:
> On Mon, 24 Oct 2005 11:22:36 -0700 Mark Knecht <markknecht@xxxxxxxxx>
> 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

Very cool Markus. Thanks. This is a great example of what Unix can do
at the command line.

Thanks very much,
Mark


[Index of Archives]     [Linux Sound]     [ALSA Users]     [Pulse Audio]     [ALSA Devel]     [Sox Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux