From 5768e2443de12bceee94e007a7e4997b06bf9ef9 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 9 Nov 2014 00:28:05 -0500 Subject: plugin/auditory.vim: Ensure PlayScale() doesn't play the last note The random note chosen should not be the same as the last note played in insert mode. --- plugin/auditory.vim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'plugin') diff --git a/plugin/auditory.vim b/plugin/auditory.vim index 5d694af..f8b1bac 100644 --- a/plugin/auditory.vim +++ b/plugin/auditory.vim @@ -27,6 +27,8 @@ function! s:PlayInsertLeave() endfunction function! s:PlayScale() + let play_scale_previous_note = -1 + let note = -1 let scale = [ \ '1_C#.wav', \ '2_D#.wav', @@ -37,7 +39,11 @@ function! s:PlayScale() \ '7_B#.wav' \ ] - let note = system("echo $RANDOM % " . len(scale) . " | bc") + while play_scale_previous_note ==# note + let note = system("echo $RANDOM % " . len(scale) . " | bc") + endwhile + + let play_scale_previous_note = note call auditory#Play('./Resources/Scale_C#/' . scale[note]) endfunction -- cgit v1.2.3