1 | $VERSION = '1.1'; |
1 | $VERSION = '1.2'; |
2 | |
2 | |
3 | pp_setversion $VERSION; |
3 | pp_setversion $VERSION; |
4 | pp_beginwrap (); # force error with older PPs |
4 | pp_beginwrap (); # force error with older PPs |
5 | |
5 | |
6 | pp_addpm {At => Top}, <<'EOD'; |
6 | pp_addpm {At => Top}, <<'EOD'; |
… | |
… | |
14 | use PDL::Audio; |
14 | use PDL::Audio; |
15 | |
15 | |
16 | =head1 DESCRIPTION |
16 | =head1 DESCRIPTION |
17 | |
17 | |
18 | Oh well ;) Not much "introductory documentation" has been written yet :( |
18 | Oh well ;) Not much "introductory documentation" has been written yet :( |
|
|
19 | |
|
|
20 | Installing this distribution also installs F<pdlaudio-demo>, which |
|
|
21 | showcases some of the oeprators, and C<pdlaudio-birds>, which imites some |
|
|
22 | bird calls with PDL::Audio. You should study them to get the hang of it. |
19 | |
23 | |
20 | =head2 NOTATION |
24 | =head2 NOTATION |
21 | |
25 | |
22 | Brackets around parameters indicate that the respective parameter is |
26 | Brackets around parameters indicate that the respective parameter is |
23 | optional and will be replaced with some default value when absent (or |
27 | optional and will be replaced with some default value when absent (or |
… | |
… | |
32 | |
36 | |
33 | # Syntax: gen_oscil duration*, frequency/ |
37 | # Syntax: gen_oscil duration*, frequency/ |
34 | $signal = gen_oscil 2*HZ, 440/HZ; |
38 | $signal = gen_oscil 2*HZ, 440/HZ; |
35 | # with a sampling frequency of 44100 Hertz: |
39 | # with a sampling frequency of 44100 Hertz: |
36 | $signal = gen_oscil 2*44100, 440/44100; |
40 | $signal = gen_oscil 2*44100, 440/44100; |
|
|
41 | |
|
|
42 | print describe_audio $signal, "\n"; |
|
|
43 | playaudio $signal->scale2short; |
37 | |
44 | |
38 | To help you, the required unit is given as a type suffix in the parameter |
45 | To help you, the required unit is given as a type suffix in the parameter |
39 | name. A "/" means that you have to divide by the sampling frequency (to |
46 | name. A "/" means that you have to divide by the sampling frequency (to |
40 | convert from Hertz) and a suffix of "*" indicates that a multiplication is |
47 | convert from Hertz) and a suffix of "*" indicates that a multiplication is |
41 | required. |
48 | required. |
… | |
… | |
276 | =cut |
283 | =cut |
277 | |
284 | |
278 | sub describe_audio($) { |
285 | sub describe_audio($) { |
279 | my $pdl = shift; |
286 | my $pdl = shift; |
280 | my ($channels, $samples) = $pdl->dims; |
287 | my ($channels, $samples) = $pdl->dims; |
|
|
288 | ($channels, $samples) = (1, $channels) unless defined $samples; |
281 | my $chan = $channels < 2 ? "mono" : |
289 | my $chan = $channels < 2 ? "mono" : |
282 | $channels == 2 ? "stereo" : |
290 | $channels == 2 ? "stereo" : |
283 | $channels == 4 ? "quad channel" : |
291 | $channels == 4 ? "quad channel" : |
284 | "$channels channel"; |
292 | "$channels channel"; |
285 | my $desc = "$chan sound with $samples samples"; |
293 | my $desc = "$chan sound with $samples samples"; |