Hi guys,
I am new to using Processing and I am using it for my final year project at college. I'm developing piano tutorial software using Java/ Processing/ MIDI within the Eclipse IDE. I am having quite a few problems with some things, and still haven't resolved them after reading a lot of online resources, so I thought I'd try asking here :) Ok, here is a list of things that I can't figure out, and if anyone can help I'd be really grateful:
1. I currently have a Processing applet which represents a virtual piano. This Piano PApplet needs to be embedded into another PApplet if possible... I have tried this already, and it 'works' in a sense, but the graphics are freezing/ being temperamental. Below is code in setup() of a Lesson PApplet which adds the Piano PApplet to a JPanel (Swing), and the JPanel is then added to the current PApplet. I know this is probably a terrible approach, but I couldn't figure out another way to do it... Do I need to use threads- main thread to handle piano display & functionality, and another thread to handle displaying general lesson content?
2. How would I go about 'tokenizing' or splitting a type 0 midi sequence/ track into separate midi commands, and then somehow retrieve each note played and its midi note number? Note duration and velocity do not have to be considered, as it is beginner tutorial software so the user will only be learning note names, etc. The reason I want to do this is to create a MIDI Comparator- the user will play along to a MIDI song and the computer key they press must be mapped to a piano key. Retrieve this piano key's midi number and if it is == the midi number of the current note in the song, user gets a point. I have key mapping already implemented, just need to break a midi file into notes...
3. The computer keyboard is used to play the virtual piano. When the user presses a computer key, the relevant piano key is highlighted in colour and should then return to its original colour upon the release of the key. I have written the code in keyPressed() and keyReleased() in such a way that it does work, but the key does not stay highlighted for long enough (just a flicker). Or sometimes, if you press it for too long, it seems to infinitely loop! Is this to do with the loop()/ noLoop() thing I've read about? Problem is, I need draw() to keep looping to keep checking for both 'button' click and keyPressed() events... Help! :(
4. Loading one PApplet from another? My software has a lot of 'pages'/ windows... Do I have to use JFrames or is there actually a way to do it without embedding all of the PApplets into Swing containers?
Anyway, if anyone has any suggestions, please feel free to tell me :) If you need any more information/ more source code, etc. let me know. Thanks :)