Jump to content

Pitchbending and scratching in Traktor with encoder


n0ne
 Share

Recommended Posts

Hya Guys,

On the NI forum I found out that a guy by the nick of 'jamesh' had the same problem as me: the pitchbend in traktor wouldn't work with an encoder, and his question isn't really answered on the forum yet, so I started to look for a solution too. I've posted a link on the NI forum to this topic too, so that jamesh might share what workarounds he has found so far.

I've mailed with Luis, the maker of the kontrol-dj (www.kontrol-dj.com), who has already made a working solution for this problem, so ofcourse I was really interested. And being the kind guy he is he told me how he did it, so mabye we can use this to make something work in MIOS.

This is what he mailed me:

Probably the only important difference is that the KDj sends a midi

message when the encoder start to move and another one when it stop

moving.

  Generally the KDj sends:

- A midi NOTE ON message when the movement of the jog is started.

- A midi CONTROL CHANGE message with VALUE 127 when the jog is turned

right.

- A midi CONTROL CHANGE message with VALUE 1 when the jog is turned

left.

- A midi NOTE OFF message when the movement of the jog is stopped.

  For example for the scratch function:

-  NN 50 with VALUE 127 when the movement of the jog is started.

-  CC 40 with VALUE 127 when the jog is turned right.

-  CC 40 with VALUE 1 when the jog is turned left.

-  NN 50 with VALUE 0 when the movement of the jog is stopped.

  And for pitch bend you can use this:

- Send nothing when the movement of the jog is started.

- CC 48 with VALUE 96 when the jog is turned right.

- CC 48 with VALUE 32 when the jog is turned left.

- CC 48 with VALUE 64 when the movement of the jog is stopped.

Here is also described how he uses it to scratch, I got traktor to scratch with an encoder a bit, but it didn't really work properly, so maybe we could look at this too, for me, personaly, this has no priority at all.

I myself have done lots of different programlanguages, but no pic assembler yet, I'm now learning it and have already made two shift buttons wich I found in some topic 8) ;), so I'll get there.

So in this topic I'm asking if there might already be something similar to this? And maybe the traktor enthausiasts are willing to help me in making such a function.

Thanks a lot in advance for any help, and I know it gets said a lot, but never enough, what a great project this is!!!! thanks!,

Jeroen.

Link to comment
Share on other sites

Ow and by the way... my idea for a pitchbend would be something like:

When encoder is toutched, send

- CC 48 with VALUE 96 when the jog is turned right.

- CC 48 with VALUE 32 when the jog is turned left.

and then start a timer of x ms. When x get's zero send CC 48 with VALUE 64.

And everything the encoder is touched again the timer get's reset to x, this would probably be a solution right? Only I have no clue at the moment how to implement this  :-X.

Jeroen.

Link to comment
Share on other sites

Hi Jeroen,

the easiest way is to program this directly into the USER_ENC_NotifyChange hook. Check for the encoder number (it's in MIOS_PARAMETER1), if it matches with the encoder you are using for pitchbend, don't branch to MB64E_ENC_Handler, but continue with your own routine.

For a "cheap" timer I would suggest the use of USER_SR_Service_Prepare or USER_SR_Service_Finish, these routines are called each mS. Here you could add a counter (free register address has to be found and defined in app_defines.h) which decrements a value until it reaches 1(!)

This gives you following possibilities:

  • in the USER_ENC_NotifyChange hook, check if the counter is <= 1. If this is the case, send the Note On event with velocity 0x7f
  • always set the counter to 255 (so that it reaches 1 after 255 mS) and send the CC events depending on the direction (-> MIOS_PARAMETER2, read the comments of the hook)
  • in USER_Tick (called when nothing else is to do), check if the counter has reached 1. If this is the case, set the counter to 0 and send the Note On event with velocity 0 (-> Note Off)

thats all! :)

Additional hint: just make the first tries with the MIOS C wrapper. This should shorten the time to success.

Once you've found a working code, you can translate it to assembler. I guess that it will result in ca. 30 additional assembly instructions.

Best Regards, Thorsten.

Link to comment
Share on other sites

Hi guys!

TK, thanks a lot for your input! Yesterday and today I invested a couple of hours in learning some extra assembler, and oh my g00d, I just went on and programmed it myself :D... pretty cool I think ;). Only problem is that traktor still doens't work correct, so I've mailed Luis from kdj again, and am awaiting his answer.

I'll be sure to post my code when it works, so other people can use this function too, i guess it's something traktor users really need.

A bit off topic but: in midiox I notice that my non detented encoder (ALPS EC11E1830401) only sends its original 36 pulses, in the mios specification says something about make the resolution higher with the software. Why isn't this working? am I missing something? Hope someone has an answer since I didn't find it in the forum.

Thanks again TK!,

Jeroen.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 5 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...