#!/bin/bash #🎩-tip: "Generate white noise to calm a baby" https://askubuntu.com/a/789472/362789 # # cf. this: # alias ocean_noise="play -r192000 -n synth brownnoise synth brownnoise mix synth sine amod 0.1 10" # 10-100% @ 0.1Hz (10s period waves) 🎩-tip: https://askubuntu.com/a/789472/362789 # cleanup old rm *.opus *.wav # Audio Copy and Paste Over (from sox manpage) # acpo infile copy-start copy-stop paste-over-start outfile function acpo() { local piece=`mktemp`.wav local part1=`mktemp`.wav local part2=`mktemp`.wav sox "$1" $piece trim $2 =$3 sox "$1" $part1 trim 0 $4 sox "$1" $part2 trim $4+$3-$2 sox $part1 $piece $part2 "$5" splice $4 +$3-$2 rm $piece $part1 $part2 } # brownnoise is a white noise with a low-pass filter applied to it. # generate 1 second of brown noise repeated for 30 seconds sox -r192000 -e float -b 32 -n 1s_of_brown_noise_repeated_for_30s.wav synth 1 brownnoise repeat 30 # generate 30 seconds of brown noise sox -r192000 -e float -b 32 -n 30s_of_brown_noise.wav synth 30 brownnoise cp 30s_of_brown_noise.wav tmp.wav # Insert the same first 1s sample (= the "frozen noise") # into the 30s brown noise sample at times t = 2, 4, 6, …, 24, 26, 28 for i in `seq 2 2 28`; do echo $i acpo tmp.wav 0 1 $i out.wav mv out.wav tmp.wav done mv tmp.wav 30s_of_brown_noise_with_1s_frozen_noise_every_2_seconds.wav # encode all wav files in the current directory to opus parallel opusenc {} {.}.opus ::: *.wav