<commit_before>(ns afterglow.dj-link
  "Provides synchronization with equipment sending Pioneer Pro DJ Link
  packets on the local network, such as Pioneer Nexus mixers and players.
  This is purely experimental and based on network traffic capture, but
  unless they change the protocol, it works really well, providing rock
  solid BPM, beat, and measure-phase tracking."
  (:require [afterglow.midi :refer [IClockSync sync-start sync-stop sync-status]]
            [afterglow.rhythm :as rhythm]
            [afterglow.util :refer [unsign]]
            [overtone.at-at :refer [now]]
            [taoensso.timbre :as timbre])
  (:import [java.net InetAddress DatagramPacket DatagramSocket]
           [java.util.regex Pattern]))

(def port
  "The UDP port on which BPM and beat packets are broadcast."
  50001)

(defonce ^{:private true
           :doc "Holds the persistent server socket, map of seen sync
  sources (keyed on the address from which they transmit), set of
  active synced metronomes, and the future that processes packets."}
  state (atom {:socket nil
               :watcher nil
               :sources-seen {}
               :synced-metronomes #{}}))

(defn shut-down
  "Close the UDP server socket and terminate the packet processing
  thread, if they are active."
  []
  (swap! state (fn [current]
                 (-> current
                     (update-in [:socket] #(when %
                                             (try (.close %)<commit_msg>Change order to match doc string.<commit_after>(ns afterglow.dj-link
  "Provides synchronization with equipment sending Pioneer Pro DJ Link
  packets on the local network, such as Pioneer Nexus mixers and players.
  This is purely experimental and based on network traffic capture, but
  unless they change the protocol, it works really well, providing rock
  solid BPM, beat, and measure-phase tracking."
  (:require [afterglow.midi :refer [IClockSync sync-start sync-stop sync-status]]
            [afterglow.rhythm :as rhythm]
            [afterglow.util :refer [unsign]]
            [overtone.at-at :refer [now]]
            [taoensso.timbre :as timbre])
  (:import [java.net InetAddress DatagramPacket DatagramSocket]
           [java.util.regex Pattern]))

(def port
  "The UDP port on which BPM and beat packets are broadcast."
  50001)

(defonce ^{:private true
           :doc "Holds the persistent server socket, map of seen sync
  sources (keyed on the address from which they transmit), set of
  active synced metronomes, and the future that processes packets."}
  state (atom {:socket nil
               :sources-seen {}
               :synced-metronomes #{}
               :watcher nil}))

(defn shut-down
  "Close the UDP server socket and terminate the packet processing
  thread, if they are active."
  []
  (swap! state (fn [current]
                 (-> current
                     (update-in [:socket] #(when %
                                             (try (.close %)
{'fraction_non_alphanumeric': 0.08468286099865047, 'fraction_numerical': 0.0033738191632928477, 'mean_word_length': 2.4759671746776086, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2941752', 'n_tokens_mistral': 820, 'n_tokens_neox': 789, 'n_words': 323}