[paranoia] splitting sound files?
Christopher Jones
cjones12 at tulane.edu
Wed Feb 14 19:29:30 PST 2001
Wow. Thanks so much. I won't have a chance to try this right away, but I'll
give it a whirl first chance. Thanks again.
On Wed, 14 Feb 2001, you wrote:
> i haven't heard of a program that actually does such a thing, but it is
> possible. one would copy out the last 'slice' in the file, then truncate()
> the original file, continue until managable size.
>
> not that i suggest you use it if you care about your file, which in
> this case you do, but here is a quick script that is sposed to be
> able to do this.. and yes, it's poorly written. if i knew someone who
> wrote a decent one, i'd sure say so :/
>
> i did test this on a 700k file,splitting into 64k chunks, and
> it did work... reassembly matched the original.. so, as long as you
> have chunksize free, it'll work...
>
> './slice.pl termcap 64' creates the following files:
> -rw-rw-r-- 1 root root 65536 Feb 14 18:14 termcap.0000
> -rw-rw-r-- 1 root root 65536 Feb 14 18:14 termcap.0001
> -rw-rw-r-- 1 root root 65536 Feb 14 18:14 termcap.0002
> -rw-rw-r-- 1 root root 65536 Feb 14 18:14 termcap.0003
> -rw-rw-r-- 1 root root 65536 Feb 14 18:14 termcap.0004
> -rw-rw-r-- 1 root root 65536 Feb 14 18:14 termcap.0005
> -rw-rw-r-- 1 root root 65536 Feb 14 18:14 termcap.0006
> -rw-rw-r-- 1 root root 65536 Feb 14 18:14 termcap.0007
> -rw-rw-r-- 1 root root 65536 Feb 14 18:14 termcap.0008
> -rw-rw-r-- 1 root root 65536 Feb 14 18:14 termcap.0009
> -rw-rw-r-- 1 root root 45485 Feb 14 18:14 termcap.0010
>
> another possible issue, seek/truncate probly won't work if you file is
> over 2gigs long..
>
> #!/usr/bin/perl
>
> if ($#ARGV < 1) {
> print "usage: $0 <filename> <chunksize(KB)>\n";
> }
> ($infile, $chunksize) = @ARGV;
> $chunksize *= 1024;
> open(F, $infile) or die "can't open $infile: $!";
> @st = stat(F);
> $size = $st[7];
> $chunks = $size / $chunksize;
> printf "%s is %d bytes, %f chunks\n", $infile, $size, $chunks;
> print "press enter to continue, control-c to exit\n";
> $junk = <STDIN>;
>
> $seek = 0;
> $chunknum = 0;
> while ($seek < $size) {
> push(@chunks, $seek);
> printf "%s.%04d will be from %d to %d\n", $infile, $chunknum, $seek,
> $seek + $chunksize;
> $seek += $chunksize;
> $chunknum++;
> }
> print "press enter to continue, control-c to exit\n";
> $junk = <STDIN>;
>
> $chunknum--;
> while ($chunknum > -1) {
> $outfile = sprintf("%s.%04d", $infile, $chunknum);
> $pos = $chunks[$chunknum];
> printf "writing to %s from %s\n", $outfile, $pos;
> seek(F, $pos, 0) or die "Can't seek: $!";
> open(OUT, ">$outfile") or die "can't write $outfile: $!";
> while (read(F,$buf,1024) > 0) {
> print OUT $buf or die "can't write to $outfile: $!";
> }
> close OUT;
> truncate($infile, $pos) or die "Can't truncate $infile: $0";
> $chunknum--;
> }
> close F;
>
>
> On Wed, Feb 14, 2001 at 05:02:13PM -0600, Christopher Jones wrote:
> > Ok. This is good. I didn't even know about the head command, though I knew
> > about the others. But I am a bit unsure about this... the point is to cut, not
> > copy parts of the file. Looking at the commands quoted here, I see that dd
> > copies, not cuts, big.wav.
> >
> > The point is, given -very- limited hd space, not to effectively double the file
> > by duplicating the whole thing in bits. So when I make part0.wav, big.wav
> > should get smaller.
> >
> > I haven't looked into xwave, but in my searching around I found what sounds like
> > the command-line equivalent, called soundgrab. But again, this copies a part of
> > the file-- doesn't cut it.
> >
> > On Wed, 14 Feb 2001, you wrote:
> > > On 2001-02-14 08:29 -0500, Dale E Martin wrote:
> > >
> > > > If you prefer something with a GUI, and the capability to listen to what
> > > > you're splitting, I've used "xwave" with mixed results in the past. I used
> > > > it once to take a tape I had sampled and split it back into individual
> > > > songs. With such a large .wav file, it crashed on me a couple of times,
> > > > and refused to start correctly a couple of times, but eventually I got it
> > > > to work.
> > >
> > > Yes. Xwave segfaults if you try to cut a block that contains the
> > > last sample.
> > >
> > > --
> > > André Majorel <amajorel at teaser.fr>
> > > http://www.teaser.fr/~amajorel/
> > >
> > > --- >8 ----
> > > List archives: http://www.xiph.org/archives/
> > > Paranoia homepage: http://www.xiph.org/paranoia/
> > > To unsubscribe from this list, send a message to 'paranoia-request at xiph.org'
> > > containing only the word 'unsubscribe' in the body. No subject is needed.
> > > Unsubscribe messages sent to the list will be ignored/filtered.
> >
> > --- >8 ----
> > List archives: http://www.xiph.org/archives/
> > Paranoia homepage: http://www.xiph.org/paranoia/
> > To unsubscribe from this list, send a message to 'paranoia-request at xiph.org'
> > containing only the word 'unsubscribe' in the body. No subject is needed.
> > Unsubscribe messages sent to the list will be ignored/filtered.
>
> --- >8 ----
> List archives: http://www.xiph.org/archives/
> Paranoia homepage: http://www.xiph.org/paranoia/
> To unsubscribe from this list, send a message to 'paranoia-request at xiph.org'
> containing only the word 'unsubscribe' in the body. No subject is needed.
> Unsubscribe messages sent to the list will be ignored/filtered.
--- >8 ----
List archives: http://www.xiph.org/archives/
Paranoia homepage: http://www.xiph.org/paranoia/
To unsubscribe from this list, send a message to 'paranoia-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the Paranoia
mailing list