<commit_before>(ns overtone.app.main
  (:gen-class)
  (:import 
    (java.awt Toolkit EventQueue Dimension Point)
    (java.awt Dimension Color Font RenderingHints Point BasicStroke)
    (java.awt.geom Ellipse2D$Float RoundRectangle2D$Float)
    (javax.swing JFrame JPanel) 
    (com.sun.scenario.scenegraph JSGPanel SGText SGShape SGGroup SGAbstractShape$Mode SGComponent
                                 SGTransform)
    (com.sun.scenario.scenegraph.event SGMouseAdapter)
    (com.sun.scenario.scenegraph.fx FXShape)
    (scenariogui.synth ISynth ISynthParam SynthControl))
  (:use (overtone.app editor)
        (overtone.core sc ugen synth envelope event)
        (overtone.gui scope)
        clojure.stacktrace)
  (:require [overtone.core.log :as log]))

(alias 'ug 'overtone.ugens)

(def APP-NAME "Overtone")

(def HEADER-HEIGHT 20)
(def WINDOW-FILL   (Color. 50 50 50))
(def WINDOW-STROKE (Color. 50 50 50))
(def LOGO-SIZE 20)
(def HEADER-FONT (Font. "SansSerif" Font/BOLD 16))

(defn header-status []
  (let [status-txt (SGText.)]
    (add-watch status* :header 
               (fn [skey sref old-status new-status]
                 (.setText status-txt (name new-status))))
    (doto status-txt
      (.setText (str "DSP: " (name @status*)))
      (.setFont HEADER-FONT)
      (.setAntialiasingHint RenderingHints/VALUE_TEXT_ANTIALIAS_ON)
      (.setFillPaint Color/WHITE)
      (.setLocation (Point. 550 17)))))

(defn booter []
  (let [boot-txt (SGText.)]
    (doto boot-txt
      (.setText "boot")
      (.setFont HEADER-FONT)
      (.setAntialiasingHint RenderingHints/VALUE_TEXT_ANTIALIAS_ON)
      (.setFillPaint Color/WHITE)
      (.setLocation (Point. 500 17))
      (.addMouseListener
        (proxy [SGMouseAdapter] []
          (mouseClicked [event node] 
            (if (connected?)
              (do (quit)
                (.setText boot-txt "boot"))
              (do (boot)
                (.setText boot-txt "quit")))))))))

(defn logo []
  (doto (SGText.)
      (.setText APP-NAME)
      (.setFont (Font. "SansSerif" Font/BOLD LOGO-SIZE))
      (.setAntialiasingHint RenderingHints/VALUE_TEXT_ANTIALIAS_ON)
      (.setFillPaint Color/WHITE)
      (.setLocation (Point. 10 18))))

(defn header []
  (let [browse-root (SGGroup.)
        base-box (FXShape.)
        width 1000]

    (doto base-box
      (.setShape (RoundRectangle2D$Float. 0 0 width HEADER-HEIGHT 4 4))
      (.setMode SGAbstractShape$Mode/STROKE_FILL)
      (.setAntialiasingHint RenderingHints/VALUE_ANTIALIAS_ON)
      (.setFillPaint WINDOW-FILL)
      (.setDrawPaint WINDOW-STROKE)
      (.setDrawStroke (BasicStroke. 1.15)))

    (doto browse-root
      (.add base-box)
      (.add (logo))
      (.add (booter))
      (.add (header-status)))))

(defn make-synth-param [[name start end step]]
  (proxy [ISynthParam] []
    (getName [] name)
    (getStart [] start)
    (getEnd [] end)
    (getStep [] step)))

