http://qs321.pair.com?node_id=174378


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?

Thanks!
!c