<commit_before>(ns clum.app.audio
  (:require [cljs-bach.synthesis :as syn]))

(defonce context (syn/audio-context))

(def frequency-dispatch
  {0 440
   1 220
   2 440
   3 220
   4 440 
   5 220
   6 440
   7 880})

(defn ->frequency
  [y x]
  (let [freq (get frequency-dispatch x)]
    freq))

(def volume-dispatch
  {0 0.05
   1 0.1
   2 0.15
   3 0.2
   4 0.25
   5 0.3
   6 0.4
   7 0.5})

(defn ->volume
  [y x]
  (let [volume (get volume-dispatch y)]
    (println "volume" volume)
    y))

(defn play-synth
  [synth x y]
  (let [frequency     (->frequency y x)
        volume        (->volume y x)
        created-synth (syn/connect->
                       (synth frequency)
                       (syn/adsr 0.3 0.2 0.01 0.005)
                       ;;(syn/low-pass 1000)
                       (syn/gain volume))]
    (-> created-synth
        (syn/connect-> syn/destination)
        (syn/run-with context (syn/current-time context) 1.0))))

(def synth-dispatch
  {0 syn/sine
   1 syn/triangle
   2 syn/square<commit_msg>Make volume dispatch table result in something better sounding.<commit_after>(ns clum.app.audio
  (:require [cljs-bach.synthesis :as syn]))

(defonce context (syn/audio-context))

(def frequency-dispatch
  {0 440
   1 220
   2 440
   3 220
   4 440 
   5 220
   6 440
   7 880})

(defn ->frequency
  [y x]
  (let [freq (get frequency-dispatch x)]
    freq))

(def volume-dispatch
  {0 0.5
   1 0.45
   2 0.4
   3 0.5
   4 0.4
   5 0.3
   6 0.5
   7 0.25})

(defn ->volume
  [y x]
  (let [volume (get volume-dispatch y)]
    (println "volume" volume)
    y))

(defn play-synth
  [synth x y]
  (let [frequency     (->frequency y x)
        volume        (->volume y x)
        created-synth (syn/connect->
                       (synth frequency)
                       (syn/adsr 0.3 0.2 0.01 0.005)
                       ;;(syn/low-pass 1000)
                       (syn/gain volume))]
    (-> created-synth
        (syn/connect-> syn/destination)
        (syn/run-with context (syn/current-time context) 1.0))))

(def synth-dispatch
  {0 syn/sine
   1 syn/triangle
   2 syn/square
{'fraction_non_alphanumeric': 0.12920018930430668, 'fraction_numerical': 0.0743019403691434, 'mean_word_length': 1.7033248081841432, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '479841', 'n_tokens_mistral': 877, 'n_tokens_neox': 762, 'n_words': 229}