Skip to content

Instantly share code, notes, and snippets.

@ion1
Created December 20, 2012 02:42
Show Gist options
  • Save ion1/4342532 to your computer and use it in GitHub Desktop.
Save ion1/4342532 to your computer and use it in GitHub Desktop.
A Pure Data patch used to help clean up an audio file
#N canvas 980 79 927 1121 10;
#X msg -1327 -1755 play;
#X obj -1197 -1786 route ready samplerate length cache float bang;
#X obj -1388 -1719 readanysf~ 2;
#X obj -972 -1755 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
-1 -1;
#X floatatom -1197 -1744 5 0 0 0 - - -;
#X floatatom -1151 -1755 5 0 0 0 - - -;
#X floatatom -1107 -1755 5 0 0 0 - - -;
#X floatatom -1061 -1755 5 0 0 0 - - -;
#X floatatom -1020 -1755 5 0 0 0 - - -;
#X obj -1507 -1518 +~;
#X obj -1478 -1536 *~ -3.25;
#X obj -1299 -1361 dbtorms;
#X obj -1348 -1322 *~;
#X msg -1418 -1755 open foo.mp4;
#X obj -1299 -1584 env~ 64;
#X obj -1299 -1403 line;
#X obj -1299 -1458 pack f 100;
#X text -1299 -1637 Follow the negated envelope of the other channel
to cancel compression;
#X obj -1299 -1542 expr 135-$f1;
#X text -1599 -1585 Cancel some of the hum using the other channel
;
#X msg -1112 -1250 start;
#X msg -1112 -1208 stop;
#X msg -1112 -1166 print;
#X obj -1167 -1118 writesf~ 1;
#X obj -1299 -1500 min 100;
#X obj -1266 -1833 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
-1 -1;
#X obj -1303 -1833 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
-1 -1;
#X msg -1466 -1925 \; pd dsp 1;
#X obj -1392 -1975 loadbang;
#X obj -1354 -1925 delay 1000;
#X obj -1231 -1852 delay 1000;
#X obj -988 -1536 delay 1000;
#X obj -1230 -1947 change;
#X obj -1230 -1905 select 1;
#X msg -988 -1494 \; pd quit;
#X msg -1112 -1322 open /tmp/pd-output.wav;
#X obj -1359 -1118 dac~;
#X connect 0 0 2 0;
#X connect 1 0 4 0;
#X connect 1 0 32 0;
#X connect 1 1 5 0;
#X connect 1 2 6 0;
#X connect 1 3 7 0;
#X connect 1 4 8 0;
#X connect 1 5 3 0;
#X connect 1 5 21 0;
#X connect 1 5 31 0;
#X connect 2 0 9 0;
#X connect 2 1 10 0;
#X connect 2 1 14 0;
#X connect 2 2 1 0;
#X connect 9 0 12 0;
#X connect 10 0 9 1;
#X connect 11 0 12 1;
#X connect 12 0 23 0;
#X connect 12 0 36 0;
#X connect 12 0 36 1;
#X connect 13 0 2 0;
#X connect 14 0 18 0;
#X connect 15 0 11 0;
#X connect 16 0 15 0;
#X connect 18 0 24 0;
#X connect 20 0 23 0;
#X connect 21 0 23 0;
#X connect 22 0 23 0;
#X connect 24 0 16 0;
#X connect 25 0 0 0;
#X connect 25 0 20 0;
#X connect 26 0 13 0;
#X connect 26 0 35 0;
#X connect 28 0 27 0;
#X connect 28 0 29 0;
#X connect 29 0 26 0;
#X connect 30 0 25 0;
#X connect 31 0 34 0;
#X connect 32 0 33 0;
#X connect 33 0 30 0;
#X connect 35 0 23 0;
@Rickasaurus
Copy link

"The most essential magic numbers in that patch are the 3.25 and the 135. The former was the factor that made the right channel's noise amplitude match that of the left channel; the latter resulted in the maximum gain from the compression cancellation to be around 1 (to avoid clipping)."

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment