diff options
| author | Teddy Wing | 2014-11-08 22:51:53 -0500 |
|---|---|---|
| committer | Teddy Wing | 2014-11-08 22:51:53 -0500 |
| commit | 0e87a822c1e60b22726188e8c8948ea6ea640c58 (patch) | |
| tree | c023d2d5ec9c2bc45cc420d1320a02371cb03055 | |
| parent | 0afa876269f4aa636aaca9d47cdf32df476c18ce (diff) | |
| download | auditory.vim-0e87a822c1e60b22726188e8c8948ea6ea640c58.tar.bz2 | |
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.
| -rw-r--r-- | plugin/auditory.vim | 24 |
1 files changed, 22 insertions, 2 deletions
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 |
