PDL::Audio not working for me

K

kieran

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
samples"
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?
Kieran
 
J

Joost Diepenmaat

kieran said:
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
samples"
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?

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 :)
 
K

kieran

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 :)

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,
Kieran
 
Z

zentara

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,
Kieran

This works here for me.

#!/usr/bin/perl
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
);
$i++;
}
( audiomix @mix )->scale2short->playaudio;
}
__END__
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top