Re: Input to aplay to make a file instead?

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

 



Hi again,

On 19/04/2020 00:39, Gerhard Zintel wrote:
On 18/04/2020 12:05, John Murphy wrote:
If I simply '>' the input, which was going to aplay, to a file, it's
done in a flash. Unplayable, but the file contains data. Could I write
a header first somehow? Or a container format would be OK.

there are for sure "correct" ways to do it. If you want to use pure bash magic here you are:
Header of a wave file contains 44 byte. To extract it to a file use:

head -c 44 original.wav > header.bin

Now you can use your file from above (let's call it part.raw) and use:

cat header.bin part.raw > newname.wav

You should be able to play the new file. Be aware that the header is correct
except for the length information. You might fix this with
wavfix (https://github.com/agfline/wavfix). Furthermore if your parts are
not cut at a sample boundary (e.g. a normal wav file is stereo 16
bit per channel thus 4 byte per sample) you will get noise.

One further remark. The wave header has two length information at byte offset 5 and 41
(see http://www.topherlee.com/software/pcm-tut-wavformat.html). You can use dd like described
here (https://unix.stackexchange.com/questions/214820/patching-a-binary-with-dd) to patch
the created file newname.wav afterwards to inject the correct length information.

The length information has to be in binary representation. You could use the method described here
(https://stackoverflow.com/questions/9955020/how-to-write-integer-to-binary-file-using-bash)
to get the 4 byte representation of file newname.wav

A lot of shell magic but it seems to work.

Gerhard
_______________________________________________
Linux-audio-user mailing list
Linux-audio-user@xxxxxxxxxxxxxxxxxxxx
https://lists.linuxaudio.org/listinfo/linux-audio-user




[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