function exportBiquadCoefs(b, a, filename)

[sos, g] = tf2sos(b, a);

fid = fopen(filename, 'w');

Nlev = size(sos, 1);
fprintf(fid, '#define Nlev %d\n', Nlev);
fprintf(fid, 'const float B[Nlev][3] = { ');
for l = 1:Nlev-1
    fprintf(fid, '{%.8f, %.8f, %.8f},\n', sos(l, 1), sos(l, 2), sos(l, 3));
end
fprintf(fid, '{%.8f, %.8f, %.8f} };\n', sos(Nlev, 1), sos(Nlev, 2), sos(Nlev, 3));
fprintf(fid, 'const float A[Nlev][3] = { ');
for l = 1:Nlev-1
    fprintf(fid, '{%.8f, %.8f, %.8f},\n', sos(l, 4), sos(l, 5), sos(l, 6));
end
fprintf(fid, '{%.8f, %.8f, %.8f} };\n', sos(Nlev, 4), sos(Nlev, 5), sos(Nlev, 6));

fprintf(fid, 'const float gain = %.8f;\n', g^(1/Nlev));
fclose(fid);
