Page 1 of 2

MIDI to Pioneer DDJ

Posted: Sat Dec 19, 2020 5:19 pm
by Then
Hi,

I have a Pioneer DDJ-200 MIDI-Controller and it is connected to my PC with USB.

I receive the numbers of the Buttons when I press them, but how can I switch on the LEDs on the PADs ?

NoteOn(...) does not work :cry:


(Sorry for my english... :| )

Re: MIDI to Pioneer DDJ

Posted: Sat Dec 19, 2020 5:26 pm
by NicTheQuick
if you post this is in the English forum nobody knows what code you are using. It would be better to link to the original thread if you really are looking for someone to help you.

This is the original thread: https://www.purebasic.fr/german/viewtop ... =3&t=32171

So you have the same controller as Stuhli? You didn't mention that in the thread.

Re: MIDI to Pioneer DDJ

Posted: Sat Dec 19, 2020 5:32 pm
by Then
Yes, its the same Controller, but i bought it :lol:

I try it here, because it´s bigger here and more traffic... i hope someone can help me.

It must be possible.... :shock:

Re: MIDI to Pioneer DDJ

Posted: Sat Dec 19, 2020 6:16 pm
by NicTheQuick
As I have already mentioned there is also a forum from Pioneer with quite a big user base and a sub forum for DDJ: https://forums.pioneerdj.com/hc/de/comm ... 307759-DDJ
I think the best idea would be to ask them about the correct MIDI signals to make your buttons light up.

Re: MIDI to Pioneer DDJ

Posted: Sat Dec 19, 2020 6:30 pm
by Then
... yes, but they don´t use purebasic. :? please, if you dont have a working example, let the other answer...

to say allways the same doesn´t help me...

Re: MIDI to Pioneer DDJ

Posted: Sat Dec 19, 2020 6:33 pm
by NicTheQuick
MIDI is MIDI. This has nothing to do with Purebasic. If you know what to send to the device the given procedures like "NoteOn" should totally work.

The main issue here is that you do not know what to send to the DDJ.

Re: MIDI to Pioneer DDJ

Posted: Sat Dec 19, 2020 9:20 pm
by infratec
As I can read in the DDJ 200 PDF:

Illumination control:
MIDI channel 16 note xx and data 0 or 1

My interpretation:
0 or 1 is on off

Btw.:
9F 00 7F
9F 01 7F

Maybe you can only switch it on/off for all keys.

Re: MIDI to Pioneer DDJ

Posted: Sun Dec 20, 2020 11:49 am
by Then
Thanks !

But, when i write

Code: Select all

NoteOn(9F,01,7F)
There is an error, because "Its not a valid Decimal number !") :cry:

Code: Select all

Procedure NoteOn(channel.b, Note.b, Velocity.b) 
  Shared HandleOut 
  Protected NoteDat.MIDIData 
  NoteDat\channel = $90 + channel 
  NoteDat\Note = Note 
  NoteDat\Velocity = Velocity 
  NoteDat\Null = #Null 
  If midiOutShortMsg_(HandleOut, PeekL(NoteDat)) = #MMSYSERR_NOERROR : Debug "Ton gestartet..." : EndIf 
EndProcedure 




Re: MIDI to Pioneer DDJ

Posted: Sun Dec 20, 2020 12:15 pm
by NicTheQuick
If you want to use hexadecimal values you have to write them accordingly:

Code: Select all

NoteOn($9F,$01,$7F)
But that's not all. The value $9f is wrong. It should be just $0f because the $90 is added within NoteOn automatically:

Code: Select all

NoteOn($0f, $01, $7f)
Or you can also use decimal values for that:

Code: Select all

NoteOn(15, 1, 127)

Re: MIDI to Pioneer DDJ

Posted: Sun Dec 20, 2020 12:33 pm
by Then
Thanks ! I forgot the "$" :oops:

I tried it, but no led turns on.

