Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Manipulating Audio Data in Perl

by lofichurch (Beadle)
on Jun 13, 2002 at 23:49 UTC ( [id://174378]=note: print w/replies, xml ) Need Help??

in reply to Re: Manipulating Audio Data in Perl
in thread Manipulating Audio Data in Perl

Oops, guess I should've specified the ability to look backwards / forwards in the data, hence the substr(). I use the pack/unpack when I don't need to know anything other than a current sample value.

For example, without using arrays or hashes, be able to look forward in the data while processing an waveform:

assuming 16bit/mono:
my $cur_smp = 0; my $len = length($input_data) / 2; foreach (unpack("s*",$input_data)) { # take the value and add to it the sample value # five samples ahead if($len < $cur_smp + 5) { # if we don't have enough samples left to look ahead, # just go with what we've got $output .= pack("s",$_); $cur_smp++; next; } my $five_ahead = unpack("s",substr($input_data,($cur_smp + 5) * 2,2) +); $output .= pack("s",$_ + $five_ahead); $cur_smp++; next; }

That substr() is a big hit on large amounts of data, but some sort of look-ahead/back is necessary on things like multi-tap delays and variable delays, and a perl array is out of the question. I'm balking at the math knowledge necessary for PDL, since DSP is a pretty new subject for me, on the low-level aspects of the algorithms.

Would you mind sharing an example of doing the FFT with PDL?


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://174378]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-05-18 00:16 GMT
Find Nodes?
    Voting Booth?

    No recent polls found