Microscopic theory of longitudinal sound velocity in CDW and SDW ordered cuprate systems