On Sun, 19 Apr 2020 01:48:34 +0200 Gerhard Zintel wrote: > 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. > Hi Gerhard, I thought I might need to abort attempts in that direction, as I used Audacity to export exactly 5 seconds of audio from one of my files and then used the player program to output a region of that's entire length to a new file. First I noticed the new file is much bigger than the file from Audacity export, but then I saw it's actually exactly (Audacity_file - 44) * 2 so there's still hope. Thanks a million for all the help. I had a quick look at using Python to make files from region information lines. It has a wave module which has 'setpos' and 'tell' methods which work in frames, so I'll get there one way or another. -- John. _______________________________________________ Linux-audio-user mailing list Linux-audio-user@xxxxxxxxxxxxxxxxxxxx https://lists.linuxaudio.org/listinfo/linux-audio-user