So on every Button press it is going one Case up ?! am i right ?
So i could define a MidiCC Channel Change inside those "cases" ?
That's exactly the idea. Each press of the button "toggles" the knob mode between states 1, 2, 3, 4, and then puts it back to 1 with the next press.
And, yes...although I didn't quote the completely correct numbers, you could put the status byte in here (which is the first byte in a MIDI message and the one that tells the receiving device what you want to do with the following data bytes).
Then the analogRead of the knob in question sends the data byte...which, remembering running status, will keep coming in a stream until you signify you've changed the status byte again. I'm assuming the code snippets you are using deal with multiplexing the buttons, doing running status, conditioning the range, etc.!
(Heh..as we speak I'm trying to write my own running status routine -- I dunno why I'm not using the stock MIDI library, though.)
Well i guess the easiest way is to try it when i get my arduino.. Can anyone recommend a got read on the topic Midi Controlling via Arduino or Sound synthesis ? Because i have to stay on the theoretical side for another 2-3 weeks till the package from china arrives.
Two things you can do right now that seem useful to me;
-
Read up on MIDI. Especially if you have some keyboards or something around, and there are several free MIDI monitors that will run on your home computer. Plus you could always write some stuff in Processing (the "sister" to the Arduino IDE.) The idea is, you want to get a feeling for what a MIDI data stream "looks like" and start thinking in the language.
-
Write software. You can write and compile in the Arduino IDE without a board connected. It will check your code for syntax errors before it attempts to upload. Think of it like a spell check for code; it won't tell you if the code makes sense, but it will catch all the places you declared a variable inappropriately or forgot to close a bracket.
Plus, like I said, you can always write in Processing. The IDE is very similar, the language similar enough, and the result runs on your home computer.
You could actually write big chunks of the code using Processing to translate mouse clicks or similar to MIDI output, and then 'port that working code to the Arduino when that arrives.
I finished the Power supply, Charging, Battery, Case, Speaker, integrated amplifier planning stuff, so there is "only" coding and building left.
Nice. Test everything you can, so hardware problems don't sneak up on you during debugging! (I just went through that on my MIDI controlled servo project; the opto-isolator was having jitter when I was trying to write the MIDI note message parser!)
How are you charging a 9v battery pack off the 5v USB connection, by the way? Consider starting a thread in Exhibitions to show off how you are doing it. (I could use that, myself!)
So if i want to have multiple functions for a Button (digital) or Potentiometer (analog) i can use something like the example above ?
If the LCD should display where i am at the moment, i have to type the lcd.print inside the corresponding Case ?
Exactly. Except you could also test for "if (mode == n)" from within the LCD display subroutines, or where-ever else. Basically, do stuff like;
if (mode == 3) then LCD.write("Now Adjusting ADSR")
Because the value of mode is global; you declared it within the main program loop, so anywhere within main() -- err, sorry, "loop()"! -- is going to contain a valid value of the current mode.
(A simple trick and a very nice debug tool is just hang four LEDs on to four spare outputs so one ALWAYS lights up to tell you immediately what mode you are in. But you can do this with an LCD write for your program!)
I find arrays can really simplify life, but sometimes it is easier to read the code if you just have a stack of if/else statements sitting there.
Apologies again for the pseudo-code. I find it easier to think in pseudo-code, even if I am drifting towards a C-like syntax with it these days.