#N canvas 0 89 1280 711 16; #N canvas 0 91 450 250 (subpatch) 0; #X array sinal107 44100 float 2; #X coords 0 1 441 -1 600 420 1 0 0; #X restore 617 90 graph; #X obj 154 486 bng 30 250 50 0 empty empty Toca_sinal 32 16 0 16 -262130 -4160 -4160; #X obj 154 559 dac~; #X obj 20 10 cnv 15 1200 40 empty empty empty 0 16 0 16 -262130 -4160 0; #X msg 26 539 \; pd dsp 1 \;, f 10; #X text 23 511 Liga DSP; #X obj 406 643 soundfiler; #X obj 154 526 tabplay~ sinal107; #X text 34 18 Exemplo 107: sintetiza um sinal com N componentes senoidais aleatórias \, e grava em arquivo, f 116; #X obj 45 89 hradio 20 1 0 10 empty empty N= -24 12 0 16 -262144 -1 -1 5; #X text 19 62 selecione o n° de componentes:; #X msg 406 614 write -wave sinal.wav sinal107; #X obj 406 555 r arquivo; #X obj 406 584 sel grava; #X text 57 615 guarda o sinal em um arquivo wave:; #N canvas 0 91 879 309 guarda 0; #X msg 25 144 add \$1; #X obj 25 251 textfile; #X msg 132 180 write CompMus107-FrequênciasSecretas.txt; #X text 149 87 tria mensagens:; #X text 103 145 se receber float \, envia mensagem "add "; #X msg 220 212 clear; #X text 284 212 se receber "limpa" \, repassa a mensagem "clear"; #X text 551 170 se receber "grava" \, escreve o arquivo no disco, f 28; #X text 173 49 recebe mensagem; #X text 22 20 guarda as frequências sorteadas em um arquivo texto (objeto [textfile] abaixo):, f 87; #X obj 25 47 r arquivo; #X obj 25 87 route float; #X obj 132 120 select grava limpa; #X connect 0 0 1 0; #X connect 2 0 1 0; #X connect 5 0 1 0; #X connect 10 0 11 0; #X connect 11 0 0 0; #X connect 11 1 12 0; #X connect 12 0 2 0; #X connect 12 1 5 0; #X restore 616 547 pd guarda as frequências sorteadas em arquivo texto ; #X obj 21 143 ofelia f \; local sig = pdArray("sinal107") \; local N = sig:getSize() \; local pi = math.pi \; local SR = 44100 \; local arq = pdSend("arquivo") \; arq:sendSymbol("limpa") \; for i=0 \, N-1 do sig[i]=0 end \; for j = 1 \, a+1 do \; f = math.floor(math.random()*1000+0.5) \; arq:sendFloat(f) \; for i = 0 \, N-1 do \; sig:setAt(i \, sig:getAt(i)+(1/(a+1))*math.sin(2*pi*f*i/SR)) \; end \; end \; arq:sendSymbol("grava") \;; #X text 48 111 1 2 3 4 5 6 7 8 9 10; #X connect 1 0 7 0; #X connect 7 0 2 0; #X connect 7 0 2 1; #X connect 9 0 16 0; #X connect 11 0 6 0; #X connect 12 0 13 0; #X connect 13 0 11 0;