Class JJazzMidiSystem
Scan the available Midi IN/OUT devices at startup. Restore the default Midi IN/OUT devices when possible using Preferences.
The application should only connect to JJazzMidiIn and JJazzMidiOut virtual devices. These devices are implemented by a MidiFilter object, enabling filtering and dumping. These devices are connected internally to the selected physical MIDI In/Out devices.
Manage a Midi master volume: a factor between 0 and 2 (default=1) which is used on all volume Midi messages.
-
Nested Class Summary
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
addPropertyChangeListener
(String propName, PropertyChangeListener l) void
closeAll()
Close default In and Out devices.void
void
Close the default out device.void
editMidiFileWithExternalEditor
(File midiFile) Edit the specified file with the registered editor, and wait for editor to exit.The default internal synth soundfont/DLS file stored in the Preferences.Get the java sequencer opened and ready to play music on the JJazzMidiOutDevice.Get a friendly name for a MidiDevice.Get the path to an external Midi file editor.Scan the MidiSystem for IN MidiDevices.static JJazzMidiSystem
The internal Java synth.float
getMidiDevice
(List<MidiDevice> midiDevices, String mdName) Find the MidiDevice whose Device.Info.name() is equals to mdName in the devices list.Get the default Jazz Midi Out device MidiFilter log config.Scan the MidiSystem for OUT MidiDevices.Get the VirtualMidiSynth MidiDevice, if present on a Windows system.boolean
boolean
boolean
loadSoundbankFileOnSynth
(File f, boolean silentRun) Try to load the soundfont2 (or DLS) file in the default Java synth.void
panic()
The Midi panic method.void
void
removePropertyChangeListener
(String propName, PropertyChangeListener l) void
This unloads all previously loaded instruments in the internal Java Synth.void
Send the specified MidiMessages on the JJazzMidiOut device with timing -1 (immediate play).void
Set the default MIDI In device.void
Connect the output of JJazzMidiOut device to this device.void
setExternalMidiEditor
(File editorFile) Set the path to an external Midi file editor.void
setMasterVolumeFactor
(float f) Set the master volume factor.void
setMidiOutFiltering
(boolean b) Filter out (discard) all Midi messages sent to Midi Out.void
setThruMode
(boolean b) Enable/Disable redirection of MIDI in to out (MIDI thru).
-
Field Details
-
NOT_SET
- See Also:
-
JAVA_INTERNAL_SYNTH_NAME
- See Also:
-
PROP_MIDI_IN
- See Also:
-
PROP_MIDI_OUT
- See Also:
-
PROP_MIDI_THRU
- See Also:
-
PROP_MASTER_VOL_FACTOR
- See Also:
-
PROP_MIDI_OUT_FILTERING
- See Also:
-
PREF_JAVA_SYNTH_SOUNDFONT_FILE
- See Also:
-
PREF_EXTERNAL_MIDI_EDITOR_PATH
- See Also:
-
-
Method Details
-
getInstance
-
getInDeviceList
Scan the MidiSystem for IN MidiDevices.- Returns:
- A List containing the MIDI out devices. Java Sequencer is excluded.
-
getOutDeviceList
Scan the MidiSystem for OUT MidiDevices.- Returns:
- A List containing the available MIDI out devices, excluding the Java synth and the Java Sequencer.
-
getJJazzMidiInDevice
- Returns:
- The Midi IN device to be used by the application.
-
getJJazzMidiOutDevice
- Returns:
- The Midi OUT device to be used by the application.
-
getDefaultInDevice
- Returns:
- The default MIDI in device. Null if not set.
-
getDefaultOutDevice
- Returns:
- The default MIDI out device. Null if not set.
-
getDefaultSequencer
Get the java sequencer opened and ready to play music on the JJazzMidiOutDevice.In general you should use MusicController.acquireSequencer(Object lock), as it allows for access synchronization between various users.
- Returns:
-
getJavaInternalSynth
The internal Java synth.- Returns:
- Can be null if no java synth.
-
getDefaultJavaSynthPreferredSoundFontFile
The default internal synth soundfont/DLS file stored in the Preferences.- Returns:
- Can be null if no soundfont/DLS file set.
-
resetJavaInternalSynth
public void resetJavaInternalSynth()This unloads all previously loaded instruments in the internal Java Synth.Note that the builtin GM instruments remain.
-
editMidiFileWithExternalEditor
Edit the specified file with the registered editor, and wait for editor to exit.- Parameters:
midiFile
-- Throws:
IOException
-
setExternalMidiEditor
Set the path to an external Midi file editor.- Parameters:
editorFile
-
-
getExternalMidiEditor
Get the path to an external Midi file editor.- Returns:
- Can be an empty path
-
loadSoundbankFileOnSynth
Try to load the soundfont2 (or DLS) file in the default Java synth.Previous soundbank instruments are unloaded first. This triggers a specific task since loading a soundfont can take some time.
- Parameters:
f
-silentRun
- If false wait until completion of the task and show progress bar. If true nothing is shown and method immediatly returns true.- Returns:
- true If success. If silentRun=true always return true.
-
setDefaultOutDevice
Connect the output of JJazzMidiOut device to this device.Fire a PROP_MIDI_OUT property chane event.property change event if device is modified.
- Parameters:
md
- Can be null.- Throws:
MidiUnavailableException
- If exception occurs, the default OUT device is unchanged.
-
closeDefaultOutDevice
public void closeDefaultOutDevice()Close the default out device.Special handling of the Java Internal Synth.
-
setDefaultInDevice
Set the default MIDI In device.Fire a PROP_MIDI_IN property change event if device is modified.
- Parameters:
md
- Can be null.- Throws:
MidiUnavailableException
- If exception occurs, the default IN device is unchanged.
-
closeDefaultInDevice
public void closeDefaultInDevice() -
closeAll
public void closeAll()Close default In and Out devices. -
setThruMode
public void setThruMode(boolean b) Enable/Disable redirection of MIDI in to out (MIDI thru).Fire the PROP_MIDI_THRU property change event.
- Parameters:
b
- Enable if true, disable if false.
-
isThruMode
public boolean isThruMode()- Returns:
- True if thru mode is enabled.
-
panic
public void panic()The Midi panic method.Send ALL_NOTES_OFF + SUSTAIN OFF + RESET_ALL_CONTROLLERS on all channels on the default JJazz midi out device.
-
getMasterVolumeFactor
public float getMasterVolumeFactor()- Returns:
- the masterVolumeFactor A value between 0 and 2. Default is 1.
-
setMasterVolumeFactor
public void setMasterVolumeFactor(float f) Set the master volume factor.All volume Midi messages are multiplicated by this factor.
Fire the PROP_MASTER_VOL_FACTOR property chane event.- Parameters:
f
- The master volume Factor to set. Must be between 0 and 2.
-
getMidiOutLogConfig
Get the default Jazz Midi Out device MidiFilter log config.Can be used to adjust Midi Out log settings, e.g: getMidiOutLogConfig().add(MidiFilter.ConfigLog.LOG_ALL_PASSED);
- Returns:
-
setMidiOutFiltering
public void setMidiOutFiltering(boolean b) Filter out (discard) all Midi messages sent to Midi Out.Fire a PROP_MIDI_OUT_FILTERING property change event.
- Parameters:
b
- Filtering is ON is b is true, OFF otherwise.
-
isMidiOutFilteringOn
public boolean isMidiOutFilteringOn()- Returns:
- True if Midi out filtering is ON.
-
sendMidiMessagesOnJJazzMidiOut
Send the specified MidiMessages on the JJazzMidiOut device with timing -1 (immediate play).Midi volume messages are multiplicated by the master volume factor.
- Parameters:
mms
-
-
getMidiDevice
Find the MidiDevice whose Device.Info.name() is equals to mdName in the devices list.- Parameters:
midiDevices
-mdName
- Can be null- Returns:
- Null if not found.
-
getVirtualMidiSynthDevice
Get the VirtualMidiSynth MidiDevice, if present on a Windows system.- Returns:
- Can be null.
-
addPropertyChangeListener
-
removePropertyChangeListener
-
addPropertyChangeListener
-
removePropertyChangeListener
-
getDeviceFriendlyName
Get a friendly name for a MidiDevice.Remove any trailing "_MD" from the MidiDevice name. Also give a better name to "Gervill" Java internal synth. the Java default synth (sometimes "Gervill") to JAVA_INTERNAL_SYNTH_NAME. Use DeviceInfo.name otherwise.
- Parameters:
md
-- Returns:
-