Initial commit
[audio-libsamplerate.git] / t / Audio-LibSampleRate.t
CommitLineData
27013d8f
MG
1#!/usr/bin/perl
2use strict;
3use warnings;
4use constant EPSILON => 0.1;
5
6use Test::More tests => 7;
7BEGIN { use_ok('Audio::LibSampleRate') };
8
9sub isf {
10 my ($xx, $yy, $name) = @_;
11 for (0 .. $#{$xx}) {
12 my ($x, $y) = ($xx->[$_], $yy->[$_]);
13 do { diag "$x != $y"; return fail $name } if abs ($x - $y) > EPSILON;
14 }
15 pass $name;
16}
17
18isf [src_simple([1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6], 2)], [1.1, 1.1, 1.7, 1.7, 1.9, 1.9, 2.2, 2.2, 3.1, 3.1, 3.8, 3.8], 'src_simple doubling';
19isf [src_simple([1..10], 1/2, SRC_LINEAR, 1)], [1, 2, 4, 6, 8], 'src_simple halving';
20
21my @out;
22my $src = Audio::LibSampleRate->new(SRC_ZERO_ORDER_HOLD, 1);
23@out = ($src->process([1.. 5], 1/2), $src->process([6..10], 2, 1));
24isf \@out, [1, 2, 4, 6, 8, 9], 'process, smooth transition';
25
26$src->reset;
27@out = $src->process([1..5], 1/2);
28$src->set_ratio(2);
29push @out, $src->process([6..10], 2, 1);
30isf \@out, [1, 2, 4, 6, 6, 7, 7, 8, 8, 9, 9, 10], 'process, step transition';
31
32is src_get_name(SRC_SINC_FASTEST), 'Fastest Sinc Interpolator', 'src_get_name';
33like src_get_description(SRC_SINC_FASTEST), qr/band limited sinc interpolation/i, 'src_get_description';
This page took 0.010027 seconds and 4 git commands to generate.