flesniak / python-prodj-link

A python interface to Pioneer ProDJ Link
Apache License 2.0
134 stars 26 forks source link

midiclock.py not detecting beat packets #21

Open maaraneasi opened 4 years ago

maaraneasi commented 4 years ago

Hey!

I am trying to use midiclock.py with my pair of xdj 1000's but I found that the script is not detecting the tempo for some reason. If I use any of the monitor packages, these detect the master player and its current tempo just fine but not the midiclock.py. midiclock.py detects the players, it sends the initial bpm (I can see the connected midi device to receive the initial clock, but the tempo doesn't follow the actual tempo of the players.

patch@patchbox:~/python-prodj-link $ ./midiclock.py INFO: found port Midi Through at 14:0 INFO: found port pisound at 20:0 INFO: found port amidiauto at 128:0 INFO: found port jack_midi at 129:0 INFO: found port pisound-ctl at 130:0 INFO: found port RtMidiIn Client at 131:0 INFO: found port RtMidiOut Client at 132:0 INFO: found port MidiClock at 133:0 INFO: Using port MidiClock at 133:0 INFO: Midi BPM 168 delay 0.014880952s <-- the default tempo I set in teh script to confirm the midi out is working DEBUG: DataStore: 0x7647d600 initialized DEBUG: DataStore: 0x7647d750 initialized DEBUG: DataStore: 0x7647d810 initialized DEBUG: DataStore: 0x7647d8a0 initialized DEBUG: DataStore: 0x7647d930 initialized DEBUG: DataStore: 0x7647d9c0 initialized DEBUG: DataStore: 0x7647da50 initialized DEBUG: DataStore: 0x7647dae0 initialized DEBUG: DataStore: 0x7647db70 initialized INFO: Listening on 0.0.0.0:50000 for keepalive packets INFO: Listening on 0.0.0.0:50001 for beat packets INFO: Listening on 0.0.0.0:50002 for status packets DEBUG: DataProvider starting DEBUG: ProDj: starting main loop INFO: Starting virtual cdj with player number 5 INFO: Starting MIDI clock queue INFO: New Player 2: XDJ-1000, 169.254.86.38, 74:5e:1c:58:56:26 INFO: Guessed own interface eth0 ip 169.254.213.8 mask 255.255.0.0 mac b8:27:eb:b6:76:86 DEBUG: query link info to 169.254.86.38 struct {'extra': {'source_ip': '169.254.213.8'}, 'player_number': 5, 'model': 'Virtual CDJ', 'content': {'slot': 3, 'remote_player_number': 2}, 'type': 'link_query'} DEBUG: Media usb in player 2 changed DEBUG: DataProvider: enqueueing metadata request with params (2, EnumIntegerString.new(3, 'usb'), 47) DEBUG: DataProvider: enqueueing beatgrid request with params (2, EnumIntegerString.new(3, 'usb'), 47) DEBUG: DataProvider: trying request metadata (2, EnumIntegerString.new(3, 'usb'), 47) from store DEBUG: DataProvider: trying request metadata (2, EnumIntegerString.new(3, 'usb'), 47) from pdb DEBUG: PDBProvider: handling metadata request params (2, EnumIntegerString.new(3, 'usb'), 47) DEBUG: Media usb in player 2 changed DEBUG: NfsClient starting DEBUG: NfsClient: enqueueing download of "/PIONEER/rekordbox/export.pdb" from 169.254.86.38 DEBUG: NfsClient mount port of player 169.254.86.38: 48276 DEBUG: NfsClient nfs port of player 169.254.86.38: 2049 INFO: NfsClient: starting file download ip 169.254.86.38 port 2049 path /PIONEER/rekordbox/export.pdb DEBUG: NfsClient: looking up "PIONEER" DEBUG: NfsClient: looking up "rekordbox" DEBUG: NfsClient: looking up "export.pdb" INFO: NfsClient: download progress 4% (60000/1204224 Bytes) INFO: NfsClient: download progress 9% (120000/1204224 Bytes) INFO: NfsClient: download progress 14% (180000/1204224 Bytes) INFO: NfsClient: download progress 19% (240000/1204224 Bytes) INFO: NfsClient: download progress 24% (300000/1204224 Bytes) INFO: NfsClient: download progress 29% (360000/1204224 Bytes) INFO: NfsClient: download progress 34% (420000/1204224 Bytes) INFO: NfsClient: download progress 39% (480000/1204224 Bytes) INFO: NfsClient: download progress 44% (540000/1204224 Bytes) INFO: NfsClient: download progress 49% (600000/1204224 Bytes) INFO: NfsClient: download progress 54% (660000/1204224 Bytes) INFO: NfsClient: download progress 59% (720000/1204224 Bytes) INFO: NfsClient: download progress 64% (780000/1204224 Bytes) INFO: NfsClient: download progress 69% (840000/1204224 Bytes) INFO: NfsClient: download progress 74% (900000/1204224 Bytes) INFO: NfsClient: download progress 79% (960000/1204224 Bytes) INFO: NfsClient: download progress 84% (1020000/1204224 Bytes) INFO: NfsClient: download progress 89% (1080000/1204224 Bytes) INFO: New Player 1: XDJ-1000, 169.254.51.125, 74:5e:1c:5a:33:7d INFO: NfsClient: download progress 94% (1140000/1204224 Bytes) INFO: NfsClient: download progress 99% (1200000/1204224 Bytes) INFO: NfsClient: Download of /PIONEER/rekordbox/export.pdb complete (1204224 Bytes, 1.79 MiB/s) DEBUG: PDBDatabase: Loading file "databases/player-2-usb.pdb" DEBUG: DataProvider: enqueueing metadata request with params (2, EnumIntegerString.new(3, 'usb'), 1075) DEBUG: DataProvider: enqueueing beatgrid request with params (2, EnumIntegerString.new(3, 'usb'), 1075) INFO: New Player 5: Virtual CDJ, 169.254.213.8, b8:27:eb:b6:76:86 DEBUG: PDBDatabase: done collecting tracks DEBUG: PDBDatabase: done collecting artists DEBUG: PDBDatabase: done collecting albums DEBUG: PDBDatabase: done collecting playlists DEBUG: PDBDatabase: done collecting playlist_map DEBUG: PDBDatabase: done collecting artwork DEBUG: PDBDatabase: done collecting colors DEBUG: PDBDatabase: done collecting genres DEBUG: PDBDatabase: done collecting key_names DEBUG: PDBDatabase: done collecting labels DEBUG: PDBDatabase: Loaded 293 pages, 1241 tracks, 73 playlists DEBUG: DataProvider: trying request beatgrid (2, EnumIntegerString.new(3, 'usb'), 47) from store DEBUG: DataProvider: trying request beatgrid (2, EnumIntegerString.new(3, 'usb'), 47) from pdb DEBUG: PDBProvider: handling beatgrid request params (2, EnumIntegerString.new(3, 'usb'), 47) DEBUG: NfsClient: enqueueing download of "/PIONEER/USBANLZ/P03E/0002AEFE/ANLZ0000.DAT" from 169.254.86.38 (...)

