sound progress.
This commit is contained in:
@@ -256,9 +256,9 @@
|
||||
|
||||
(defn load-sound [f]
|
||||
(try
|
||||
(sound (str f ".mp3"))
|
||||
(sound f)
|
||||
(catch Exception _
|
||||
(sound f))))
|
||||
(sound (str f ".mp3")))))
|
||||
|
||||
|
||||
|
||||
@@ -402,36 +402,41 @@
|
||||
|
||||
|
||||
(defn get-sound-volume [entities target vol-scale [x y]]
|
||||
(if (= target :ego)
|
||||
(-> (* (/ (get-in entities [:room :entities :ego :scale-x]) 1.5) 0.75)
|
||||
(* (or vol-scale 1.0))
|
||||
(clamp-volume))
|
||||
(proximity-volume entities [x y] :scale vol-scale)))
|
||||
(* (if (= target :ego)
|
||||
(-> (* (/ (get-in entities [:room :entities :ego :scale-x]) 1.5) 0.75)
|
||||
(* (or vol-scale 1.0))
|
||||
(clamp-volume))
|
||||
(proximity-volume entities [x y] :scale vol-scale))
|
||||
(- 1.0 (get-in entities [:fade :opacity]))))
|
||||
|
||||
(defn get-sound-pan [x]
|
||||
(/ (- x 160 ) 160))
|
||||
|
||||
(defn sourced-volume-fn [target vol-scale [x y]]
|
||||
(fn [entities]
|
||||
(get-sound-volume entities target vol-scale [x y])))
|
||||
|
||||
|
||||
(defn play-sound!
|
||||
([screen entities snd target vol-scale [x y]]
|
||||
(play-sound! screen entities snd target vol-scale [x y] :once))
|
||||
([screen entities snd volume-fn]
|
||||
(play-sound! screen entities snd volume-fn 0.5))
|
||||
|
||||
([screen entities snd target vol-scale [x y] type]
|
||||
(let [vol (get-sound-volume entities target vol-scale [x y])
|
||||
pan (get-sound-pan x)
|
||||
([screen entities snd volume-fn pan]
|
||||
(play-sound! screen entities snd volume-fn pan :once))
|
||||
|
||||
([screen entities snd volume-fn pan type]
|
||||
(let [vol (volume-fn entities)
|
||||
sound-id (if (= :once type)
|
||||
(sound! snd :play (current-sound-volume vol) 1.0 pan)
|
||||
(sound! snd :loop (current-sound-volume vol) 1.0 pan)) ]
|
||||
(update-in entities [:current-sounds :value]
|
||||
conj {:id sound-id
|
||||
:sound snd
|
||||
:loc [x y]
|
||||
:vol-scale vol-scale
|
||||
:volume-fn volume-fn
|
||||
:type type
|
||||
:ends-at (if (= type :once)
|
||||
(+ (:total-time screen) (sound! snd :duration))
|
||||
nil)
|
||||
:target target}))))
|
||||
nil)}))))
|
||||
|
||||
(defn stop-all-sounds! [entities]
|
||||
(doseq [snd (get-in entities [:current-sounds :value])]
|
||||
|
||||
Reference in New Issue
Block a user