puredataでAM変調、復調

#概要
puredataでAM変調、復調やってみた。
復調は、IQ復調。
#写真
![am.JPG](https://qiita-image-store.s3.amazonaws.com/0/18104/447f0e7a-a087-0c36-0d5a-fdc4ba2587ba.jpeg)

#サンプルコード
```
#N canvas 73 79 920 596 16;
#N canvas 0 22 454 304 (subpatch) 0;
#X array scope1 400 float 1;
#A 0 0.233505 0.190066 0.145663 0.100522 0.0548715 0.0089414 -0.0370336
-0.0828204 -0.128188 -0.172906 -0.216746 -0.259484 -0.300907 -0.340805
-0.378977 -0.415224 -0.44936 -0.481219 -0.510639 -0.537472 -0.561577
-0.582826 -0.60112 -0.616369 -0.628495 -0.637433 -0.643126 -0.64556
-0.644722 -0.640619 -0.633268 -0.62269 -0.608958 -0.59214 -0.572322
-0.549603 -0.524085 -0.49591 -0.465223 -0.432178 -0.396943 -0.359688
-0.320608 -0.279904 -0.237781 -0.194454 -0.150136 -0.105057 -0.0594467
-0.0135347 0.0324465 0.0782633 0.123682 0.168473 0.212411 0.255273
0.296839 0.336895 0.375244 0.411691 0.446052 0.478151 0.507816 0.534908
0.559289 0.580836 0.599438 0.614988 0.627421 0.636675 0.642704 0.645475
0.644958 0.641172 0.634138 0.623891 0.610482 0.593965 0.574436 0.551996
0.526759 0.498853 0.468408 0.435587 0.400559 0.363501 0.324601 0.28405
0.242056 0.198837 0.15461 0.1096 0.0640315 0.0181384 -0.027846 -0.0736893
-0.11916 -0.164026 -0.208057 -0.251034 -0.292738 -0.33296 -0.371492
-0.408134 -0.442707 -0.475037 -0.504961 -0.532324 -0.556976 -0.578806
-0.597702 -0.61357 -0.62633 -0.635898 -0.642243 -0.645334 -0.645155
-0.641707 -0.634992 -0.625056 -0.611953 -0.595749 -0.576527 -0.554371
-0.529402 -0.50175 -0.471556 -0.438972 -0.404157 -0.367288 -0.328559
-0.288166 -0.246312 -0.203205 -0.159067 -0.114123 -0.0686006 -0.0227303
0.023256 0.0691237 0.11464 0.159576 0.203704 0.246799 0.288637 0.329012
0.36772 0.404565 0.43936 0.471916 0.502081 0.529702 0.554639 0.576765
0.595954 0.612121 0.625187 0.635085 0.641765 0.645178 0.645318 0.642189
0.635806 0.626202 0.613411 0.597508 0.578576 0.556714 0.53203 0.504641
0.474689 0.442332 0.407734 0.37107 0.33252 0.29228 0.250559 0.207569
0.163527 0.118654 0.0731781 0.0273317 -0.0186529 -0.0645435 -0.110107
-0.15511 -0.199327 -0.242533 -0.284511 -0.325047 -0.363927 -0.400963
-0.435967 -0.468761 -0.499182 -0.527059 -0.552264 -0.574671 -0.594165
-0.61065 -0.624026 -0.634236 -0.641232 -0.64498 -0.645459 -0.642655
-0.636589 -0.627297 -0.614826 -0.59924 -0.580608 -0.559027 -0.534613
-0.50749 -0.477795 -0.445674 -0.411286 -0.374816 -0.336446 -0.29637
-0.254791 -0.211915 -0.167965 -0.123165 -0.0777409 -0.0319214 0.0140605
0.0599704 0.105576 0.150647 0.194956 0.238271 0.280378 0.321064 0.360123
0.397359 0.43257 0.465588 0.496247 0.524391 0.549878 0.572567 0.59235
0.609132 0.622828 0.633367 0.640686 0.644751 0.64555 0.643078 0.637348
0.628378 0.616216 0.600931 0.582602 0.56132 0.537188 0.510324 0.480875
0.448989 0.414828 0.378561 0.340368 0.300451 0.259012 0.21626 0.172411
0.127683 0.0823099 0.0365196 -0.00945604 -0.0553846 -0.101031 -0.146165
-0.190557 -0.233985 -0.276227 -0.317063 -0.35629 -0.393712 -0.429139
-0.462392 -0.493292 -0.521689 -0.547442 -0.570421 -0.59051 -0.607596
-0.621597 -0.632448 -0.640094 -0.644497 -0.645625 -0.643472 -0.638059
-0.629413 -0.617577 -0.602605 -0.584569 -0.563571 -0.539717 -0.513129
-0.483936 -0.452281 -0.418334 -0.382268 -0.344265 -0.304515 -0.263215
-0.220581 -0.176831 -0.132184 -0.0868659 -0.0411055 0.00486232 0.0508052
0.0964909 0.141688 0.186165 0.229696 0.272063 0.313052 0.352455 0.390065
0.425695 0.459167 0.490313 0.518975 0.544998 0.568254 0.588629 0.606022
0.620345 0.631515 0.639476 0.644197 0.645654 0.643839 0.638756 0.630424
0.618898 0.604235 0.586512 0.565812 0.542232 0.515906 0.486965 0.455557
0.421838 0.385971 0.348149 0.308563 0.267413 0.224908 0.181256 0.136687
0.0914254 0.0457003 -0.000257176 -0.0462134 -0.0919346 -0.13719 -0.18175
-0.225389 -0.267882 -0.309015 -0.348582 -0.386383 -0.422226 -0.455923
-0.487304 -0.516215 -0.542511 -0.566058 -0.586729 -0.604418 -0.619045
-0.630534 -0.638829 -0.64388 -0.645657 -0.644162 -0.639402 -0.631403
-0.620201 -0.605842 -0.588413 -0.568003 -0.544714 -0.518664 -0.489972
-0.458798 -0.425299 -0.389645 -0.352015 -0.312593 -0.271587 -0.229204
-0.185661 -0.141176;
#X coords 0 1.2 399 -1.2 400 140 1;
#X restore 481 19 graph;
#X obj 323 12 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#N canvas 0 22 454 304 (subpatch) 0;
#X array scope2 400 float 1;
#A 0 -0.105363 0.0959514 0.145518 0.0582217 -0.0203317 -0.00877377
0.0257091 -0.0188804 -0.1207 -0.137242 0.0174039 0.228572 0.263453
0.0235669 -0.303365 -0.389381 -0.0975433 0.337918 0.499933 0.193559
-0.330359 -0.581919 -0.297645 0.284252 0.625701 0.394633 -0.208232
-0.626473 -0.470151 0.114762 0.584904 0.512516 -0.0185858 -0.506981
-0.514249 -0.0652927 0.403341 0.473049 0.123494 -0.28777 -0.392167
-0.146102 0.175444 0.279894 0.127887 -0.0809664 -0.14858 -0.0690729
0.0164197 0.0129554 -0.0247381 0.0101655 0.111731 0.143263 0.00410977
-0.211713 -0.27288 -0.0566443 0.276491 0.398382 0.139699 -0.300201
-0.504993 -0.241363 0.282347 0.580257 0.34719 -0.227873 -0.615659 -0.441987
0.146515 0.607774 0.511927 -0.0514831 -0.558593 -0.546235 -0.0422159
0.475459 0.538684 0.119823 -0.369896 -0.488395 -0.168688 0.256242 0.399936
0.179988 -0.149697 -0.282787 -0.149857 0.0643795 0.150039 0.0799234
-0.0114707 -0.0167532 0.0229191 -0.00224896 -0.102022 -0.147382 -0.0247173
0.193198 0.279243 0.088385 -0.247361 -0.403223 -0.179824 0.259951 0.504943
0.286302 -0.231913 -0.572806 -0.392976 0.169473 0.599523 0.484826 -0.0834194
-0.582979 -0.548613 -0.0124166 0.526636 0.574607 0.102892 -0.438967
-0.557889 -0.173623 0.332377 0.498961 0.212778 -0.221607 -0.403753
-0.212731 0.121741 0.282763 0.170992 -0.0463238 -0.149776 -0.0905836
0.00550822 0.0200224 -0.0203613 -0.0047801 0.0917677 0.149645 0.0442188
-0.173305 -0.282586 -0.118488 0.216318 0.403936 0.21755 -0.217634 -0.499849
-0.327938 0.17958 0.559713 0.434588 -0.109655 -0.57744 -0.522718 0.0195856
0.55239 0.579839 0.0762933 -0.489321 -0.597335 -0.162832 0.397854 0.571614
0.226132 -0.291138 -0.504623 -0.255304 0.184177 0.403508 0.243971 -0.0918441
-0.27977 -0.191033 0.0269604 0.147726 0.100899 0.00141603 -0.0226678
0.0171474 0.0108523 -0.0811304 -0.150096 -0.0624274 0.152271 0.282929
0.14667 -0.183722 -0.400563 -0.25251 0.17369 0.489823 0.365891 -0.125896
-0.541104 -0.471612 0.0490309 0.549685 0.555293 0.0443438 -0.516295
-0.605288 -0.139504 0.447019 0.614146 0.221419 -0.352513 -0.579705
-0.276804 0.246547 0.505234 0.295803 -0.144299 -0.399126 -0.273328
0.0602705 0.273736 0.20971 -0.00646705 -0.143809 -0.110668 -0.00923586
0.0245669 -0.0134123 -0.0159194 0.0702985 0.148835 0.0791897 -0.130387
-0.280368 -0.17268 0.149947 0.39324 0.284406 -0.128598 -0.475007 -0.39981
0.0714211 0.517242 0.503711 0.0117877 -0.516547 -0.582248 -0.107725
0.475072 0.624681 0.201407 -0.400149 -0.624885 -0.278053 0.303368 0.582021
0.325114 -0.199043 -0.500756 -0.33383 0.102353 0.390598 0.300479 -0.0273288
-0.264658 -0.226773 -0.0149555 0.138012 0.119737 0.0178675 -0.0256444
0.0092578 0.0199459 -0.059433 -0.145937 -0.0943554 0.107906 0.274999
0.196294 -0.115359 -0.382071 -0.312942 0.0828319 0.455618 0.429386
-0.0167058 -0.488384 -0.530593 -0.072185 0.478385 0.603293 0.169917
-0.429142 -0.637856 -0.261375 0.349158 0.629391 0.332156 -0.25091 -0.578509
-0.370537 0.149072 0.491166 0.368967 -0.0587441 -0.377912 -0.325066
-0.00666249 0.252552 0.241971 0.0370888 -0.130294 -0.12791 -0.0272058
0.0258074 -0.00483529 -0.0229247 0.0487113 0.141547 0.107826 -0.0851087
-0.266962 -0.217325 0.0803463 0.367281 0.337891 -0.0368668 -0.431901
-0.454379 -0.0376901 0.454876 0.551995 0.131554 -0.435611 -0.618276
-0.230298 0.378958 0.644649 0.318801 -0.294573 -0.627621 -0.383161
0.195637 0.56917 0.412609 -0.0971336 -0.476504 -0.400806 0.0139013
0.36117 0.346808 0.041362 -0.237472 -0.255086 -0.0597034 0.12069 0.135042
0.0371365 -0.025008 0.000257167 0.0248554 -0.0382792 -0.135767 -0.119497
0.0622532 0.256417 0.235603 -0.0452749 -0.349048 -0.359045 -0.00882392
0.404148 0.474552 0.091219 -0.417087 -0.567762 -0.1893 0.388656 0.627029
0.288258 -0.325048 -0.645012 -0.373097 0.236916 0.619565 0.430553 -0.138108
-0.554043 -0.450847 0.0437349 0.456874 0.428986 0.0317293 -0.340443
-0.365395 -0.0764149 0.219505 0.265893 0.0825447 -0.109217 -0.140956
;
#X coords 0 1.2 399 -1.2 400 140 1;
#X restore 482 199 graph;
#X obj 237 136 tabwrite~ scope2;
#X obj 28 170 *~;
#X obj 269 47 metro 1000;
#X obj 239 92 tabwrite~ scope1;
#X obj 239 534 tabwrite~ scope3;
#N canvas 0 22 454 304 (subpatch) 0;
#X array scope3 400 float 1;
#A 0 -0.144183 -0.198396 -0.274445 -0.327792 -0.384725 -0.440863 -0.485846
-0.534204 -0.567445 -0.55975 -0.563081 -0.597721 -0.554084 -0.51542
-0.57112 -0.508479 -0.432631 -0.473581 -0.412086 -0.309833 -0.327388
-0.28542 -0.169999 -0.164085 -0.155673 -0.0409142 -0.0142758 -0.0474891
0.0537411 0.0956955 0.0195236 0.0967199 0.146373 0.0326905 0.0789254
0.127333 0.0402176 0.0483748 0.0821727 0.0169513 -0.0130373 -0.00408486
-0.0566213 -0.117996 -0.139851 -0.189543 -0.269926 -0.32376 -0.379986
-0.43679 -0.482643 -0.529205 -0.567387 -0.562067 -0.561077 -0.604587
-0.565561 -0.521001 -0.569517 -0.515677 -0.434814 -0.460529 -0.412432
-0.307409 -0.30863 -0.283878 -0.168385 -0.145941 -0.157259 -0.0451461
-0.00264958 -0.0564945 0.039758 0.0961486 0.00013791 0.0707405 0.132842
0.0360578 0.0721677 0.128097 0.0570422 0.053499 0.0906848 0.0374505
-0.00364728 0.00585102 -0.0387752 -0.108841 -0.131608 -0.177276 -0.262607
-0.317459 -0.373137 -0.430642 -0.477659 -0.522917 -0.566057 -0.563689
-0.559133 -0.611356 -0.577708 -0.528278 -0.564154 -0.520348 -0.436114
-0.447235 -0.413534 -0.307407 -0.292962 -0.286054 -0.172085 -0.133818
-0.16507 -0.0570501 0.000554025 -0.0736982 0.0163366 0.0863767 -0.0183877
0.0438078 0.116811 0.0399294 0.0643746 0.126331 0.071298 0.0551111
0.0945986 0.0533848 0.000741854 0.0101234 -0.0264601 -0.105274 -0.129207
-0.170589 -0.256501 -0.312587 -0.367588 -0.425524 -0.473685 -0.517875
-0.565732 -0.566648 -0.559118 -0.608162 -0.581404 -0.52891 -0.553144
-0.520668 -0.43488 -0.432339 -0.41399 -0.308529 -0.279335 -0.29082
-0.180034 -0.126887 -0.178173 -0.0757372 -0.00400707 -0.0982684 -0.0156609
0.0670732 -0.0160264 0.0343071 0.114981 0.0565442 0.0668555 0.132322
0.0922356 0.061777 0.101711 0.0717591 0.00661805 0.0146356 -0.0143823
-0.102376 -0.128148 -0.165416 -0.247327 -0.305246 -0.35981 -0.41821
-0.467752 -0.511366 -0.563879 -0.568572 -0.558863 -0.599938 -0.58109
-0.526976 -0.540341 -0.520037 -0.434213 -0.418804 -0.416364 -0.313096
-0.270012 -0.30008 -0.193945 -0.126866 -0.197921 -0.102352 -0.0174832
-0.106064 -0.0340857 0.0583711 -0.004168 0.0319432 0.117865 0.0770503
0.0716326 0.138722 0.112979 0.0673074 0.106315 0.0872128 0.0091885
0.0149939 -0.00664741 -0.10384 -0.131836 -0.164946 -0.242238 -0.301997
-0.355838 -0.414217 -0.464864 -0.50794 -0.564629 -0.573178 -0.56176
-0.594989 -0.584262 -0.529314 -0.532092 -0.524133 -0.43928 -0.411465
-0.424933 -0.324992 -0.268679 -0.317003 -0.216631 -0.136427 -0.22658
-0.138895 -0.041826 -0.107976 -0.0487756 0.0511961 0.00869513 0.0290819
0.118428 0.0948394 0.0727808 0.140065 0.128363 0.0671225 0.104227 0.0958093
0.00494905 0.00798695 -0.00628851 -0.104313 -0.135367 -0.164747 -0.237226
-0.299179 -0.352353 -0.410515 -0.462222 -0.505026 -0.563277 -0.576109
-0.563819 -0.589731 -0.587553 -0.532828 -0.525656 -0.530336 -0.447668
-0.40824 -0.437615 -0.34224 -0.273626 -0.339864 -0.246449 -0.154191
-0.224512 -0.149003 -0.0438634 -0.0898231 -0.0466283 0.0574712 0.0332814
0.0356472 0.125689 0.117962 0.0778266 0.143234 0.144544 0.0669687 0.100683
0.102204 -0.00172272 -0.00237696 -0.0097286 -0.0983988 -0.133802 -0.16036
-0.228256 -0.293121 -0.346045 -0.404092 -0.457041 -0.500053 -0.555379
-0.573233 -0.561226 -0.580731 -0.587734 -0.534539 -0.518399 -0.53609
-0.456969 -0.407003 -0.452327 -0.362876 -0.283166 -0.356166 -0.271864
-0.169687 -0.219095 -0.157583 -0.0464366 -0.0726844 -0.0467946 0.0596195
0.0533057 0.0369265 0.126191 0.133967 0.0755166 0.137921 0.151941 0.0582396
0.0878382 0.099118 -0.00651561 -0.0121241 -0.0134049 -0.0925629 -0.133042
-0.157242 -0.22038 -0.288429 -0.341146 -0.398822 -0.452839 -0.496209
-0.548814 -0.571707 -0.560515 -0.574026 -0.590222 -0.539355 -0.514875
-0.545448 -0.470848 -0.411206 -0.472046 -0.389533 -0.299782 -0.353217
-0.281151 -0.17226 -0.202309 -0.157176 -0.0427897 -0.0505955 -0.0436384
0.0627897 0.0733183 0.037223 0.123849 0.146253 0.0691364 0.127154 0.153194
0.0434971 0.0680638 0.0886179 -0.00312403 -0.0154727 -0.0121197 -0.0821598
-0.128809 -0.151522 -0.210106 -0.281916;
#X coords 0 1.2 399 -1.2 400 140 1;
#X restore 481 382 graph;
#X obj 28 113 osc~ 7000;
#X obj 55 68 *~;
#X obj 167 10 hsl 128 15 0 1 0 1 empty empty empty -2 -8 0 10 -262144
-1 -1 8200 0;
#X obj 55 7 osc~ 500;
#X obj 28 266 *~;
#X obj 147 266 *~;
#X obj 27 361 expr~ $V1*$V1+$V2*$V2;
#X obj 27 404 sqrt~;
#X obj 74 217 cos~ 6000;
#X obj 205 215 sin~ 6000;
#X obj 27 311 lop~ 600;
#X obj 147 311 lop~ 600;
#X obj 27 449 lop~ 600;
#X obj 26 484 -~ 0.03;
#X obj 26 526 *~ 40;
#X connect 1 0 5 0;
#X connect 4 0 3 0;
#X connect 4 0 13 0;
#X connect 4 0 14 0;
#X connect 5 0 3 0;
#X connect 5 0 6 0;
#X connect 5 0 7 0;
#X connect 9 0 4 0;
#X connect 10 0 4 1;
#X connect 10 0 6 0;
#X connect 11 0 10 1;
#X connect 12 0 10 0;
#X connect 13 0 19 0;
#X connect 14 0 20 0;
#X connect 15 0 16 0;
#X connect 16 0 21 0;
#X connect 17 0 13 1;
#X connect 18 0 14 1;
#X connect 19 0 15 0;
#X connect 20 0 15 1;
#X connect 21 0 22 0;
#X connect 22 0 23 0;
#X connect 23 0 7 0;

```