So, i tried the dezimal values with FOR-NEXT to see, if something happens - but there is nothing :|

Code: Select all

For a=0 To 16
 For t=0 To 128
  For x=0 To 128
   NoteOn(a, t, x)
   Debug a
   Debug t
   Debug x
   Debug "-----"
   Delay(100)
  Next
 Next
Next
I give up :cry:

Re: MIDI to Pioneer DDJ

Posted: Mon Dec 21, 2020 6:27 pm
by infratec
If you have a program which makes them light up, you can spy out what is sended to the device.

Re: MIDI to Pioneer DDJ

Posted: Tue Dec 22, 2020 9:36 am
by Joris
Then wrote:...
So, i tried the dezimal values with FOR-NEXT to see, if something happens - but there is nothing :|
You're loops are going out of range, they should be like :

Code: Select all

For a=0 To 15                 ;midi channel ranges from 0 to 15 !  
 For t=0 To 127              :these values are maximum 127
  For x=0 To 127
...

Re: MIDI to Pioneer DDJ

Posted: Tue Dec 22, 2020 10:28 am
by oreopa
I think we're all assuming you have opened the device correctly in the first place? Have you? (Just checking...)

Re: MIDI to Pioneer DDJ

Posted: Wed Dec 23, 2020 2:22 pm
by Then
Yes I did. I receive the numbers of the pads, when i press them.

Here is the full code :

Code: Select all

Global Dim Controller.s(127) 

