We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi there, I would like to convert the following midi sequencer to android An error occurred; Failed resolution of: Ljavax/sound/midi/MidiSystem I think something wrong around MidiBus, The sketch never open it's self on my phone. There is someone who could help me?
Thanks a lot! Giammy
import controlP5.*;
import themidibus.*;
int outDeviceNum = 1;
MidiBus midiBus;
ControlP5 cp5;
Knob myKnobA;
int col = color(255);
int slot = 16;
IntList inv;
int[] t = new int [16];
boolean START = true;
int myColor = color(255);
int c1,c2;
float n,n1;
boolean t20 = true;
boolean t50 = true;
boolean t80 = false;
boolean t110 = false;
boolean t140 = false;
boolean t170 = false;
boolean t200 = false;
boolean t230 = false;
boolean t260 = false;
boolean t290 = false;
boolean t320 = false;
boolean t350 = false;
boolean t380 = false;
boolean t410 = false;
boolean t440 = false;
boolean t470 = false;
int incr = 0;
void setup() {
size(860, 540, JAVA2D);
MidiBus.list();
midiBus = new MidiBus(this, -1, outDeviceNum);
//pixelDensity(displayDensity());
//smooth();
cp5 = new ControlP5(this);
cp5.setColorBackground(color(89,89,89));
cp5.setColorForeground(color(140,140,140)); //Qty & rim color
cp5.setColorActive(color(217,217,217)); //Selected items
for (int i = 20; i < 490; i = i+30) {
cp5.addToggle("t"+i)
.setPosition(i, 20)
.setSize(20, 20)
.setCaptionLabel("")
.setColorValue(100)
;
}
// myKnobA = cp5.addKnob("slot")
// .setRange(1, 16)
//.setValue(20)
// .setPosition(510, 10)
//.setRadius(20)
//.setDragDirection(Knob.VERTICAL)
//;
cp5.addToggle("start")
.setPosition(830, 512)
.setSize(20, 20)
.setCaptionLabel("PLAY")
;
cp5.addButton("slot2")
.setValue(0)
.setPosition(100,100)
.setSize(30,20)
;
cp5.addButton("slot3")
.setValue(0)
.setPosition(500,20)
.setSize(30,20)
;
}
void draw() {
//frameRate(8);
delay(120);
t[0]= int(t20);
t[1]= int(t50);
t[2]= int(t80);
t[3]= int(t110);
t[4]= int(t140);
t[5]= int(t170);
t[6]= int(t200);
t[7]= int(t230);
t[8]= int(t260);
t[9]= int(t290);
t[10]= int(t320);
t[11]= int(t350);
t[12]= int(t380);
t[13]= int(t410);
t[14]= int(t440);
t[15]= int(t470);
background(38,38,38);
if (incr > slot) {
incr = 0;
};
if (t[incr] == 1) {
sendNote(0, 36, 100, 100);
}
incr ++;
noStroke();
fill(217, 217, 217);
rect(18+((incr-1)*30), 18, 24, 24);
}
//void slot(int theValue) {
// slot = theValue-1;
//}
public void sendNote(final int channel, final int pitch, final int velocity, final int duration) {
Thread thread = new Thread(new Runnable() {
public void run() {
//println("sending note c:"+channel+" p:"+pitch+", v:"+velocity+", d:"+duration+", ");
midiBus.sendNoteOn(channel, pitch, velocity);
delay(duration);
midiBus.sendNoteOff(channel, pitch, velocity);
}
}
);
thread.start();
}
void slot2() {
slot = slot-1;
if(slot ==-1){slot = 0;}
}
void slot3() {
slot = slot+1;
if(slot ==16){slot = 15;}
}
// function colorA will receive changes from
// controller with name colorA
//public void colorA(int theValue) {
// println("a button event from colorA: "+theValue);
// slot = slot-1;
//c2 = color(0,160,100);
//}
/*
a list of all methods available for the Toggle Controller
use ControlP5.printPublicMethodsFor(Toggle.class);
to print the following list into the console.
You can find further details about class Toggle in the javadoc.
Format:
ClassName : returnType methodName(parameter type)
controlP5.Toggle : Toggle setMode(int)
controlP5.Toggle : Toggle setState(boolean)
controlP5.Toggle : Toggle setValue(boolean)
controlP5.Toggle : Toggle setValue(float)
controlP5.Toggle : Toggle toggle()
controlP5.Toggle : Toggle update()
controlP5.Toggle : boolean getState()
controlP5.Controller : CColor getColor()
controlP5.Controller : ControlBehavior getBehavior()
controlP5.Controller : ControlWindow getControlWindow()
controlP5.Controller : ControlWindow getWindow()
controlP5.Controller : Controller addCallback(CallbackListener)
controlP5.Controller : Controller addListener(ControlListener)
controlP5.Controller : Controller hide()
controlP5.Controller : Controller linebreak()
controlP5.Controller : Controller listen(boolean)
controlP5.Controller : Controller lock()
controlP5.Controller : Controller plugTo(Object)
controlP5.Controller : Controller plugTo(Object, String)
controlP5.Controller : Controller plugTo(Object[])
controlP5.Controller : Controller plugTo(Object[], String)
controlP5.Controller : Controller registerProperty(String)
controlP5.Controller : Controller registerProperty(String, String)
controlP5.Controller : Controller registerTooltip(String)
controlP5.Controller : Controller removeBehavior()
controlP5.Controller : Controller removeCallback()
controlP5.Controller : Controller removeCallback(CallbackListener)
controlP5.Controller : Controller removeListener(ControlListener)
controlP5.Controller : Controller removeProperty(String)
controlP5.Controller : Controller removeProperty(String, String)
controlP5.Controller : Controller setArrayValue(float[])
controlP5.Controller : Controller setArrayValue(int, float)
controlP5.Controller : Controller setBehavior(ControlBehavior)
controlP5.Controller : Controller setBroadcast(boolean)
controlP5.Controller : Controller setCaptionLabel(String)
controlP5.Controller : Controller setColor(CColor)
controlP5.Controller : Controller setColorActive(int)
controlP5.Controller : Controller setColorBackground(int)
controlP5.Controller : Controller setColorCaptionLabel(int)
controlP5.Controller : Controller setColorForeground(int)
controlP5.Controller : Controller setColorValueLabel(int)
controlP5.Controller : Controller setDecimalPrecision(int)
controlP5.Controller : Controller setDefaultValue(float)
controlP5.Controller : Controller setDisplay(ControllerDisplay)
controlP5.Controller : Controller setHeight(int)
controlP5.Controller : Controller setId(int)
controlP5.Controller : Controller setImages(PImage, PImage, PImage)
controlP5.Controller : Controller setImages(PImage, PImage, PImage, PImage)
controlP5.Controller : Controller setLabelVisible(boolean)
controlP5.Controller : Controller setLock(boolean)
controlP5.Controller : Controller setMax(float)
controlP5.Controller : Controller setMin(float)
controlP5.Controller : Controller setMoveable(boolean)
controlP5.Controller : Controller setPosition(PVector)
controlP5.Controller : Controller setPosition(float, float)
controlP5.Controller : Controller setSize(PImage)
controlP5.Controller : Controller setSize(int, int)
controlP5.Controller : Controller setStringValue(String)
controlP5.Controller : Controller setUpdate(boolean)
controlP5.Controller : Controller setValueLabel(String)
controlP5.Controller : Controller setVisible(boolean)
controlP5.Controller : Controller setWidth(int)
controlP5.Controller : Controller show()
controlP5.Controller : Controller unlock()
controlP5.Controller : Controller unplugFrom(Object)
controlP5.Controller : Controller unplugFrom(Object[])
controlP5.Controller : Controller unregisterTooltip()
controlP5.Controller : Controller update()
controlP5.Controller : Controller updateSize()
controlP5.Controller : ControllerProperty getProperty(String)
controlP5.Controller : ControllerProperty getProperty(String, String)
controlP5.Controller : Label getCaptionLabel()
controlP5.Controller : Label getValueLabel()
controlP5.Controller : List getControllerPlugList()
controlP5.Controller : PImage setImage(PImage)
controlP5.Controller : PImage setImage(PImage, int)
controlP5.Controller : PVector getAbsolutePosition()
controlP5.Controller : PVector getPosition()
controlP5.Controller : String getAddress()
controlP5.Controller : String getInfo()
controlP5.Controller : String getLabel()
controlP5.Controller : String getName()
controlP5.Controller : String getStringValue()
controlP5.Controller : String toString()
controlP5.Controller : Tab getTab()
controlP5.Controller : boolean isActive()
controlP5.Controller : boolean isBroadcast()
controlP5.Controller : boolean isInside()
controlP5.Controller : boolean isListening()
controlP5.Controller : boolean isLock()
controlP5.Controller : boolean isMouseOver()
controlP5.Controller : boolean isMousePressed()
controlP5.Controller : boolean isMoveable()
controlP5.Controller : boolean isUpdate()
controlP5.Controller : boolean isVisible()
controlP5.Controller : float getArrayValue(int)
controlP5.Controller : float getDefaultValue()
controlP5.Controller : float getMax()
controlP5.Controller : float getMin()
controlP5.Controller : float getValue()
controlP5.Controller : float[] getArrayValue()
controlP5.Controller : int getHeight()
controlP5.Controller : int getId()
controlP5.Controller : int getWidth()
controlP5.Controller : int listenerSize()
controlP5.Controller : void remove()
controlP5.Controller : void setDisplay(ControllerDisplay, int)
java.lang.Object : String toString()
java.lang.Object : boolean equals(Object)
*/
Answers
@chanof===
i suppose that your lib (themidibus) uses javaFXsound which is not supported by android. As for android, mediaplayer can read .mid files. For something like your code is doing you need another lib: i have used libpd for that with some results. This lib supposes that you install pd (vanilla).
Hi, thanks you for your help! may i ask how to use libpd? It's not on contribution manager, has you say it need pd but where, and how to recall it on the processing sketch? The best may be if you can do an example with code or maybe tell me a link? Thank you!
@chanof=== sorry: i have done that with Eclipse && never tried with P5...when i get some time i ll give a look. But i am quite sure that it is possible.
Thank You!
Hi Akenaton, i have an issue with libpd, according to http://robertesler.com/libpd-with-processing/ it need jack audio that is not already for new os as mine: sierra. And i think i can't install audio jack on Android, so, how you configure it? it work on android without jack?
@chanof===
seems that your link is too old see here: https://github.com/jackaudio/jack2/issues/144
(last comment from 2016, so it s possible that the last release woks with sierra)
Hi akenaton may i ask if you have experience about send midi with libpd thru the midi usb of the android device? I try libpd, and read some guide and i don't find this possibility thanks in advance