image thumbnail

self-made stroboscope with microphone

by

 

GUI for the stoboscope. FFT spectrum, detect frequency, generate drive signal.

add_to_buffer
function add_to_buffer
global  ao st fout phiout dt pso pc fqmx pco hds signal


if st
    set(ao,'SamplesOutputFcn','');

else
    if (get(hds.mute,'value'))||(~signal);
        d2=zeros(pso,1);
    else
        phia=fout*dt*(0:pso-1)'+phiout/(2*pi); % phasies without 2*pi
        %phic=fqmx*(pc-1)*ps*dt;
        phic=fout*(pco-1)*pso*dt;
        phia=phia+phic; % correct
        phia=mod(phia,1); % to range [0;1)

        str=get(hds.duty,'string');
        duty=str2num(str);
        if duty>1
            duty=1;
        end
        if duty<0
            duty=0;
        end

        indp=find(phia<=duty);
        d2=zeros(pso,1);
        d2(indp)=1;
        neg=get(hds.neg,'value');
        if neg
            d2=-d2;
        end
        rmv=get(hds.rmv,'value');
        if rmv
            d2=d2-mean(d2);
        end
    end
    % add to buffer:
    putdata(ao,[d2 d2]);
    pco=pco+1;
end
    

Contact us