Procedure MIDIRequester(*OutDevice, *InDevice) 
  #MOD_WAVETABLE = 6 
  #MOD_SWSYNTH = 7 
  #MIDIRequ_InSet = 2 
  #MIDIRequ_OutSet = 1 

  #Width = 400 
  If OpenWindow(0, 0, 0, #Width, 270,"MIDI-Requester", #PB_Window_SystemMenu | #PB_Window_ScreenCentered ) 
    If CreateGadgetList(WindowID(0)) 
      #Column = (#Width - 20) / 2 
      #Offset = (#Width / 2) + 5 

      TextGadget(0, 5, 5, #Column, 18, "Output-Device:", #PB_Text_Center | #PB_Text_Border) 
      ListViewGadget(2, 5, 23, #Column, 100) 
        MaxOutDev.l = midiOutGetNumDevs_() 
        InfoOut.MIDIOUTCAPS 
        If MaxOutDev 
          For a.l = -1 To MaxOutDev - 1 
            midiOutGetDevCaps_(a, InfoOut, SizeOf(MIDIOUTCAPS)) 
            AddGadgetItem(2, -1, PeekS(@InfoOut\szPname[0], 32)) 
          Next 
        Else 
          AddGadgetItem(2, -1, "(no output device)") 
          DisableGadget(2, 1) 
        EndIf 

      TextGadget(1, #Offset, 5, #Column, 18, "Input-Device:", #PB_Text_Center | #PB_Text_Border) 
      ListViewGadget(3, #Offset, 23, #Column, 100) 
        MaxInDev.l = midiInGetNumDevs_() 
        InfoIn.MIDIINCAPS 
        If MaxInDev 
          For a.l = 0 To MaxInDev - 1 
            midiInGetDevCaps_(a, InfoIn, SizeOf(MIDIINCAPS)) 
            AddGadgetItem(3, -1, PeekS(@InfoIn\szPname[0], 32)) 
          Next 
        Else 
          AddGadgetItem(3, -1, "(no input device)") 
          DisableGadget(3, 1) 
        EndIf 

      ButtonGadget(4, 5, 240, #Column, 24, "&OK") 
      ButtonGadget(5, #Offset, 240, #Column, 24, "&Cancel") 
      
      Frame3DGadget(6, 5, 130, #Width - 10, 100, "Info of Output-Device", 0) 
       TextGadget(7, 10, 145, #Width - 20, 18, "Version:") 
       TextGadget(8, 10, 165, #Width - 20, 18, "Technology:") 
       TextGadget(9, 10, 185, #Width - 20, 18, "Max. Voices:") 
       TextGadget(10, 10, 205, #Width - 20, 18, "Polyphonie:") 
      
      OutDev.l = 0 
      InDev.l = 0 
      Quit.l = #False 
      OK.l = #False 
      Repeat 
        If GetGadgetState(2) > -1 Or GetGadgetState(3) > -1 
          DisableGadget(4, 0) 
        Else 
          DisableGadget(4, 1) 
        EndIf 
        
        If InDev.l <> GetGadgetState(3) 
          InDev.l = GetGadgetState(3) 
        EndIf 

        If GetGadgetState(2) <> OutDev 
          OutDev.l = GetGadgetState(2) 
          midiOutGetDevCaps_(OutDev - 1, InfoOut, SizeOf(MIDIOUTCAPS)) 
          SetGadgetText(7, "Version: " + Str(InfoOut\vDriverVersion >> 8) + "." + Str(InfoOut\vDriverVersion & FF)) 
          Select InfoOut\wTechnology 
            Case #MOD_MIDIPORT :  TmpS.s = "Hardware Port" 
            Case #MOD_SYNTH :     TmpS.s = "Synthesizer" 
            Case #MOD_SQSYNTH :   TmpS.s = "Square Wave Synthesizer" 
            Case #MOD_FMSYNTH :   TmpS.s = "FM Synthesizer" 
            Case #MOD_MAPPER :    TmpS.s = "Microsoft MIDI Mapper" 
            Case #MOD_WAVETABLE : TmpS.s = "Hardware Wavetable Synthesizer" 
            Case #MOD_SWSYNTH :   TmpS.s = "Software Synthesizer" 
            Default: TmpS.s = "(Error Code " + Str(InfoOut\wTechnology) + ")" 
          EndSelect 
          SetGadgetText(8, "Technology: " + TmpS) 
          If InfoOut\wVoices = 0 : TmpS.s = "inf" : Else : TmpS.s = Str(InfoOut\wVoices) : EndIf 
          SetGadgetText(9, "Max. Voices: " + TmpS) 
          If InfoOut\wNotes = 0 : TmpS.s = "inf" : Else : TmpS.s = Str(InfoOut\wNotes) : EndIf 
          SetGadgetText(10, "Polyphonie: " + TmpS) 
        EndIf 
        
        EventID.l = WaitWindowEvent() 
        Select EventID 
          Case #PB_Event_CloseWindow 
            Quit = #True 
            OK = #False 
          Case #PB_Event_Gadget 
            Select EventGadget() 
              Case 4 
                PokeL(*OutDevice, OutDev - 1) 
                PokeL(*InDevice, InDev) 
                Quit = #True 
                OK = 3 
                If (OutDev = -1 Or CountGadgetItems(2) = 0) And OK & #MIDIRequ_OutSet : OK ! #MIDIRequ_OutSet : EndIf 
                If (InDev = -1 Or CountGadgetItems(3) = 0) And OK & #MIDIRequ_InSet : OK ! #MIDIRequ_InSet : EndIf 
              Case 5 
                Quit = #True 
                OK = #False 
            EndSelect 
        EndSelect 
      Until Quit 
      CloseWindow(0) 
      ProcedureReturn OK 
    Else 
      End 
    EndIf 
  Else 
    End 
  EndIf 
EndProcedure 

Structure MIDIData 
  channel.b 
  Note.b 
  Velocity.b 
  Null.b 
EndStructure 

Procedure NoteOn(channel.b, Note.b, Velocity.b) 
  Shared HandleOut 
  Protected NoteDat.MIDIData 
  NoteDat\channel = $90 + channel 
  NoteDat\Note = Note 
  NoteDat\Velocity = Velocity 
  NoteDat\Null = #Null 
  If midiOutShortMsg_(HandleOut, PeekL(NoteDat)) = #MMSYSERR_NOERROR : Debug "started..." : EndIf 
EndProcedure 
Procedure NoteOff(channel.b, Note.b, Velocity.b) 
  Shared HandleOut 
  Protected NoteDat.MIDIData 
  NoteDat\channel = $80 + channel 
  NoteDat\Note = Note 
  NoteDat\Velocity = Velocity 
  NoteDat\Null = #Null 
  midiOutShortMsg_(HandleOut, PeekL(NoteDat)) 
EndProcedure 
Procedure NoteOffAlternate(channel.b, Note.b, Velocity.b) 
  Shared HandleOut 
  Protected NoteDat.MIDIData 
  NoteDat\channel = $90 + channel 
  NoteDat\Note = Note 
  NoteDat\Velocity = 0 
  NoteDat\Null = #Null 
  midiOutShortMsg_(HandleOut, PeekL(NoteDat)) 
EndProcedure 
Procedure PitchWheel(channel.b, Value.w) 
  Shared HandleOut 
  Protected NoteDat.MIDIData 
  NoteDat\channel = $E0 + channel 
  NoteDat\Null = #Null 
  PokeW(@NoteDat\Note, Value) 
  midiOutShortMsg_(HandleOut, PeekL(NoteDat)) 
EndProcedure 
Procedure InitController() 
  Protected a.l 
  Restore ControllerNames 
  For a = 0 To 127 
    Read.s Controller(a) 
  Next 
EndProcedure 
Procedure.s GetControllerName(Number.l) 
  If Number >= 0 And Number <= 127 
    ProcedureReturn RSet(Str(Number), 3, "0") + " " + Controller(Number) 
  EndIf 
EndProcedure 
Procedure MidiInProc(hMidiIn.l, wMsg.l, dwInstance.l, dwParam1.l, dwParam2.l) 
  Protected Status.l, OnOf.l, NoteNr.l, Velocity.l 
  Select wMsg 
   Case #MM_MIM_DATA 
    Status = dwParam1 & $FF 
    If Status < $F0 
    Debug "Status :"+Str(Status)
     Select Status / 16 
      Case $9  
       key1=(dwParam1 >> 8) & $FF
       Debug "$9"
       Debug key1
       Debug "---"
  
      Case $B 
       key2=(dwParam1 >> 16) & $FF
       Debug "$B"
       Debug key2 
       Debug "---"
      Case $C 
       key3=(dwParam1 >> 8 ) & $FF
       Debug "$C"
       Debug key3  
       Debug "---"
      Case $E 
       key4=(dwParam1 >> 16 ) & $FF 
       Debug "$E"
       Debug key4  
       Debug "---"
     EndSelect 
    EndIf
   EndSelect 
EndProcedure 

InitController() 

OutDevice.l;1
InDevice.l;0
MIDIResult.l = MIDIRequester(@OutDevice, @InDevice) ;3


If MIDIResult & #MIDIRequ_InSet 
  hMidiIn.l 
  If midiInOpen_(@hMidiIn, InDevice, @MidiInProc(), 0, #CALLBACK_FUNCTION) = #MMSYSERR_NOERROR 
    If midiInStart_(hMidiIn) = #MMSYSERR_NOERROR 
   
    EndIf 
  EndIf 
EndIf 
  
If MIDIResult & #MIDIRequ_OutSet 
  hMidiOut.l 
  If midiOutOpen_(@hMidiOut, OutDevice, 0, 0, 0) = 0 
  EndIf 
EndIf 

If hMidiIn And hMidiOut 
  If midiConnect_(hMidiIn, hMidiOut, 0) = 0 
  EndIf 
EndIf 

DataSection 
  ControllerNames: 
    Data.s "Bank Select", "Modulation", "Breath Controller", "", "4 (0x04) Foot Controller"                   ;0 - 4 
    Data.s "Portamento time", "Data Entry (MSB)", "Main Volume", "Balance", "", "Pan"                         ;5 - 10 
    Data.s "Expression Controller", "Effect Control 1", "Effect Control 2", "", ""                            ;11 - 15 
    Data.s "General-Purpose Controllers 1", "General-Purpose Controllers 2", "General-Purpose Controllers 3"  ;16 - 18 
    Data.s "General-Purpose Controllers 4", "", "", "", "", "", "", "", "", "", "", "", ""                    ;19 - 31 
    Data.s "LSB for Controller 0", "LSB for Controller 1", "LSB for Controller 2", "LSB for Controller 3"     ;32 - 35 
    Data.s "LSB for Controller 4", "LSB for Controller 5", "LSB for Controller 6", "LSB for Controller 7"     ;36 - 39 
    Data.s "LSB for Controller 8", "LSB for Controller 9", "LSB for Controller 10", "LSB for Controller 11"   ;40 - 43 
    Data.s "LSB for Controller 12", "LSB for Controller 13", "LSB for Controller 14", "LSB for Controller 15" ;44 - 47 
    Data.s "LSB for Controller 16", "LSB for Controller 17", "LSB for Controller 18", "LSB for Controller 19" ;48 - 51 
    Data.s "LSB for Controller 20", "LSB for Controller 21", "LSB for Controller 22", "LSB for Controller 23" ;52 - 55 
    Data.s "LSB for Controller 24", "LSB for Controller 25", "LSB for Controller 26", "LSB for Controller 27" ;56 - 59 
    Data.s "LSB for Controller 28", "LSB for Controller 29", "LSB for Controller 30", "LSB for Controller 31" ;60 - 63 
    Data.s "Damper pedal (sustain)", "Portamento", "Sostenuto", "Soft Pedal", "Legato Footswitch"             ;64 - 68 
    Data.s "Hold 2", "Sound Controller 1 (Default: Timber Variation)"                                         ;69 - 70 
    Data.s "Sound Controller 2 (Default: Timber/Harmonic Content)"                                            ;71 - 71 
    Data.s "Sound Controller 3 (Default: Release time)", "Sound Controller 4 (Default: Attack time)"          ;72 - 73 
    Data.s "Sound Controller 6", "Sound Controller 7", "Sound Controller 8", "Sound Controller 9"             ;74 - 77 
    Data.s "Sound Controller 10", "", "General-Purpose Controllers 5", "General-Purpose Controllers 6"        ;78 - 81 
    Data.s "General-Purpose Controllers 7", "General-Purpose Controllers 8", "Portamento Control"             ;82 - 84 
    Data.s "", "", "", "", "", "", "Effects 1 Depth (formerly External Effects Depth)"                        ;85 - 91 
    Data.s "Effects 2 Depth (formerly Tremolo Depth)", "Effects 3 Depth (formerly Chorus Depth)"              ;92 - 93 
    Data.s "Effects 4 Depth (formerly Celeste Detune)", "Effects 5 Depth (formerly Phaser Depth)"             ;94 - 95 
    Data.s "Data Increment", "Data Decrement", "Non-Registered Parameter Number (LSB)"                        ;96 - 98 
    Data.s "Non-Registered Parameter Number (MSB)", "Registered Parameter Number (LSB)"                       ;99 - 100 
    Data.s "Registered Parameter Number (MSB)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""    ;101 - 116 
    Data.s "", "", "", "", "Mode Messages", "Mode Messages", "Mode Messages", "Mode Messages"                 ;117 - 124 
    Data.s "Mode Messages", "Mode Messages", "Mode Messages"                                                  ;125 - 127 
EndDataSection


NoteOn(......



Re: MIDI to Pioneer DDJ

Posted: Wed Dec 23, 2020 2:44 pm
by infratec
You should use EnableExplicit :!:

Then you would found:

Code: Select all

Str(InfoOut\vDriverVersion & FF)
Which is a bug.

And that

Code: Select all

Shared HandleOut
results in a bug since HandleOut is not defined.

So where comes HandleOut from ???