use lazy allocation

add type annotation to sampfreq
improve tests