PDL::Audio not working for me

Discussion in 'Perl Misc' started by kieran, Oct 17, 2008.

  1. kieran

    kieran Guest

    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
    kieran, Oct 17, 2008
    #1
    1. Advertising

  2. kieran <> writes:

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

    --
    Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
    Joost Diepenmaat, Oct 17, 2008
    #2
    1. Advertising

  3. kieran

    kieran Guest

    On Oct 17, 8:01 pm, Joost Diepenmaat <> wrote:
    > kieran<> writes:
    > > Hi all,
    > > I am relatively new toperland 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 :)
    >
    > --
    > Joost Diepenmaat | blog:http://joost.zeekat.nl/| work:http://zeekat.nl/


    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
    kieran, Oct 20, 2008
    #3
  4. kieran

    zentara Guest

    On Mon, 20 Oct 2008 06:35:34 -0700 (PDT), kieran <>
    wrote:

    >On Oct 17, 8:01 pm, Joost Diepenmaat <> wrote:
    >> kieran<> writes:


    >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__
    zentara, Oct 21, 2008
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Junmou Zhang
    Replies:
    0
    Views:
    1,408
    Junmou Zhang
    Jul 10, 2003
  2. Mark Ohlund

    PDL function call failing

    Mark Ohlund, May 2, 2004, in forum: Perl
    Replies:
    1
    Views:
    467
    Slaven Rezic
    May 2, 2004
  3. aeonsun
    Replies:
    2
    Views:
    417
    Luc The Perverse
    Mar 11, 2007
  4. Keflavich
    Replies:
    0
    Views:
    120
    Keflavich
    Feb 15, 2007
  5. sick dick
    Replies:
    0
    Views:
    383
    sick dick
    Apr 3, 2006
Loading...

Share This Page