From 0e87a822c1e60b22726188e8c8948ea6ea640c58 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 8 Nov 2014 22:51:53 -0500 Subject: plugin/auditory.vim: Play a random note on keypress in Insert mode When in insert mode, play a random note from the Scale on every keypress. --- plugin/auditory.vim | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'plugin') diff --git a/plugin/auditory.vim b/plugin/auditory.vim index aec1409..5d694af 100644 --- a/plugin/auditory.vim +++ b/plugin/auditory.vim @@ -26,11 +26,31 @@ function! s:PlayInsertLeave() call s:KillPid(s:insert_mode_pid) endfunction +function! s:PlayScale() + let scale = [ + \ '1_C#.wav', + \ '2_D#.wav', + \ '3_E#.wav', + \ '4_F#.wav', + \ '5_G#.wav', + \ '6_A#.wav', + \ '7_B#.wav' + \ ] + + let note = system("echo $RANDOM % " . len(scale) . " | bc") + + call auditory#Play('./Resources/Scale_C#/' . scale[note]) +endfunction + + +" auditory#InsertGalaxyFarFarAway() + augroup auditory#insert_mode autocmd! - autocmd InsertEnter * call s:PlayInsertEnter() - autocmd InsertLeave * call s:PlayInsertLeave() + " autocmd InsertEnter * call s:PlayInsertEnter() + " autocmd InsertLeave * call s:PlayInsertLeave() + autocmd CursorMovedI * call s:PlayScale() augroup END -- cgit v1.2.3