Hi Sergei.
Thanks again for reporting this.
I added a fix soon after I responded to this ticket which may or may not
be causing the behavior you are seeing. Specifically, I added "use
bytes". Possibly not related, but it should cause problems to omit it:
ski@portege:~/mysrc/skix/cpan/Audio-Wav$ diff -w -u yours mine
--- yours 2010-07-01 10:26:04.183776886 -0400
+++ mine 2010-07-01 10:26:41.533773025 -0400
@@ -4,9 +4,15 @@
if ( $self -> {'use_offset'} ) {
return $self -> write_raw( pack 'C'.$channels, map { $_ + $self ->
{'use_offset'} } @args );
} else {
-#return $self -> write_raw( pack 'V'.$channels, @args );
+ #TODO: performance: when we move to _init_write_sub, just use:
+ #32: pack 'V1', ...
+ #24: substr pack('V1', ...), 3
+ #16: pack 'v1', ...
my $bytes_per_sample = $self->{'details'}->{'bits_sample'} >> 3;
+ use bytes;
my @samples = map { substr pack('V1', $_), 0, $bytes_per_sample } @args;
+#warn "bits/sample: $self->{'details'}->{'bits_sample'}, bytes/sample:
$bytes_per_sample";
+#warn "output samples(".scalar @samples."): ".join "-", map ord, split
//, join '', @samples;
return $self -> write_raw( @samples );
}
}
If that doesn't fix the problem, can you boil your program down to a
(preferably small ;-) ) script that shows the errant behavior?
Also, to be sure we are on the same page, please use r2473 directly from
SVN - I've attached it here for your convenience. And if you do
encounter problems, please add and uncomment the warn statements in the
above diff (lines 279 and 280 in the attached tarball / r2473).
Thanks!
Brian
On Sun Jun 27 18:35:34 2010, sergstesh wrote:
Show quoted text>
>
> --- On Thu, 6/3/10, Brian Szymanski via RT <bug-Audio-Wav@rt.cpan.org>
> wrote:
>
> > From: Brian Szymanski via RT <bug-Audio-Wav@rt.cpan.org>
> > Subject: [rt.cpan.org #57093] Resolved: problem with bits per sample
> other than 16
> > To: sergstesh@yahoo.com
> > Date: Thursday, June 3, 2010, 9:54 PM
> > <URL:
https://rt.cpan.org/Ticket/Display.html?id=57093 >
> >
> > According to our records, your request has been resolved.
> > If you have any
> > further questions or concerns, please respond to this
> > message.
> >
>
> I have used (hopefully correctly) the fix you've suggested:
>
> 266 sub write {
> 267 my ($self, @args) = @_;
> 268 my $channels = $self -> {'details'} -> {'channels'};
> 269 if ( $self -> {'use_offset'} ) {
> 270 return $self -> write_raw( pack 'C'.$channels, map {
> $_ + $self -> {'use_offset'} } @args );
> 271 } else {
> 272 #return $self -> write_raw( pack 'V'.$channels, @args
> );
> 273 my $bytes_per_sample = $self->{'details'}-
> >{'bits_sample'} >> 3;
> 274 my @samples = map { substr pack('V1', $_), 0,
> $bytes_per_sample } @args;
> 275 return $self -> write_raw( @samples );
> 276 }
> 277 }
> .
>
> The fix doesn't work for me - when I run the same program I used to
> run
> with my fix (now commented out on line #272), I'm getting a bunch of
>
> "
> Argument "\0\0\0\0" isn't numeric in addition (+) at
> /home/sergei/my_perl-5.10.1/lib/site_perl/5.10.1/Audio/Wav/Write.pm
> line 307.
> "
>
> messages, here is the context for line #307:
>
> 292 sub write_raw {
> 293 my $self = shift;
> 294 my $data = shift;
> 295 my $len = shift;
> 296 $len = length $data unless $len;
> 297 return unless $len;
> 298 my $wrote = $len;
> 299 if ( $self -> {'use_cache'} ) {
> 300 $self -> {'write_cache'} .= $data;
> 301 my $cache_len = length $self -> {'write_cache'};
> 302 $self -> _purge_cache( $cache_len ) unless $cache_len
> < $self -> {'cache_size'};
> 303 } else {
> 304 $wrote = syswrite $self -> {'handle'}, $data, $len;
> 305 }
> 306
> 307 $self -> {'pos'} += $wrote;
> 308 return $wrote;
> 309 }
> .
>
> I think the bug should be reopened.
>
> Thanks,
> Sergei.
>
>
>
>