cimo Posted February 10, 2008 Report Share Posted February 10, 2008 halloi thought i could use the spectrasymbol soft pots to trigger the BeatRepeater in Ableton with a single touch.To achieve that i need to:1- read the pot movement and send the CC void AIN_NotifyChange(unsigned char pin, unsigned int pin_value) __wparam { // a pot has been moved, send CC# at channel 1 MIOS_MIDI_TxBufferPut(0xb0); // CC at channel 1 MIOS_MIDI_TxBufferPut(pin); // pin number corresponds to CC number MIOS_MIDI_TxBufferPut(MIOS_AIN_Pin7bitGet(pin)); // don't send 10bit pin_value, // but 7bit value } 2- set a note ON message if the CC value is >0 (finger(or whatever) on softpot) 3- set a note OFF message if the CC value is =0 i thought i could transform the CC to Velocity and insert the ASM code for double note (with the proper adaptation) as found in the Meta Handler example in MB64 MB64E_META_Handler_DoubleNote call MIOS_MIDI_BeginStream ; begin stream ;; branch depending on content of MIDI_EVNT_VALUE movf MIDI_EVNT_VALUE, W ; get MIDI_EVNT_VALUE value bz MB64E_META_Handler_DoubleNoteOff ; when Zero (enc value = 00 or button released): send Note Off MB64E_META_Handler_DoubleNoteOn ;; NOTE ON movlw 0x90 ; send 0x90 (Note On Header, channel 0) call MIOS_MIDI_TxBufferPut movlw 0x00 ; send 0x00 (C-0) -- cakewalk needs this as MIDI Remote indicator call MIOS_MIDI_TxBufferPut movlw 0x7f ; send 0x7F (velocity) call MIOS_MIDI_TxBufferPut movf MIDI_EVNT1, W ; send content of second byte (08-0f) call MIOS_MIDI_TxBufferPut movlw 0x7f ; send 0x7F (velocity) call MIOS_MIDI_TxBufferPut rgoto MB64E_META_Handler_DoubleNoteEnd... am i in the right direction? simone Quote Link to comment Share on other sites More sharing options...
DavidBanner Posted February 10, 2008 Report Share Posted February 10, 2008 Cimo - I'm a C head as you know so I'm sticking to what I know - why don't you stick an if statement to check that the Pot is coming in on the correct AIN pin for the softpot you wish to control, and then fire off the 2 midi notes within the if statement?something like:void AIN_NotifyChange(unsigned char pin, unsigned int pin_value) __wparam{ if (pin == 1){ //fire off note on or CC info here }}Also why are you trying to send 2 midi notes? Beat repeat only requires 1 note to turn on the "power switch".Also instead of sending a CC - why not send a note on?Let me know if you need some more help.... Quote Link to comment Share on other sites More sharing options...
cimo Posted February 10, 2008 Author Report Share Posted February 10, 2008 hi davidi don t want to send 2 notes, i thought i could use that code to "double" the midi event-input: CC ----> -output CC (unchanged) + ON/OFF event (depending on CC value: 0=OFF, >0=ON)or maybe i could use the button event as "toggle" Quote Link to comment Share on other sites More sharing options...
DavidBanner Posted February 10, 2008 Report Share Posted February 10, 2008 ahhh!! i see what you meanbut I don't think you need the 2 events, the only time the AIN data is updated (i.e. the function is called) is when it gets a value. Quote Link to comment Share on other sites More sharing options...
cimo Posted February 11, 2008 Author Report Share Posted February 11, 2008 ok so:void AIN_NotifyChange(unsigned char pin, unsigned int pin_value) __wparam { // a pot has been moved, send CC# at channel 1 MIOS_MIDI_TxBufferPut(0xb0); // CC at channel 1 MIOS_MIDI_TxBufferPut(pin); // pin number corresponds to CC number MIOS_MIDI_TxBufferPut(MIOS_AIN_Pin7bitGet(pin)); // don't send 10bit //pin_value,but 7bit value { if (pin == 0){ //fire off note OFF else if (pin > 0) //fire off note ON } } } - how do i fire off a note on ? void DIN_NotifyToggle(unsigned char pin, unsigned char pin_value) is supposed to be called by MIOS when a button is depressed, what to do in this case?-what about the syntax? ::) Quote Link to comment Share on other sites More sharing options...
DavidBanner Posted February 11, 2008 Report Share Posted February 11, 2008 hehe - you've had a deep dark insight to my coding notes to myself there....let's step back a second - how do the softpots connect to the core, AIN or DIN?ignore that last code snippett - I didn't check it properly for errors - was psuedo code...void AIN_NotifyChange(unsigned char pin, unsigned int pin_value) __wparam{ // a pot has been moved, send CC# at channel 1 MIOS_MIDI_TxBufferPut(0xb0); // CC at channel 1 MIOS_MIDI_TxBufferPut(pin); // pin number corresponds to CC number MIOS_MIDI_TxBufferPut(MIOS_AIN_Pin7bitGet(pin)); // don't send 10bit //pin_value,but 7bit value if (pin == 0) { MIOS_MIDI_BeginStream(); MIOS_MIDI_TxBufferPut(0x90); // Note at channel 1 MIOS_MIDI_TxBufferPut(pin); // pin number corresponds to note number MIOS_MIDI_TxBufferPut(0 ? 0x00 : 0x7f); // buttons are high-active MIOS_MIDI_EndStream(); } else if (pin > 0) { MIOS_MIDI_BeginStream(); MIOS_MIDI_TxBufferPut(0x90); // Note at channel 1 MIOS_MIDI_TxBufferPut(pin); // pin number corresponds to note number MIOS_MIDI_TxBufferPut(127 ? 0x00 : 0x7f); // buttons are high-active MIOS_MIDI_EndStream(); } }that SHOULD work - i.e. not testedkeep an eye on the values in bold, they might not be right - a little digging / experimentation will tell you.... Quote Link to comment Share on other sites More sharing options...
cimo Posted February 11, 2008 Author Report Share Posted February 11, 2008 mmmi was just wondering.. Ableton responds to notes ON/OFF, i mean you send and ON/OFF and it will turn on the effect, you send an ON/OFF again, you turn it off.I don t know how it reacts when you send first a note ON event and then a note OFF.Also since the softpot will send 2 events at the same time, i need some trick to assign the parameter to Ableton, for example i can use an "assign" button that will send the same note.Too bad you can t assign parameters on a table as in the generic remote in cubase.Thanks for the input!What i don tunderstand is why you used the MIOS_MIDI_BeginStream()function, isn t that something you use only in linked cores?ah there was a bit of irony here:- how do i fire off a note on ? ;) Quote Link to comment Share on other sites More sharing options...
DavidBanner Posted February 11, 2008 Report Share Posted February 11, 2008 i was just wondering.. Ableton responds to notes ON/OFF, i mean you send and ON/OFF and it will turn on the effect, you send an ON/OFF again, you turn it off.I don t know how it reacts when you send first a note ON event and then a note OFF.mmm, good point - try it and see, I know the dBLive is sending a Note on and Off for each button pressso I guess it's being set by the note on?Also since the softpot will send 2 events at the same time, i need some trick to assign the parameter to Ableton, for example i can use an "assign" button that will send the same note.Too bad you can t assign parameters on a table as in the generic remote in cubase.well you can re-assign the pin or anything else in MIOS, so I would turn off one of the values being out-putted - set ableton, turn and then do it the other way round for the 2nd value....or you could do a midi remote script Quote Link to comment Share on other sites More sharing options...
cimo Posted February 11, 2008 Author Report Share Posted February 11, 2008 no no and no !! just remember the note and cc values and use eg. miosstudio virtual keyboard to set the parameter in Ableton ! Quote Link to comment Share on other sites More sharing options...
cimo Posted February 12, 2008 Author Report Share Posted February 12, 2008 ;D ;D ;Dhere it is:void AIN_NotifyChange(unsigned char pin, unsigned int pin_value) __wparam{ // a pot has been moved, send CC# at channel 1 MIOS_MIDI_TxBufferPut(0xb0); // CC at channel 1 MIOS_MIDI_TxBufferPut(pin); // pin number corresponds to CC number MIOS_MIDI_TxBufferPut(MIOS_AIN_Pin7bitGet(pin)); // don't send 10bit //pin_value,but 7bit value if (MIOS_AIN_Pin7bitGet(pin) == 0) { MIOS_MIDI_TxBufferPut(0x90); // Note at channel 1 MIOS_MIDI_TxBufferPut(pin); // pin number corresponds to note number MIOS_MIDI_TxBufferPut(0x00); // buttons are high-active } else if (MIOS_AIN_Pin7bitGet(pin) > 0) { MIOS_MIDI_TxBufferPut(0x90); // Note at channel 1 MIOS_MIDI_TxBufferPut(pin); // pin number corresponds to note number MIOS_MIDI_TxBufferPut(0x7f); // buttons are high-active } } Quote Link to comment Share on other sites More sharing options...
cimo Posted February 12, 2008 Author Report Share Posted February 12, 2008 ..getting better and better but what i ve feared about Ableton behavior s actually happened: it s waiting for a ON/OFF to turn on and ON/OFF again to turn off.It gets tricky to get the proper behavior, anyway here is the latest code (note i use 13 as a switch value cause the pot wont go under that value for some reason, probably construction/hardware.void AIN_NotifyChange(unsigned char pin, unsigned int pin_value) __wparam{ // a pot has been moved, send CC# at channel 1 MIOS_MIDI_TxBufferPut(0xb0); // CC at channel 1 MIOS_MIDI_TxBufferPut(50); // pin number corresponds to CC number MIOS_MIDI_TxBufferPut(MIOS_AIN_Pin7bitGet(pin)); // don't send 10bit //pin_value,but 7bit value if (MIOS_AIN_Pin7bitGet(pin) < 13) { MIOS_MIDI_TxBufferPut(0x90); // Note at channel 1 MIOS_MIDI_TxBufferPut(pin); // pin number corresponds to note number MIOS_MIDI_TxBufferPut(0x00); // buttons are high-active MIOS_MIDI_TxBufferPut(0x90); // Note at channel 1 MIOS_MIDI_TxBufferPut(pin); // pin number corresponds to note number MIOS_MIDI_TxBufferPut(0x7f); // buttons are high-active } else if (MIOS_AIN_Pin7bitGet(pin) > 13) { MIOS_MIDI_TxBufferPut(0x90); // Note at channel 1 MIOS_MIDI_TxBufferPut(pin); // pin number corresponds to note number MIOS_MIDI_TxBufferPut(0x00); // buttons are high-active MIOS_MIDI_TxBufferPut(0x90); // Note at channel 1 MIOS_MIDI_TxBufferPut(pin); // pin number corresponds to note number MIOS_MIDI_TxBufferPut(0x7f); // buttons are high-active } }still the behavior is erratic , need to figure something else out. Quote Link to comment Share on other sites More sharing options...
cimo Posted February 12, 2008 Author Report Share Posted February 12, 2008 ..maybe..i need to scan the state of the MIDI coming from Abletondunno if with USER_MPROC_NotifyReceivedEvent or MIOS_DOUT_PinGetso: if BeatRepeat is OFF and cc>0 then send note ON/OFF else if BeatRepeat is ON and cc==0 then send note ON/OFF else if BeatRepeat is OFF and cc==0 then do nothing else if BeatRepeat is ON and cc>0 then do nothingwhat do you think? Quote Link to comment Share on other sites More sharing options...
cimo Posted February 12, 2008 Author Report Share Posted February 12, 2008 .. me again, sooo easy, get ableton 6 or 7 and you can just assign the softpot to both plugin-on/off button and grid value, then in the MIDI mappings just set minimum at around 3 and max at 127.that s it.Still i am interested to finish that code cause i don t have a no-demo 6 or 7 ableton version.And for learning too.txit s quite a funny toy! Quote Link to comment Share on other sites More sharing options...
bugfight Posted February 12, 2008 Report Share Posted February 12, 2008 i will chime in for a second here on a coding issue (don't know live so can't help there...)this if (MIOS_AIN_Pin7bitGet(pin) == 0) { ... } else if (MIOS_AIN_Pin7bitGet(pin) > 0) { ... } would be better like this (for both code and execution efficiency): if (MIOS_AIN_Pin7bitGet(pin) == 0) { ... } else { ... } on the other hand this: if (MIOS_AIN_Pin7bitGet(pin) < 13) { ... } else if (MIOS_AIN_Pin7bitGet(pin) > 13) { ... } actually skips the value 13 as well, which i think you didn't intend, so would be much better this way: if (MIOS_AIN_Pin7bitGet(pin) < 13) { ... } else { ... } hope that helps... Quote Link to comment Share on other sites More sharing options...
stryd_one Posted February 13, 2008 Report Share Posted February 13, 2008 Totally. every time you do an 'if', it processes the input accordingly. #define SOFTPOT_MIN 13 if (MIOS_AIN_Pin7bitGet(pin) <= SOFTPOT_MIN) { ... } else { ... } Just a thought.....Keeps it portable. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.