[orx-midi] Fix problem in bindMidiNote
This commit is contained in:
@@ -22,12 +22,11 @@ fun bindMidiNote(on: () -> Unit, off: () -> Unit, transceiver: MidiTransceiver,
|
|||||||
}
|
}
|
||||||
transceiver.noteOff.listen {
|
transceiver.noteOff.listen {
|
||||||
if ((channel == -1 || it.channel == channel) && it.note == note) {
|
if ((channel == -1 || it.channel == channel) && it.note == note) {
|
||||||
on()
|
off()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@JvmName("bindMidiControlDouble")
|
@JvmName("bindMidiControlDouble")
|
||||||
fun Program.bindMidiControl(
|
fun Program.bindMidiControl(
|
||||||
property: KMutableProperty0<Double>,
|
property: KMutableProperty0<Double>,
|
||||||
|
|||||||
@@ -48,7 +48,8 @@ class MidiConsole: Extension {
|
|||||||
|
|
||||||
override fun afterDraw(drawer: Drawer, program: Program) {
|
override fun afterDraw(drawer: Drawer, program: Program) {
|
||||||
drawer.defaults()
|
drawer.defaults()
|
||||||
box = Rectangle(drawer.width - box.width, 0.0, box.width, drawer.height*1.0)
|
synchronized(messages) {
|
||||||
|
box = Rectangle(drawer.width - box.width, 0.0, box.width, drawer.height * 1.0)
|
||||||
val positions = List(messages.size) { index ->
|
val positions = List(messages.size) { index ->
|
||||||
Vector2(box.x, box.y + index * 16.0 + 16.0)
|
Vector2(box.x, box.y + index * 16.0 + 16.0)
|
||||||
}
|
}
|
||||||
@@ -58,4 +59,5 @@ class MidiConsole: Extension {
|
|||||||
drawer.fill = ColorRGBa.WHITE
|
drawer.fill = ColorRGBa.WHITE
|
||||||
drawer.texts(messages, positions)
|
drawer.texts(messages, positions)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -65,7 +65,7 @@ data class MidiDeviceDescription(
|
|||||||
|
|
||||||
class MidiTransceiver(program: Program, val receiverDevice: MidiDevice?, val transmitterDevicer: MidiDevice?) {
|
class MidiTransceiver(program: Program, val receiverDevice: MidiDevice?, val transmitterDevicer: MidiDevice?) {
|
||||||
companion object {
|
companion object {
|
||||||
fun fromDeviceVendor(program: Program, name: String, vendor: String): MidiTransceiver {
|
fun fromDeviceVendor(program: Program, name: String, vendor: String? = null): MidiTransceiver {
|
||||||
val infos = MidiSystem.getMidiDeviceInfo()
|
val infos = MidiSystem.getMidiDeviceInfo()
|
||||||
|
|
||||||
var receiverDevice: MidiDevice? = null
|
var receiverDevice: MidiDevice? = null
|
||||||
@@ -75,17 +75,17 @@ class MidiTransceiver(program: Program, val receiverDevice: MidiDevice?, val tra
|
|||||||
try {
|
try {
|
||||||
val device = MidiSystem.getMidiDevice(info)
|
val device = MidiSystem.getMidiDevice(info)
|
||||||
if (device !is Sequencer && device !is Synthesizer) {
|
if (device !is Sequencer && device !is Synthesizer) {
|
||||||
if (info.vendor == vendor && info.name == name) {
|
if ((vendor == null || info.vendor == vendor) && info.name == name) {
|
||||||
logger.info { "found matching device $name / $vendor" }
|
logger.info { "found matching device $name / $vendor" }
|
||||||
if (device.maxTransmitters != 0 && device.maxReceivers == 0) {
|
if (device.maxTransmitters != 0 && device.maxReceivers == 0) {
|
||||||
transmitterDevice = device
|
transmitterDevice = device
|
||||||
logger.info {
|
logger.debug {
|
||||||
"found transmitter"
|
"found transmitter"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (device.maxReceivers != 0 && device.maxTransmitters == 0) {
|
if (device.maxReceivers != 0 && device.maxTransmitters == 0) {
|
||||||
receiverDevice = device
|
receiverDevice = device
|
||||||
logger.info {
|
logger.debug {
|
||||||
"found receiver"
|
"found receiver"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user