public abstract class VirtualKeyboard
extends javax.swing.JComponent
implements javax.sound.midi.Receiver
Uses refactored code from the gervill package licensed under the GPL with the classpath exception.
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
static int |
NUMBER_OF_MIDI_KEYS
The number of MIDI keys in total.
|
static int |
VELOCITY
The velocity of NOTE_ON events.
|
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
VirtualKeyboard(int numberOfKeysInOctave)
Create a new keyboard that spans 7 octaves and uses the specified number
of keys per octave.
|
VirtualKeyboard(int numberOfKeysInOctave,
int totalOfKeys)
Create a new keyboard that has a number of keys per octave and a
specified total number of keys.
|
Modifier and Type | Method and Description |
---|---|
protected void |
allKeysOff() |
void |
close() |
void |
connectToTunedSynth(double[] tuning)
Connects the virtual keyboard to the default Gervill synthesizer.
|
static VirtualKeyboard |
createVirtualKeyboard(int numberOfKeysPerOctave)
Creates a virtual keyboard using the best representation available.
|
protected int |
getLowestAssignedKey() |
static java.lang.String |
getMappedKeys() |
protected abstract int |
getMidiNote(int x,
int y)
Converts x and y coordinate into a MIDI note number.
|
protected int |
getNumberOfKeys() |
protected int |
getNumberOfKeysPerOctave() |
protected float |
getNumberOfOctaves() |
protected double[] |
getTuning() |
protected boolean |
isKeyDown(int midiKey) |
void |
send(javax.sound.midi.MidiMessage message,
long timeStamp) |
protected void |
setLowestAssignedKey(int lowestAssignedKey) |
static void |
setMappedKeys(java.lang.String mappedKeys) |
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public static final int VELOCITY
public static final int NUMBER_OF_MIDI_KEYS
public VirtualKeyboard(int numberOfKeysInOctave)
numberOfKeysInOctave
- the number of keys per octavepublic VirtualKeyboard(int numberOfKeysInOctave, int totalOfKeys)
numberOfKeysInOctave
- the number of keys per octavetotalOfKeys
- the total number of keys used. E.g. 12 keys per octave and 4
octaves = 48 keysprotected final boolean isKeyDown(int midiKey)
protected abstract int getMidiNote(int x, int y)
x
- the x coordinatey
- the y coordinateprotected final void allKeysOff()
public final void send(javax.sound.midi.MidiMessage message, long timeStamp)
send
in interface javax.sound.midi.Receiver
public static VirtualKeyboard createVirtualKeyboard(int numberOfKeysPerOctave)
UniversalVirtualKeyboard
class.numberOfKeysPerOctave
- requested number of keys for each octave.VirtualKeyboard
using the best representation
available.protected double[] getTuning()
public void connectToTunedSynth(double[] tuning)
tuning
- The tuning for one octave defined in cents.public static void setMappedKeys(java.lang.String mappedKeys)
public static java.lang.String getMappedKeys()
protected int getNumberOfKeysPerOctave()
protected void setLowestAssignedKey(int lowestAssignedKey)
protected int getLowestAssignedKey()
protected int getNumberOfKeys()
protected float getNumberOfOctaves()
public void close()
close
in interface java.lang.AutoCloseable
close
in interface javax.sound.midi.Receiver