diff --git a/statocles-site/blog/2024/12/13/sound/index.markdown b/statocles-site/blog/2024/12/13/sound/index.markdown
index 05c792a..5d13e3f 100644
--- a/statocles-site/blog/2024/12/13/sound/index.markdown
+++ b/statocles-site/blog/2024/12/13/sound/index.markdown
@@ -10,11 +10,8 @@ images:
alt: 'Score sheet for "In dulci jubilo"'
data:
attribution: |-
- From ChoralWiki, available under the
- Choral Public Domain License.
- Copyright © 2016 by CPDL.
+ Banner image From ChoralWiki, available under the Choral Public Domain License. Copyright © 2016 by CPDL.
data:
- bio: haj
description: 'Creating Sound with PDL (Perl Data Language)'
---
@@ -45,11 +42,11 @@ the result in a one-dimensional PDL ndarray. Like audio CDs, we use
# This subroutine is where the fun will happen.
# Return N_SAMPLES for a wave with FREQUENCY
- sub samples ($n_samples, $frequency) {
- my $phase = sequence($n_samples) * 2 * PI * $frequency / RATE;
- my $samples = sin($phase);
- return $samples;
- }
+ sub samples ($n_samples, $frequency) {
+ my $phase = sequence($n_samples) * 2 * PI * $frequency / RATE;
+ my $samples = sin($phase);
+ return $samples;
+ }
The `sequence` constructor of PDL builds regular intervals which we
adjust for the rate and the desired frequency. Also, PDL brings its
@@ -64,12 +61,12 @@ constructor, and we make sure that they use the full value range for
Perl scalar which holds the _binary_ array which we can directly print
to a WAV file:
- sub prepare ($samples) {
- my $amplitude = 2**15-1;
- my $max = max(abs $samples);
- my $sound16 = short($samples / $max * $amplitude);
- return $sound16->get_dataref;
- }
+ sub prepare ($samples) {
+ my $amplitude = 2**15-1;
+ my $max = max(abs $samples);
+ my $sound16 = short($samples / $max * $amplitude);
+ return $sound16->get_dataref;
+ }
The actual WAV formatting needs some bookkeeping but isn't all that
interesting:
@@ -183,8 +180,8 @@ samples:
$samples -= short $samples; # drop the integer part
$samples *= 2;
$samples -= 1;
- return $samples;
- }
+ return $samples;
+ }