(defn make-synth []
  (let [s-fn (synth [freq 400 dur 0.2] (ug/* (ug/env-gen (perc 0.1 dur)) (ug/sin-osc freq)))]
    (proxy [ISynth] []
      (getParams [] (into-array (map make-synth-param [["freq" 0.0 1200.0 1.0] ["dur" 0.01 10.0 0.1]])))
      (getName [] (:name (meta s-fn))) 
      (play [vals] (do (println "playing vals: " vals) (apply s-fn vals)))
      (kill [] ())
      (control [param value] (s-fn :ctl param value)))))

(def scene-root* (ref nil))

(defn synth-control []
  (.add @scene-root* (SynthControl. (make-synth))))

(defn overtone-scene [args]
  (let [root (SGGroup.)]
    (doto root
      (.add (header)))
      ;(.add (editor))
      ;(.add (scope)))
      (dosync (ref-set scene-root* root))
    root))

(defn screen-dim []
  (.getScreenSize (Toolkit/getDefaultToolkit)))

(defn screen-size []
  (let [dim (screen-dim)]
    [(.width dim) (.height dim)]))

;TODO: It undecorates, but it doesn't seem to change the size of the frame...
(defn fullscreen-frame [f]
    (.setExtendedState f JFrame/MAXIMIZED_BOTH)
    (.setUndecorated f true))

(defn -main [& args]
  (let [app-frame (JFrame.  "Project Overtone")
        main-panel (JSGPanel.)]
    (.add (.getContentPane app-frame) main-panel)

    (when (not (connected?))
      (boot)
      (Thread/sleep 1000))
<commit_msg>cleaning out jons synth stuff until it works<commit_after>(ns overtone.app.main
  (:gen-class)
  (:import 
    (java.awt Toolkit EventQueue Dimension Point)
    (java.awt Dimension Color Font RenderingHints Point BasicStroke)
    (java.awt.geom Ellipse2D$Float RoundRectangle2D$Float)
    (javax.swing JFrame JPanel) 
    (com.sun.scenario.scenegraph JSGPanel SGText SGShape SGGroup SGAbstractShape$Mode SGComponent
                                 SGTransform)
    (com.sun.scenario.scenegraph.event SGMouseAdapter)
    (com.sun.scenario.scenegraph.fx FXShape))
  (:use (overtone.app editor)
        (overtone.core sc ugen synth envelope event)
        (overtone.gui scope)
        clojure.stacktrace)
  (:require [overtone.core.log :as log]))

(alias 'ug 'overtone.ugens)

(def APP-NAME "Overtone")

(def HEADER-HEIGHT 20)
(def WINDOW-FILL   (Color. 50 50 50))
(def WINDOW-STROKE (Color. 50 50 50))
(def LOGO-SIZE 20)
(def HEADER-FONT (Font. "SansSerif" Font/BOLD 16))

(defn header-status []
  (let [status-txt (SGText.)]
    (add-watch status* :header 
               (fn [skey sref old-status new-status]
                 (.setText status-txt (name new-status))))
    (doto status-txt
      (.setText (str "DSP: " (name @status*)))
      (.setFont HEADER-FONT)
      (.setAntialiasingHint RenderingHints/VALUE_TEXT_ANTIALIAS_ON)
      (.setFillPaint Color/WHITE)
      (.setLocation (Point. 550 17)))))

(defn booter []
  (let [boot-txt (SGText.)]
    (doto boot-txt
      (.setText "boot")
      (.setFont HEADER-FONT)
      (.setAntialiasingHint RenderingHints/VALUE_TEXT_ANTIALIAS_ON)
      (.setFillPaint Color/WHITE)
      (.setLocation (Point. 500 17))
      (.addMouseListener
        (proxy [SGMouseAdapter] []
          (mouseClicked [event node] 
            (if (connected?)
              (do (quit)
                (.setText boot-txt "boot"))
              (do (boot)
                (.setText boot-txt "quit")))))))))

(defn logo []
  (doto (SGText.)
      (.setText APP-NAME)
      (.setFont (Font. "SansSerif" Font/BOLD LOGO-SIZE))
      (.setAntialiasingHint RenderingHints/VALUE_TEXT_ANTIALIAS_ON)
      (.setFillPaint Color/WHITE)
      (.setLocation (Point. 10 18))))

(defn header []
  (let [browse-root (SGGroup.)
        base-box (FXShape.)
        width 1000]

    (doto base-box
      (.setShape (RoundRectangle2D$Float. 0 0 width HEADER-HEIGHT 4 4))
      (.setMode SGAbstractShape$Mode/STROKE_FILL)
      (.setAntialiasingHint RenderingHints/VALUE_ANTIALIAS_ON)
      (.setFillPaint WINDOW-FILL)
      (.setDrawPaint WINDOW-STROKE)
      (.setDrawStroke (BasicStroke. 1.15)))

    (doto browse-root
      (.add base-box)
      (.add (logo))
      (.add (booter))
      (.add (header-status)))))

(def scene-root* (ref nil))

(defn overtone-scene [args]
  (let [root (SGGroup.)]
    (doto root
      (.add (header)))
      ;(.add (editor))
      ;(.add (scope)))
      (dosync (ref-set scene-root* root))
    root))

(defn screen-dim []
  (.getScreenSize (Toolkit/getDefaultToolkit)))

(defn screen-size []
  (let [dim (screen-dim)]
    [(.width dim) (.height dim)]))

;TODO: It undecorates, but it doesn't seem to change the size of the frame...
(defn fullscreen-frame [f]
    (.setExtendedState f JFrame/MAXIMIZED_BOTH)
    (.setUndecorated f true))

(defn -main [& args]
  (let [app-frame (JFrame.  "Project Overtone")
        main-panel (JSGPanel.)]
    (.add (.getContentPane app-frame) main-panel)

    (when (not (connected?))
      (boot)
      (Thread/sleep 1000))

{'fraction_non_alphanumeric': 0.14649020371091215, 'fraction_numerical': 0.016089269495264045, 'mean_word_length': 2.6530805687203793, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5799807', 'n_tokens_mistral': 3004, 'n_tokens_neox': 2714, 'n_words': 663}