Skip to content

Commit

Permalink
regex fix for sc version, linting and bumping
Browse files Browse the repository at this point in the history
  • Loading branch information
hlolli committed Jul 10, 2017
1 parent b26e46f commit 258dac9
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ target/
/.classpath
/bin
/.settings
.nrepl-port
8 changes: 4 additions & 4 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
(vec (set (concat (get JVMOPTS :any)
(get JVMOPTS os))))))

(defproject overtone "0.10.1"
(defproject overtone "0.10.2"
:description "Collaborative Programmable Music."
:url "http://overtone.github.io/"
:mailing-list {:name "overtone"
Expand All @@ -50,9 +50,9 @@
:distribution :repo
:comments "Please use Overtone for good"}

:dependencies [[org.clojure/clojure "1.5.1"]
[org.clojure/data.json "0.2.3"]
[clj-native "0.9.3"]
:dependencies [[org.clojure/clojure "1.9.0-alpha17"]
[org.clojure/data.json "0.2.6"]
[clj-native "0.9.5"]
[overtone/at-at "1.2.0"]
[overtone/osc-clj "0.9.0"]
[overtone/byte-spec "0.3.1"]
Expand Down
1 change: 1 addition & 0 deletions src/overtone/api.clj
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,4 @@
'overtone.libs.event
'overtone.samples.freesound
'overtone.version))

5 changes: 2 additions & 3 deletions src/overtone/examples/compositions/at_all.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
(ns overtone.examples.compositions.at-all
(:use
overtone.live
[overtone.inst.sampled-piano :only [sampled-piano]]))
(:use overtone.live)
(:require [overtone.inst.sampled-piano :refer [sampled-piano]]))

(defn from [metro offset]
(fn [beat] (metro (+ beat offset))))
Expand Down
26 changes: 18 additions & 8 deletions src/overtone/helpers/string.clj
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,23 @@
hash (subs (str (md5 prefix)) 0 3)
cnt (+ (count prefix) (count postfix))]
(cond
(< cnt max-size) (str prefix postfix)
(< cnt max-size) (str prefix postfix)

(> (+ (count hash) (count postfix)) max-size)
(throw (Exception.
(str "Cannot shorten string. The max-size you supplied to hash-shorten is too small. Try something larger than "
(+ (count hash) (count postfix)))))
(> (+ (count hash) (count postfix)) max-size)
(throw (Exception.
(str "Cannot shorten string. The max-size you supplied to hash-shorten is too small. Try something larger than "
(+ (count hash) (count postfix)))))

:else (let [num-allowed-chars (- max-size (count hash) (count postfix))
allowed-s (subs prefix 0 num-allowed-chars)]
(str allowed-s hash postfix)))))
:else (let [num-allowed-chars (- max-size (count hash) (count postfix))
allowed-s (subs prefix 0 num-allowed-chars)]
(str allowed-s hash postfix)))))

(defn numeric?
"Determines if string is numeric."
[s]
(if-let [s (seq s)]
(let [s (if (= (first s) \-) (next s) s)
s (drop-while #(Character/isDigit %) s)
s (if (= (first s) \.) (next s) s)
s (drop-while #(Character/isDigit %) s)]
(empty? s))))
16 changes: 8 additions & 8 deletions src/overtone/sc/machinery/allocator.clj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
(ns ^{:doc "ID allocator system. Used to return new unique integer IDs
in a threadsafe manner. IDs may be freed and therefore
reused. Allows action fns to be executed in synchronisation
with allocation and deallocation."
:author "Sam Aaron"}
overtone.sc.machinery.allocator
(:use [overtone.sc defaults]
[overtone.sc.machinery.server args])
(ns overtone.sc.machinery.allocator
"ID allocator system. Used to return new unique integer IDs
in a threadsafe manner. IDs may be freed and therefore
reused. Allows action fns to be executed in synchronisation
with allocation and deallocation.
Author: Sam Aaron"
(:use [overtone.sc.defaults]
[overtone.sc.machinery.server.args])
(:require [overtone.config.log :as log]))

;; ## Allocators
Expand Down
13 changes: 8 additions & 5 deletions src/overtone/sc/machinery/server/args.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
[overtone.config store]
[overtone.helpers.system]
[clojure.java.shell])
(:require [overtone.helpers.math :as math]
(:require [clojure.string :as string]
[overtone.helpers.math :as math]
[overtone.helpers.string :refer [numeric?]]
[overtone.jna-path]))

(def SC-ARG-INFO
Expand Down Expand Up @@ -45,13 +47,14 @@
(defn- find-sc-external-version
"In scsynth 3.7 the -V and -v flags switch places. We check the version by
trying both and examining the output from the successful run. Returns a float
representing major and minor release"
representing major and minor release."
[]
(let [attempts [(sh "scsynth" "-V") (sh "scsynth" "-v")]
successful (first (filter #(= (:exit %) 0) attempts))
version (re-find #"scsynth\s+(\d+\.\d+)\.\d+" (:out successful))
]
(Float. (last version))))
version-regex [(re-find #"scsynth\s+(\d+\.\d+)\.\d+" (:out successful))
(re-find #"scsynth\s+(\d+\.\d+)" (:out successful))]
version (->> version-regex (remove nil?) (map second) (filter numeric?) first)]
(Float. version)))

(defn- fix-verbosity-flag
"If scsynth version is 3.7 or above, upper-case the :flag in the :verbosity
Expand Down
7 changes: 4 additions & 3 deletions src/overtone/sc/vbap.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
and its sc port by Scott Wilson."
:author "Orm Finnendahl"
:date "06/06/2015"}
overtone.sc.vbap)
overtone.sc.vbap)

;; VBAP originally created by Ville Pukki
;; This version is a complete reimplementation
Expand All @@ -11,7 +11,7 @@
;; paper "Creating Auditory Displays with Multiple Loudspeakers Using
;; VBAP: A Case Study with DIVA Project" by Ville Pukki.
;;
;; The original C-code was written by Ville Pulkki 1999
;; The original C-code was written by Ville Pukki 1999
;; Helsinki University of Technology
;; and
;; University of California at Berkeley
Expand Down Expand Up @@ -102,7 +102,8 @@
(mapv #(v* (inv-det x y z)
(v-perm-prod-diff %1 %2)) [y z x] [z x y]))

(def any? (comp boolean some))
;; From clojure 1.9 any? is a core function
;; (def any? (comp boolean some))

(defn- get-coords [speaker-set]
(into [] (map :coords speaker-set)))
Expand Down
6 changes: 3 additions & 3 deletions src/overtone/studio/inst.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
(:refer-clojure :exclude [Inst inst?])
(:use [overtone.sc defaults bindings server synth ugens envelope node bus dyn-vars]
[overtone.sc.machinery synthdef]
[overtone.sc.machinery.server.comms :only [with-server-sync]]
[overtone.sc.util :only (id-mapper)]
[overtone.studio core mixer fx]
[overtone.helpers lib]
[overtone.libs event])
(:require [overtone.sc.protocols :as protocols]))
(:require [overtone.sc.protocols :as protocols]
[overtone.sc.util :refer [id-mapper]]
[overtone.sc.machinery.server.comms :refer [with-server-sync]] ))

(defonce ^{:private true} __RECORDS__
(do
Expand Down

0 comments on commit 258dac9

Please sign in to comment.