ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/PDL-Audio/audio.pd
(Generate patch)

Comparing PDL-Audio/audio.pd (file contents):
Revision 1.8 by root, Tue Nov 8 18:48:47 2005 UTC vs.
Revision 1.9 by root, Tue Nov 8 18:56:06 2005 UTC

293=head2 raudio path, [option-hash], option => value, ... 293=head2 raudio path, [option-hash], option => value, ...
294 294
295Reads audio data into the piddle. Options can be anything, most useful 295Reads audio data into the piddle. Options can be anything, most useful
296values are C<filetype>, C<rate>, C<channels> and C<format>. The returned 296values are C<filetype>, C<rate>, C<channels> and C<format>. The returned
297piddle is represents "time" in the outer dimension, and samples in the 297piddle is represents "time" in the outer dimension, and samples in the
298inner (i.e. scalars for mono files, 2-vectors for stereo files). 298inner (i.e. scalars for mono files, 2-vectors for stereo files):
299
300 [ [left0, right0], [left1, right1], [left2, right2], ...]
299 301
300 # read any file 302 # read any file
301 $pdl = raudio "file.wav"; 303 $pdl = raudio "file.wav";
302 # read a file. if it is a raw file preset values 304 # read a file. if it is a raw file preset values
303 $pdl = raudio "file.raw", filetype => FILE_RAW, rate => 44100, channels => 2; 305 $pdl = raudio "file.raw", filetype => FILE_RAW, rate => 44100, channels => 2;
304 306
305=head2 waudio pdl, [option-hash], option => value, ... 307=head2 waudio pdl, [option-hash], option => value, ...
306 308
307Writes a pdl as a file. The path is taken from the header (or the options), e.g.: 309Writes a pdl as a file. See L<raudio> for options and format. The path and
310other metadata is taken from the header, whcih cna be overwritten using
311options, e.g.:
308 312
309 # write a file, using the header of another piddle 313 # write a file, using the header of another piddle
310 $pdl->waudio ($orig_file->gethdr); 314 $pdl->waudio ($orig_file->gethdr);
311 # write pdl as au file, take rate from the header 315 # write pdl as .au file, take rate from the header
312 $pdl->waudio (path => "piddle.au", filetype => FILE_AU, format => FORMAT_16_LINEAR; 316 $pdl->waudio (path => "piddle.au", filetype => FILE_AU, format => FORMAT_16_LINEAR;
313 317
314=cut 318=cut
315 319
316# read a sound file 320# read a sound file
364 $hdr{rate} ||= 44100; 368 $hdr{rate} ||= 44100;
365 369
366 ($pdl, $channels, $frames) = _audio_make_plain $pdl->convert(long); 370 ($pdl, $channels, $frames) = _audio_make_plain $pdl->convert(long);
367 371
368 1 <= $channels && $channels <= 2 372 1 <= $channels && $channels <= 2
369 or croak "can only write mono or stereo (one or two channel) files, not $channels channel files\n"; 373 or croak "can only write mono or stereo (one or two channel) files, not $channels channel files";
370 374
371 my $fd = open_sound_output $hdr{path}, $hdr{rate}, $channels, $hdr{format}, $hdr{filetype}, $hdr{comment}; 375 my $fd = open_sound_output $hdr{path}, $hdr{rate}, $channels, $hdr{format}, $hdr{filetype}, $hdr{comment};
372 $fd >= 0 or barf "$hdr{$path}: ".audio_error_name audio_error; 376 $fd >= 0 or barf "$hdr{$path}: ".audio_error_name audio_error;
373 $pdl->clump(-1)->write_sound($fd, $channels, $frames) 377 $pdl->clump(-1)->write_sound($fd, $channels, $frames)
374 >= 0 or barf "$path: ".audio_error_name audio_error; 378 >= 0 or barf "$path: ".audio_error_name audio_error;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines