Ok, I came up with some different sollutions, since the one first suggested by Luis didn’t work. After I just tried something myself, wich worked, Luis also suggested that method to me. I’m not an assembler programmer, so if you spot a mistake I’ll be happy to hear it!
This is what works for me, It sends two different notes on, one for each way when turning. When you stop turning it sends them both off. Also, it sends a note off every time just before it sends a note on. This is so that traktor doesn’t keep on increasing the pitch bend because it’s stopped everytime. I haven’t really tested it enough to see if this really works like that, but you could always remove the first 0x00 and call to MIDI_EVNT_SEND. I have only tested thisone with traktor 3, but I am pretty sure that is also works with traktor 2, also because Luis suggested it to me.
Also there is the scratch function, wich I will be using soon in combination with a button. So when the button is pressed you can scratch, when it’s not you can pitchbend. You have to assign the note of the scratch function to scratch on in traktor and the cc to the scratch itself (set it to incremental). This works pretty sweet :). This one both worked in traktor 2.6.1 and 3.
;; Beginning, I use two pitchbend encoders, the otherone is the same but with a 2 on the end, this because it also uses a seperate timer, this could probably be done butter, but it is sufficient for me since I only use 2 pitchbend encoders
;; if pitchbend encoder do ENC_PITCH_BEND
movf MIOS_PARAMETER1, W
xorlw 0x01
skpnz
goto ENC_PITCH_BEND
movf MIOS_PARAMETER1, W
xorlw 0x00
skpnz
goto ENC_PITCH_BEND2
;;;;;;;;;;;;;;;;;;;;;;; standard mios code
;;else continue at ENC handler
movf MIOS_PARAMETER1, W
goto MB64E_ENC_Handler
;;;;;;;;;;;;;;;;;;;;;;;; emd standard mios code
ENC_SCRATCH
movf SCRATCH_TIMER, W ;; When the timer hasn’t started yet, the start note should be sent
skpnz
call SCRATCH_START
movlw 0x64
movwf SCRATCH_TIMER ;; Set the timer again
movf MIOS_PARAMETER2,W ;; Check if negative
bn SCRATCH_DOWN
goto SCRATCH_UP
SCRATCH_START
movlw 0x90
movwf MIDI_EVNT0
movlw 0x60
movwf MIDI_EVNT1
movlw 0x7f
movwf MIDI_EVNT_VALUE
goto MIDI_EVNT_Send
return
SCRATCH_UP
movlw 0xb0
movwf MIDI_EVNT0
movlw 0x02
movwf MIDI_EVNT1
movlw 0x7f
movwf MIDI_EVNT_VALUE
goto MIDI_EVNT_Send
SCRATCH_DOWN
movlw 0xb0
movwf MIDI_EVNT0
movlw 0x02
movwf MIDI_EVNT1
movlw 0x01
movwf MIDI_EVNT_VALUE
goto MIDI_EVNT_Send
ENC_PITCH_BEND
movlw 0x60
movwf PITCH_BEND_TIMER ;; Set the timer again
movf MIOS_PARAMETER2,W ;; Check if negative
bn ENC_PITCH_BEND_DOWN
goto ENC_PITCH_BEND_UP
ENC_PITCH_BEND_UP
movlw 0x90
movwf MIDI_EVNT0
movlw 0x61
movwf MIDI_EVNT1
movlw 0x00 ;could be removed
movwf MIDI_EVNT_VALUE ;could be removed
call MIDI_EVNT_Send ;could be removed
movlw 0x40
movwf MIDI_EVNT_VALUE
goto MIDI_EVNT_Send
ENC_PITCH_BEND_DOWN
movlw 0x90
movwf MIDI_EVNT0
movlw 0x62
movwf MIDI_EVNT1
movlw 0x00 ;could be removed
movwf MIDI_EVNT_VALUE ;could be removed
call MIDI_EVNT_Send ;could be removed
movlw 0x40
movwf MIDI_EVNT_VALUE
goto MIDI_EVNT_Send
and these are my timers
USER_SR_Service_Prepare
;; Added a timer of pitchbend function
movf PITCH_BEND_TIMER,W
skpz
call PITCH_BEND_TIMER_Do
;; Added a timer of pitchbend function
movf PITCH_BEND_TIMER2,W
skpz
call PITCH_BEND_TIMER2_Do
;; Added a timer of scratch function
movf SCRATCH_TIMER,W
skpz
call SCRATCH_TIMER_Do
;;;;;;;;;;;;; standard mios code
;; call LEDrings handler
call MB64E_LEDRINGS_Handler
;; branch to the Rx/Tx LED handler
goto MIDI_RXTX_Handler
;;;;;;;;;;;;;;; end standard mios code
SCRATCH_TIMER_Do
movlw 0x01
cpfsgt SCRATCH_TIMER
goto SCRATCH_TIMER_Boom
decf SCRATCH_TIMER
return
SCRATCH_TIMER_Boom
movlw 0x00
movwf SCRATCH_TIMER ;; Timer to zero (off)
movlw 0x90
movwf MIDI_EVNT0
movlw 0x60
movwf MIDI_EVNT1
movlw 0x00 ;; a value of 64
movwf MIDI_EVNT_VALUE
goto MIDI_EVNT_Send
PITCH_BEND_TIMER_Do
movlw 0x01
cpfsgt PITCH_BEND_TIMER
goto PITCH_BEND_TIMER_Boom
decf PITCH_BEND_TIMER
return
PITCH_BEND_TIMER_Boom
movlw 0x00
movwf PITCH_BEND_TIMER ;; Timer to zero (off)
movlw 0x90
movwf MIDI_EVNT0
movlw 0x61
movwf MIDI_EVNT1
movlw 0x00 ;; a value of 96
movwf MIDI_EVNT_VALUE
call MIDI_EVNT_Send
movlw 0x90
movwf MIDI_EVNT0
movlw 0x62
movwf MIDI_EVNT1
movlw 0x00 ;; a value of 64
movwf MIDI_EVNT_VALUE
call MIDI_EVNT_Send
return
It’s still a bit messy… but I am still working on it.
This is what Luis suggested me first, doesn’t work for me, but please try so we can find out why :D:
ENC_PITCH_BEND
movlw 0xff
movwf PITCH_BEND_TIMER ;; Set the timer again
movf MIOS_PARAMETER2,W ;; Check if negative
bn ENC_PITCH_BEND_DOWN
goto ENC_PITCH_BEND_UP
ENC_PITCH_BEND_UP
movlw 0xb0
movwf MIDI_EVNT0
movf MIOS_PARAMETER1,W
movwf MIDI_EVNT1
movlw 0x60 ;; a value of 96
movwf MIDI_EVNT_VALUE
goto MIDI_EVNT_Send
ENC_PITCH_BEND_DOWN
movlw 0xb0
movwf MIDI_EVNT0
movf MIOS_PARAMETER1,W
movwf MIDI_EVNT1
movlw 0x20 ;; a value of 32
movwf MIDI_EVNT_VALUE
goto MIDI_EVNT_Send
And then the timer also changes a bit (different midi values)
SCRATCH_TIMER_Do
movlw 0x01
cpfsgt SCRATCH_TIMER
goto SCRATCH_TIMER_Boom
decf SCRATCH_TIMER
return
SCRATCH_TIMER_Boom
movlw 0x00
movwf SCRATCH_TIMER ;; Timer to zero (off)
movlw 0x90
movwf MIDI_EVNT0
movlw 0x60
movwf MIDI_EVNT1
movlw 0x00 ;; a value of 64
movwf MIDI_EVNT_VALUE
goto MIDI_EVNT_Send
I’m also nog happy about the pitchbend yet because: when you keep turning the encoder at the same (slow) speed the pitch bend keeps increasing, and that is not what I want. This is a problem of traktor because that is just what it does with the buttons. But I have already thought about a solution for this wich I will try soon and post it here too.
Hope this is usefull for anybody, to all the future traktor midibox builders: scratching an pitchbending is possible with an encoder!
Bye, Jeroen.