Skip to content

Commit f95ae53

Browse files
author
Shaji Khan
committed
minor midi improvements
1 parent dc8d424 commit f95ae53

3 files changed

Lines changed: 36 additions & 4 deletions

File tree

.idea/deploymentTargetSelector.xml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/shajikhan/ladspa/amprack/MainActivity.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,28 +199,50 @@ public void logMidiMessage(byte[] data, int offset, int count) {
199199

200200
public void onSend(byte[] data, int offset,
201201
int count, long timestamp) throws IOException {
202+
ShortMessage shortMessage = new ShortMessage(data);
202203
byte command = (byte) (data[offset] & MidiConstants.STATUS_COMMAND_MASK);
203204
int channel = (byte) (data[offset] & MidiConstants.STATUS_CHANNEL_MASK);
204205
Log.i(TAG, "onSend: recieved message on channel " + channel);
205206
switch (command) {
206207
case MidiConstants.STATUS_NOTE_OFF:
207208
// noteOff(channel, data[1], data[2]);
209+
mainActivity.processMIDIMessage(channel, data [offset+1] & 0xFF, data [offset+2] & 0xFF);
210+
Log.d(TAG, String.format ("[midi note off] %s [%d] %d: %d",
211+
shortMessage.getCommand(), shortMessage.getChannel(),
212+
// data 1
213+
data [offset+1] & 0xFF,
214+
//data 2
215+
data [offset+2] & 0xFF));
208216
break;
209217
case MidiConstants.STATUS_NOTE_ON:
218+
mainActivity.processMIDIMessage(channel, data [offset+1] & 0xFF, data [offset+2] & 0xFF);
219+
Log.d(TAG, String.format ("[midi note on] %s [%d] %d: %d",
220+
shortMessage.getCommand(), shortMessage.getChannel(),
221+
// data 1
222+
data [offset+1] & 0xFF,
223+
//data 2
224+
data [offset+2] & 0xFF));
210225
// noteOn(channel, data[1], data[2]);
211226
break;
212227
case MidiConstants.STATUS_PITCH_BEND:
213228
int bend = (data[2] << 7) + data[1];
214229
// pitchBend(channel, bend);
230+
mainActivity.processMIDIMessage(channel, data [offset+1] & 0xFF, data [offset+2] & 0xFF);
231+
Log.d(TAG, String.format ("[midi pitch bend] %s [%d] %d: %d",
232+
shortMessage.getCommand(), shortMessage.getChannel(),
233+
// data 1
234+
data [offset+1] & 0xFF,
235+
//data 2
236+
data [offset+2] & 0xFF));
215237
break;
216238
case MidiConstants.STATUS_PROGRAM_CHANGE:
217239
// mProgram = data[1];
218240
// mFreeVoices.clear();
219241
Log.d(TAG, "onSend: program change");
242+
mainActivity.processMIDIMessage(channel, data [offset+1] & 0xFF, data [offset+2] & 0xFF);
220243
logMidiMessage(data, offset, count);
221244
break;
222245
case MidiConstants.STATUS_CONTROL_CHANGE:
223-
ShortMessage shortMessage = new ShortMessage(data);
224246
Log.d(TAG, "onSend: control change " );
225247
Log.d(TAG, String.format ("[midi control change] %s [%d] %d: %d",
226248
shortMessage.getCommand(), shortMessage.getChannel(),
@@ -536,7 +558,8 @@ public void onDeviceOpened(MidiDevice device) {
536558
@Override
537559
public void run() {
538560
Log.i(TAG, "[bt] run: connected device " + midiDevice.getInfo().getType());
539-
if (midiDevice.getInfo().getType() == MidiDeviceInfo.TYPE_USB)
561+
((TextView) findViewById(R.id.midi_name)).setText(midiDeviceInfo.getProperties().getString("name", ""));
562+
if (midiDevice.getInfo().getType() == MidiDeviceInfo.TYPE_USB || midiDevice.getInfo().getType() == MidiDeviceInfo.TYPE_VIRTUAL)
540563
(findViewById(R.id.midi_icon)).setVisibility(VISIBLE);
541564
else if (midiDevice.getInfo().getType() == MidiDeviceInfo.TYPE_BLUETOOTH)
542565
(findViewById(R.id.bt_icon)).setVisibility(VISIBLE);

app/src/main/res/layout/rack.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,15 @@
652652
android:textAlignment="center"
653653
android:layout_gravity="center"
654654
android:gravity="center"/>
655+
<TextView
656+
android:layout_width="wrap_content"
657+
android:layout_height="wrap_content"
658+
android:text=""
659+
android:id="@+id/midi_name"
660+
android:textAlignment="center"
661+
android:layout_gravity="center"
662+
android:textSize="9dp"
663+
android:fontFamily="@font/start"/>
655664
</LinearLayout>
656665
<Space
657666
android:visibility="gone"

0 commit comments

Comments
 (0)