private void stop_Click(object sender, RoutedEventArgs e)
 {
     if (metronome != null)
     {
         metronome.Halt();
     }
 }