Any idea or debugging steps for checking what is wrong?

Thanks for help!

flesniak commented 4 years ago

midiclock was still using a callback that was removed from the internal API a long time ago. Unfortunately I forgot to remove the function to set that callback, otherwise I would have noticed that earlier. Can you try commit 832db372d395315d0340f0e4d5c36cc9952a0f5c and see if it solves the issue for you? This is not yet on the master branch as I'm currently working on restructuring the whole project.

maaraneasi commented 4 years ago

Hey! Thanks for getting back to me and checkking the issue! The new commit works fine and sends the midi clock as expected. One issue I found is that pressing pause on the player crashes the script:

DEBUG: Media usb in player 2 changed INFO: New Player 5: Virtual CDJ, 169.254.213.8, b8:27:eb:b6:76:86 INFO: Midi BPM 171.31188583374023 delay 0.014593266s INFO: Midi BPM 170.96791076660156 delay 0.014622627s INFO: Midi BPM 171.05386352539062 delay 0.014615279s INFO: Midi BPM 171.56990814208984 delay 0.014571320s INFO: Midi BPM 172.0 delay 0.014534884s INFO: Midi BPM 172.94597244262695 delay 0.014455381s INFO: Midi BPM 173.71987533569336 delay 0.014390984s INFO: Midi BPM 173.8919448852539 delay 0.014376744s INFO: Midi BPM 173.80599212646484 delay 0.014383854s INFO: Midi BPM 173.6339225769043 delay 0.014398108s INFO: Midi BPM 173.28994750976562 delay 0.014426688s INFO: Midi BPM 172.94597244262695 delay 0.014455381s INFO: Midi BPM 172.7739028930664 delay 0.014469778s INFO: Midi BPM 172.68795013427734 delay 0.014476980s INFO: Midi BPM 172.34397506713867 delay 0.014505874s INFO: Midi BPM 172.17190551757812 delay 0.014520371s INFO: Midi BPM 172.0 delay 0.014534884s Exception in thread Thread-2: Traceback (most recent call last): File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner self.run() File "/home/patch/python-prodj-link/prodj/core/prodj.py", line 92, in run self.handle_status_packet(data, addr) File "/home/patch/python-prodj-link/prodj/core/prodj.py", line 134, in handle_status_packet self.cl.eatStatus(packet) File "/home/patch/python-prodj-link/prodj/core/clientlist.py", line 252, in eatStatus self.client_change_callback(c.player_number) File "./midiclock.py", line 33, in update_master c.setBpm(newbpm) File "/home/patch/python-prodj-link/prodj/midi/midiclock_alsaseq.py", line 93, in setBpm self.delay = 60/bpm/24 ZeroDivisionError: float division by zero

flesniak commented 4 years ago

Ah, division by zero. A classic. This should be fixed in 02b7dcc4fed9b78032b9a8083310537ebf45a2c3, among lots of other things. Can you try if the overhauled version works for you? Sorry for the delay.