function trialnew(audio,a)
servoAttach(a,9);
servoAttach(a,8);
servoWrite(a,9,10);
servoWrite(a,8,100);
[d,sr] = audioread(audio);
e=size(d);
timesec=round(e(1)/sr);
t=0;
i=0;
k=30;
while t+1<=timesec
    m=round(t*sr);
    f=d(m+1:m+sr);
    beat = beat2(f,sr);
    beat=size(beat);
    beat=beat(2);
    if beat==0
        for tes=0.1:0.1:1
        i=i+1;
        o(i)=0;
        u(i)=0;
        end
        t=t+1;
    else
        beatime=1/beat;
        beatime=round(beatime*10)/10;
        for tes = 0.1:0.1:beatime
        s=round(10*k*beatime*cos((tes/beatime)*pi));
        i=i+1;
        o(i)=s/10;
        u(i)=-s/10;
        end
        t=t+beatime;
    end
end
sound(audioread(audio),44100);
tic;
for p=1:i
    servoWrite(a,8,100+o(p));
    servoWrite(a,9,20-u(p));
    pause(0.090);
end
toc
i