PDL::Audio not working for me

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi all,
I am relatively new to perl and have just begun using the PDL::Audio
module. I am having trouble getting basic functionality working, for
example "describe_audio" should return the number of samples in an
audio file. I have tried using the following code to find the number
of sample in a wav file.

use PDL;
use PDL::Audio;

$pdl = raudio "hello1.wav";
print "\n\n", describe_audio pdl, "\n";

The output i get for any wav file is as follows:  "mono sound with
where there should be either mono or stereo (I always get mono, even
for stereo files)
Also there should be a number of samples such as "mono file with
1234567 samples", but it is always blank.
Any suggestions?

Re: PDL::Audio not working for me

Quoted text here. Click to load it

I don't use PDL::Audio, if all you want is to check out the meta-data on
an audio file, and/or read the sample data, there are more modules out
there if PDL::Audio doesn't work for you.

I would suggest Audio::SndFile it should work for both data and
meta-data, but it needs libsndfile and I'm biased since I wrote it :-)

Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl /

Re: PDL::Audio not working for me

Quoted text here. Click to load it

Hi Joost, thank for the reply, I had planned to use PDL::Audio ofr
filtering, FFT, cut_leading _silence, etc...
I am having problems with any of the functions i use from that module.
It would be great to see some examples of this code working as there
is a serious lack of documentation for this module. If anyone has used
this module successfully any sample code woul be a great help.
Best regards,

Re: PDL::Audio not working for me


Quoted text here. Click to load it

This works here for me.

use warnings;
#use strict;
use PDL::Audio;
use PDL::Audio::Scales qw(scale_list get_scale);

my @names = PDL::Audio::Scales::scale_list();
print "@names\n";
# returns [1 1 1.5 5 7 8 8.5 1.2]
#$scale = get_scale arist_chromrej;
#print "$scale\n";
#($scale, $desc) = get_scale arist_chromrej;
# sets $desc to "Aristoxenos Rejected Chromatic, 6 + 3 + 21 parts 7"
#print "$scale $desc\n";

sub osc {
   my ( $dur, $freq ) = @_;
   ( gen_asymmetric_fm $dur, $freq, 0.9, 0.6 ) *
    ( gen_env $dur, [ 0, 1, 2, 9, 10 ], [ 0, 1, 0.6, 0.3, 0 ] );

for ( @names ) {
   my ( $scale, $desc ) = PDL::Audio::Scales::get_scale( $_ );
   my @mix;
   my $i;
   print "$_ [$desc] $scale\n";
   my $l = $scale->list;

   for ( ( $scale * 880 )->list ) {
      push @mix, ( $i * 0.2 * 44100, osc 0.3 * 44100, $_ / 44100 );
      push @mix, ( $l * 0.2 * 44100 + 0.1, osc 0.8 * 44100, $_ / 44100
   ( audiomix @mix )->scale2short->playaudio;

Site Timeline