/Users/lyon/j4p/src/sound/musica/MusicaKeyProcessor.java

1    package sound.musica; 
2     
3    /* 
4     * Open Source Software by http://www.Docjava.com 
5     * programmer: D. Lyon 
6     * e-mail: lyon@docjava.com 
7     * Date: Apr 30, 2002 
8     * Time: 3:40:56 PM 
9     */ 
10    
11   import sound.Utils; 
12    
13   import java.awt.event.KeyEvent; 
14   import java.awt.event.KeyListener; 
15    
16   import sound.musica.Scales; 
17    
18   public class MusicaKeyProcessor 
19    
20           implements KeyListener { 
21       int startIndex = 64; 
22       int scale[] = Scales.getScale(ChromaticScale.CHROMATIC, startIndex); 
23    
24       //PetriNodes pn = SongReader.initMarkov(20); 
25    
26    
27       public void keyPressed(KeyEvent 
28               e) { 
29       } 
30    
31       public void keyTyped(KeyEvent 
32               e) { 
33           int c = e.getKeyChar(); 
34           //  System.out.println(c); 
35           if (e.isAltDown()) { 
36               //  (pn.getNode(c % 9)).play(); 
37               return; 
38           } 
39    
40           if (e.isShiftDown()) { 
41    
42               //Utils.play(SongReader.getNextNote()); 
43           } else { 
44               int scaleLength = scale.length; 
45               int index = c % scaleLength; 
46               System.out.println("scaleLength: " + scaleLength + " c: " + c + " index+ " + index); 
47               //Utils.play(scale[index] + scaleLength *((c-startIndex)/scaleLength), 20); 
48               Utils.play(scale[index]+(c/scaleLength)*scaleLength, 20); 
49    
50           } 
51       } 
52    
53       public void keyReleased(KeyEvent 
54               e) { 
55       } 
56   } 
57