added pitch and rest generation, fixed sampling bug