Bassman Posted May 10, 2008 Report Share Posted May 10, 2008 Is it possible to insert a short routine at MIDI_EVNT_Send_9x to add 0x0C or 0x00 to MIDI_EVNT1 (this would be the note number) from a user register, before the Note On gets sent? Is it then possible to use a meta event as a hook to store either 0x00 or 0x0c in that user register? Would this achieve an octave toggle? What register should be used?excert from midi_evnt.inc;; sending three bytes: MIDI_EVNT_Send_8x ; Note Off. rgoto MIDI_EVNT_Send_BxMIDI_EVNT_Send_9x ; Note On ;; add a routine hereMIDI_EVNT_Send_Ax ; AftertouchMIDI_EVNT_Send_Bx ; Controller movff MIDI_EVNT0, WREG call MIOS_MIDI_TxBufferPut movff MIDI_EVNT1, WREG andlw 0x7f call MIOS_MIDI_TxBufferPut movff MIDI_EVNT_VALUE, WREG andlw 0x7f call MIOS_MIDI_TxBufferPut rgoto MIDI_EVNT_Send_EndIf I am barking up the wrong tree, is there a better way to approach this?thanksKeith Quote Link to comment Share on other sites More sharing options...
stryd_one Posted May 12, 2008 Report Share Posted May 12, 2008 Don't you want it to work for note off's? ;)Define a new variable for this, and set it's value as 0x0c in a meta event like you said, then around line 56 of midi_evnt.inc: ;; sending three bytes: MIDI_EVNT_Send_8x ; Note Off MIDI_EVNT_Send_9x ; Note On ;; Add your variable to evnt1 here MIDI_EVNT_Send_Ax ; Aftertouch MIDI_EVNT_Send_Bx ; Controller movff MIDI_EVNT0, WREG call MIOS_MIDI_TxBufferPut movff MIDI_EVNT1, WREG andlw 0x7f call MIOS_MIDI_TxBufferPut movff MIDI_EVNT_VALUE, WREG andlw 0x7f call MIOS_MIDI_TxBufferPut rgoto MIDI_EVNT_Send_End Quote Link to comment Share on other sites More sharing options...
Bassman Posted May 12, 2008 Author Report Share Posted May 12, 2008 Thanks stryd_one,I thought it looked possible. where is the right place to define a new variable?thanksbassman Quote Link to comment Share on other sites More sharing options...
stryd_one Posted May 12, 2008 Report Share Posted May 12, 2008 app_defines.h is the go, you could put it at the bottom: CSMD_POTBASE EQU 0x299 ;;holds POT# of top left pot in zone ;; ========================================================================== NOTE_SHIFT EQU 0x300 ;;holds value for note number shift This looks to be free also, and might be a better place: ;; used by drums.inc DRUMS_STATE_BEGIN EQU 0x068 ; for 8 drum triggers DRUMS_STATE_END EQU 0x06f DRUMS_MAX_VALUE_BEGIN EQU 0x060 ; for 8 drum triggers DRUMS_MAX_VALUE_END EQU 0x067 DRUMS_CTR EQU 0x068 ; used as loop counter ;; used by Bassman's note shifting code NOTE_SHIFT EQU 0x069 ;;holds value for note number shift ;; ========================================================================== Quote Link to comment Share on other sites More sharing options...
Bassman Posted May 15, 2008 Author Report Share Posted May 15, 2008 Well this is finally working. I got my mb64 to do transpose.Here's my extra code to use META_EVENT_8 to perform a note shift or transpose.When you assign a button to a meta event, in the Edit Events, first it's midi channel 1, the first hex number will be 08 (meta function #8) and the second hex number will be the number of half steps to transpose up (an octave will be 12 notes 0C hex). Lastly set the button mode to T (Toggle), unless you want to use 2 buttons for up and down, then O for OnOnly. In theory you can go up almost 10 octaves, yikes, at the touch of a button.Hope it's useful for anyone.Oh, one thing, I haven't trapped the possiblility of transposing whilst another button is held down, you'll get notes stuck on. Insert into app_defines.h after line 196 DRUMS_CTR;; used by Bassman's note shifting code NOTE_SHIFT EQU 0x69 ;;holds value for note number shift Insert into midi_event.inc after line 71 MIDI_EVNT_Send_9x ;; pickup NOTE_SHIFT value and add to current note number movf NOTE_SHIFT, W ;; get note shift value addwf MIDI_EVNT1, W movwf MIDI_EVNT1 so the section will look like; ;; sending three bytes: MIDI_EVNT_Send_8x ; Note Off MIDI_EVNT_Send_9x ; Note On ;; pickup NOTE_SHIFT value and add to current note number movf NOTE_SHIFT, W ;; get note shift value addwf MIDI_EVNT1, W ;; add NOTE_SHIFT to MIDI_EVNT1 movwf MIDI_EVNT1 MIDI_EVNT_Send_Ax ; Aftertouch MIDI_EVNT_Send_Bx ; Controller movff MIDI_EVNT0, WREG call MIOS_MIDI_TxBufferPut movff MIDI_EVNT1, WREG andlw 0x7f call MIOS_MIDI_TxBufferPut movff MIDI_EVNT_VALUE, WREG andlw 0x7f call MIOS_MIDI_TxBufferPut rgoto MIDI_EVNT_Send_End This will only affect notes. But you could adapt it for other events, like move all your program changes up by 16 or 32 etc. In this case use similar 3 extra lines but put it after MIDI_EVNT_Send_Cx ; Program Change, just change the 2 references to MIDI_EVNT1 to MIDI_EVNT_VALUE. Lastly Insert into mb64_meta.inc after line 184 MB64_META_Handler_08; movff MIDI_EVNT_VALUE, NOTE_SHIFT ;; Save shift amount in NOTE_SHIFT return ;; exit So it will look like this; ;; a trick: all labels are pointing to the same routine ;; Currently mb64_meta events are all F0, so midi channel 1 ;; Use the first hex number in Event Edit - Meta to determine which Meta handler # to jump to. ;; Use the second hex number in Event Edit - Meta to determine number of notes to transpose MB64_META_Handler_08 ;; Perform Note shift ;; BANKED access not required - see mb64_meta.inc movff MIDI_EVNT_VALUE, NOTE_SHIFT ;; Save shift amount in NOTE_SHIFT return ;; exit MB64_META_Handler_09 MB64_META_Handler_0A MB64_META_Handler_0B MB64_META_Handler_0C MB64_META_Handler_0D MB64_META_Handler_0E MB64_META_Handler_0F Many thanks to stryd_one, who helped me figure it out.bassman Quote Link to comment Share on other sites More sharing options...
stryd_one Posted May 15, 2008 Report Share Posted May 15, 2008 Nice one dude :) Quote Link to comment Share on other sites More sharing options...
bugfight Posted May 15, 2008 Report Share Posted May 15, 2008 as tk pointed out to me in this thread , there is a risk of sending invalid midi data when transposing (you want to avoid sending midi data above 0x7F)in my example i just rapped out of range notes around note 0, but for your case you might just want to block them... Quote Link to comment Share on other sites More sharing options...
stryd_one Posted May 15, 2008 Report Share Posted May 15, 2008 Hahah I'm such a git... I looked at it and thought "that could overflow... ah well it'll just roll around to 0..."7 bit, stryd....just ANDLW 0x7F to mask it... Quote Link to comment Share on other sites More sharing options...
Bassman Posted May 15, 2008 Author Report Share Posted May 15, 2008 There's no need to worry about this because the original code for sending 3 bytes already deals with this. ;; sending three bytes: MIDI_EVNT_Send_8x ; Note OffMIDI_EVNT_Send_9x ; Note OnMIDI_EVNT_Send_Ax ; AftertouchMIDI_EVNT_Send_Bx ; Controller movff MIDI_EVNT0, WREG call MIOS_MIDI_TxBufferPut movff MIDI_EVNT1, WREG andlw 0x7f ;; oveflow to above 0x7f dealt with here! call MIOS_MIDI_TxBufferPut movff MIDI_EVNT_VALUE, WREG andlw 0x7f call MIOS_MIDI_TxBufferPut rgoto MIDI_EVNT_Send_Endbut it was something I thought of, thanks, TK has already made sure nothing like that can upset things.Anyway, I thought it best used with the button in Toggle mode, that way it transforms, then returns to normal.bassman Quote Link to comment Share on other sites More sharing options...
bugfight Posted May 16, 2008 Report Share Posted May 16, 2008 There's no need to worry about this because the original code for sending 3 bytes already deals with this....true, as long as you don't mind very high notes becoming very low notes, or if transposing down, very low notes becoming very high notes Quote Link to comment Share on other sites More sharing options...
Bassman Posted May 16, 2008 Author Report Share Posted May 16, 2008 Hi bugfight,Actually that can't happen. You can only implement this with Meta Evnt #8, whatever number you enter as the second Hex number in 'Edit Event' is the amount it will transpose up. It doesn't keep adding, no matter what mode you choose for the button. I suppose you could put a transpose of 127 (h7f), which would cause it to wrap around to 0, but why would anyone do that?Anyway, I'm just trying to post things that might be useful to someone.bassman Quote Link to comment Share on other sites More sharing options...
stryd_one Posted May 17, 2008 Report Share Posted May 17, 2008 Anyway, I'm just trying to post things that might be useful to someone.It's totally useful and appreciated... But it makes sense to discuss such things for the optimal result, right? Bugfight and I spend hours upon hours discussing our methods, finding flaws and improvements in each others work.... we don't get offended by each other.... No need to be all passive-defensive :) Quote Link to comment Share on other sites More sharing options...
Bassman Posted May 18, 2008 Author Report Share Posted May 18, 2008 To all,Hey sorry to give the impression I was offended, not at all, I am grateful to everyone for their help.I don't have anyone to discuss things with, except here, I thought that's what I was doing. Anyway nuff said!Right now I am trying to figure out how to allow someone to press a button that sends a note on, and do the transpose whilst holding the note.At the moment, the note gets left on, as the MIDI_EVNT1 gets added too, before note off (or rather note on, zero velocity). It might be easy enough to account for one note, but there could be a while chord. Any ideas here?Same would apply to Prog change. It might be usefull to shift a whole group of buttons up/down by 8 or 16. But if the transpose happened whilst a button was held down, it could get messy.bassman Quote Link to comment Share on other sites More sharing options...
Bassman Posted May 18, 2008 Author Report Share Posted May 18, 2008 Yes, I guess the "Anyway, I'm just trying to post things that might be useful to someone."could easily be taken as passive/defensive.Sorry guys, my faultbassman Quote Link to comment Share on other sites More sharing options...
stryd_one Posted May 20, 2008 Report Share Posted May 20, 2008 Hey dude sorry to disappear - family stuff... I'll reply soon :) Quote Link to comment Share on other sites More sharing options...
stryd_one Posted May 21, 2008 Report Share Posted May 21, 2008 OK back again (for now)....What you're talking about doing now, is really a totally different kettle of fish to what you started talking about. Initially, you wanted to configure an offset before sending an event. Now, you will have to keep a queue of the events which are currently 'active', and then stop them all, apply the shift, and start them again. Really, it's a totally different thing, and maybe even better suited to a completely different application, as it will require significant mods to MB64's note sending functions. Quote Link to comment Share on other sites More sharing options...
Bassman Posted May 22, 2008 Author Report Share Posted May 22, 2008 Yes, you're right, the more I thought about it, and looked at the code, the more complex it became. In principal, I think the simple alterations I made were fine for the application, it is quite useful as a simple Meta Event, the user can program the transposition. With minor mods other Meta events can be used to shift Prg Changes or a particular controller etc. All useful to perhaps cut down on the amount of hardware needed, or to expand the use of current hardware used.I'm trying to take it into the musical instrument sphere, which is not the purpose of the midibox64.I'm happy to have achieved my little mod, I can do so much more with remote control using the transpose, to shift up/down a set of functions.However, regarding your point.you will have to keep a queue of the events which are currently 'active', and then stop them all, apply the shift, and start them againSurely all I have to do is search the DIN registers, and that routine is already there somewhere. If I don't fine any zeros I can apply the shift, if there are zeros, wait until they're all set before applying the shift. Wouldn't that work? I don't need to know what events are 'active', only if there are any?bassman Quote Link to comment Share on other sites More sharing options...
stryd_one Posted May 23, 2008 Report Share Posted May 23, 2008 I could be wrong about this, but I don't think that the MB64 keeps the state of all the buttons in memory. Quote Link to comment Share on other sites More sharing options...
Bassman Posted May 24, 2008 Author Report Share Posted May 24, 2008 Aren't these the button events? Around line 285 in app_defines.h? ;; button events, byte 0 MB64_BUTTON_EVNT0_00 EQU 0x200 ;; ... MB64_BUTTON_EVNT0_3F EQU 0x23f ;; button events, byte 1 MB64_BUTTON_EVNT1_00 EQU 0x240 ;; ... MB64_BUTTON_EVNT1_3F EQU 0x27f ;; button values (packed) MB64_BUTTON_VALUES_SR0 EQU 0x280 ;; ... MB64_BUTTON_VALUES_SR7 EQU 0x287 ;; midi button values (packed) MB64_MBUTTON_VALUES_SR0 EQU 0x288 ;; ... MB64_MBUTTON_VALUES_SR7 EQU 0x28fMaybe I'm wrong, but this looks like the place.bassman Quote Link to comment Share on other sites More sharing options...
stryd_one Posted May 24, 2008 Report Share Posted May 24, 2008 Looks that way :)Aren't you glad one of us bothered to look at the code ? hehehe Quote Link to comment Share on other sites More sharing options...
Bassman Posted May 27, 2008 Author Report Share Posted May 27, 2008 Well, I tried and tried, I can't figure out a good approach to this. I think I'll have to leave it on the back burner until I can spend more time on it.Thanks for your help Stryd, until the next problem?bassman 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.