# Themidibus - can't receive input

**URL:** https://discourse.processing.org/t/themidibus-cant-receive-input/33512
**Category:** Libraries
**Created:** [November 14, 2021, 8:48pm UTC](https://discourse.processing.org/t/themidibus-cant-receive-input/33512 "2021-11-14T20:48:07Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Louwo](https://avatars.discourse-cdn.com/v4/letter/l/b487fb/32.png) [@Louwo](https://discourse.processing.org/u/Louwo)
#### Post date: [November 14, 2021, 8:48pm UTC](https://discourse.processing.org/t/themidibus-cant-receive-input/33512/1 "2021-11-14T20:48:07Z")

</div>

Hello everyone,  
I’m trying to connect my digital piano to processing, with the themidibus library. I have no problem for sending messages to my piano but I can’t receive any information from it. I used the example code from the Github page ([https://github.com/sparks/themidibus/blob/master/examples/Basic/Basic.pde](https://github.com/sparks/themidibus/blob/master/examples/Basic/Basic.pde)) and didn’t change anything except one thing : I replaced the line 24  
myBus = new MidiBus(this, -1, “Java Sound Synthesizer”);  
with  
myBus = new MidiBus(myBus, 1, 4);  
where 1 and 4 correspond respectively to my piano as input device and output device. I had to replace “this” by “myBus” otherwise I had a null pointer exception.  
How is it possible that I can send outputs but not receive any input ?  
As you can see from my message, I’m really new to this field so please take it easy ^^  
Thank you very much for reading and hope you can help me !

---

<div class="post-metadata">

### Author: ![esebesty](https://avatars.discourse-cdn.com/v4/letter/e/977dab/32.png) [@esebesty](https://discourse.processing.org/u/esebesty)
#### Post date: [November 26, 2023, 8:23pm UTC](https://discourse.processing.org/t/themidibus-cant-receive-input/33512/2 "2023-11-26T20:23:29Z")

</div>

Hey, looks like I have the same problem. I’m trying to use a nanoKONTROL Studio with Processing and themidibus library, but no luck, can’t get any info out of it.

I found [this stackoverflow thread](https://stackoverflow.com/questions/34622204/midi-out-transmitter-not-available) with a probably similar problem (I’m no java expert at all). After compiling and running the java code with all 3 java versions on my machine, all of them show `maxTransmitters=0` so I guess that might be the problem? Java does not see the input port?

Any pointers on what to do with this?

macOS 14.1.1, Processing 4.3, OpenJDK 11/20/21

---

<div class="post-metadata">

### Author: ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)
#### Post date: [November 26, 2023, 10:25pm UTC](https://discourse.processing.org/t/themidibus-cant-receive-input/33512/3 "2023-11-26T22:25:15Z")

</div>

This driver may or may not be helpful:  
[https://www.korg.com/us/support/download/driver/0/552/1357/](https://www.korg.com/us/support/download/driver/0/552/1357/)

What do you see in the console when you run this code:

```auto
import themidibus.*;

void setup() {
  surface.setVisible(false);
  // List all our MIDI devices
  MidiBus.list();
}

```

Do you have a minimal example that you could post? It would be helpful to see the code that you are using.

---

<div class="post-metadata">

### Author: ![esebesty](https://avatars.discourse-cdn.com/v4/letter/e/977dab/32.png) [@esebesty](https://discourse.processing.org/u/esebesty)
#### Post date: [November 27, 2023, 11:57am UTC](https://discourse.processing.org/t/themidibus-cant-receive-input/33512/4 "2023-11-27T11:57:11Z")

</div>

Thanks, tried to install the driver, but it gave an error at the last step, probably the os version is not supported. However, something did change, as running your code now shows:

```auto
Available MIDI Devices:
----------Input----------
[0] "IAC Driver - Bus 1"
[1] "nanoKONTROL Studio - CTRL"
[2] "Real Time Sequencer"
[3] "Bus 1"
[4] "CTRL"
----------Output----------
[0] "IAC Driver - Bus 1"
[1] "nanoKONTROL Studio - CTRL"
[2] "Gervill"
[3] "Real Time Sequencer"
[4] "Bus 1"
[5] "CTRL"

```

Yesterday, the `"nanoKONTROL Studio - CTRL"` did not show up, only the rest.

Minimal example:

```auto
import themidibus.*;

MidiBus myBus; 

void setup() {
  size(400, 400);
  
  MidiBus.list(); 
    
  myBus = new MidiBus(myBus, 1, 1);
  // or 4, 5
  // still nothing

}

void draw() {
  background(0);
}

void controllerChange(int channel, int number, int value) {
  println();
  println("Controller Change:");
  println("--------");
  println("Channel:"+channel);
  println("Number:"+number);
  println("Value:"+value);
}

```

The same MIDI controller on the same machine works without any problem with Supercollider and SonicPI.

---

<div class="post-metadata">

### Author: ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)
#### Post date: [November 27, 2023, 12:53pm UTC](https://discourse.processing.org/t/themidibus-cant-receive-input/33512/5 "2023-11-27T12:53:32Z")

</div>

Try changing the output to 2 or 3. I use:

> myBus = new MidiBus(this, 1, 2); // Parent, In, Out

The following source code works for a Qmini:

```auto
import themidibus.*;
import processing.sound.*;

MidiBus myBus;
float freq = 0;
TriOsc triOsc;
Env env;

int channel = 0;
int pitch = 0;
int velocity = 0;
String name = "";

// Times and levels for the ASR envelope
float attackTime = 0.0010;
float sustainTime = 0.014;
float sustainLevel = 0.3;
float releaseTime = 0.2;

void setup() {
  size(400, 400);
  surface.setLocation(200, 100);
  MidiBus.list();
  myBus = new MidiBus(this, 1, 2); // (Parent, In, Out)  
  triOsc = new TriOsc(this);
  env = new Env(this);
}

void draw() {
  background(209);
  myBus.sendNoteOn(channel, pitch, velocity); // Send a Midi noteOn
  delay(100);
  // myBus.sendNoteOff(channel, note, velocity); // Send a Midi nodeOff
  // delay(100);
}

float midiToFreq(int note) {
  return (pow(2, ((note-69)/12.0))) * 440;
}

void noteOn(int channel, int pitch, int velocity) {
  freq = midiToFreq(pitch);
  name = pitchMap[pitch%12];
  println("========================================");
  println("note = " + pitch + " : name = " + name +" : freq =", freq );
  triOsc.play(freq, 1);
  env.play(triOsc, attackTime, sustainTime, sustainLevel, releaseTime);
  fill(255);
  circle(30, 30, 20);
}

void delay(int time) {
  int current = millis();
  while (millis () < current+time) Thread.yield();
}

static String[] pitchMap = new String[] {
    "C",
    "C#",
    "D",
    "D#",
    "E",
    "F",
    "F#",
    "G",
    "G#",
    "A",
    "A#",
    "B"
  };

```

---

<div class="post-metadata">

### Author: ![esebesty](https://avatars.discourse-cdn.com/v4/letter/e/977dab/32.png) [@esebesty](https://discourse.processing.org/u/esebesty)
#### Post date: [November 27, 2023, 1:29pm UTC](https://discourse.processing.org/t/themidibus-cant-receive-input/33512/6 "2023-11-27T13:29:05Z")

</div>

Changing the output channel did not help, but I just discovered that Processing is installing version 008 when using the library manager. However, there is a 009 release, that fixes some issues. The jar is not available in the [original github repo](https://github.com/sparks/themidibus/releases/tag/009), but [one of the forks](https://github.com/micycle1/themidibus/releases/tag/p4) has it. If I replace the library manager installed jar with the one from the fork, everything starts working!
