This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-01-31
Channels
- # announcements (4)
- # babashka (73)
- # beginners (128)
- # bristol-clojurians (1)
- # calva (8)
- # cider (8)
- # clj-kondo (4)
- # clojars (7)
- # clojure (148)
- # clojure-dev (16)
- # clojure-europe (5)
- # clojure-gamedev (1)
- # clojure-italy (10)
- # clojure-nl (7)
- # clojure-uk (57)
- # clojurescript (57)
- # clojutre (1)
- # community-development (2)
- # cursive (7)
- # data-science (1)
- # datascript (5)
- # datomic (9)
- # events (6)
- # figwheel-main (1)
- # fulcro (91)
- # garden (11)
- # graalvm (14)
- # graphql (1)
- # immutant (4)
- # jobs (1)
- # kaocha (33)
- # off-topic (63)
- # onyx (3)
- # pathom (4)
- # re-frame (23)
- # ring-swagger (1)
- # shadow-cljs (49)
- # sql (6)
- # testing (8)
- # tools-deps (45)
- # vrac (1)
- # xtdb (10)
What do clojurescripters do to workaround the fact that BigDecimal doesn't exist if they need to calculate something like (* 100 10.2)
and would like the answer to be exact?
Aha this? https://github.com/gfredericks/exact Didn't show up in my initial search but the addition of "gfredericks" got me there. Thanks
This tagged literal library can also be useful with exact
: https://github.com/mfikes/precise
Hello! What do people use to embed the content of a file (e.g. .css, .svg) in their cljs code as a string? Write a custom macro (so that it is resolved at compile time) calling slurp
?
Thanks a lot! My googling revealed nothing, sadly.
I guess there is no out of the box macro I could use, I have to write my own, right?
Hi, Can someone help me translate plain vanilla js to cljs?
I'm wanting to play audio files in sequence. My plan is to cut a long mp3 into words and then play them one after another
I found a nice code on SO:
function play(audio) {
audio.play();
return new Promise(function(resolve, reject) {
audio.addEventListener('ended', resolve);
});
}
function myFunction() {
var audio1 = new Audio('');
var audio2 = new Audio('');
var audio3 = new Audio('');
play(audio1).then(function() {
return play(audio2);
}).then(function() {
return play(audio3);
});
}
Not sure/certain how to do eventListeners or Promises in CLJS. My goal is to play audio files one after another in a sequence according to a vector that represents the whole sentence, mp3 clip by mp3 clip
something like ["part01.mp3" "part02.mp3" "part03.mp3"] much like in the above example
@sova (defn play [audio] (.play audio) (js/Promise. (fn [resolve reject] (.addEventListener audio "ended" resolve))))
@sova This example may also help: https://gist.github.com/yogthos/d9d2324016f62d151c9843bdac3c0f23#file-gallery-cljs-L67
thanks a lot! looks like kung fu at this point, will learn up
hmm how would you do the
.then
some nice resources: https://lambdaisland.com/episodes/clojurescript-interop https://www.verypossible.com/blog/clojurescript-and-javascript-interoperability-a-comprehensive-guide
thank you kindly.
so just to confirm
resolve
is a function that gets called when the play event finishes?or that's invoked by the promise
(defn play [audio]
(.play audio)
(js/Promise.
(fn [resolve reject]
(.addEventListener audio "ended" resolve))))
(let [s1 (.createElement js/document "audio")
s2 (.createElement js/document "audio")
s3 (.createElement js/document "audio")]
(set! (.-src s1) "ji.mp3")
(set! (.-src s2) "byo.mp3")
(set! (.-src s3) "chyu.mp3")
(set! (.-preload s1) "auto")
(set! (.-preload s2) "auto")
(set! (.-preload s3) "auto")
(-> (play s1)
(.then (play s2))
(.then (play s3))))
they all play simultaneously
it worked
thank you. i don't get it. could you help explain?
thank you very much! 😃
now i'm trying to get it to highlight text alongside playback
lots of surgery but in the end i think it will be worth it
so close haha
eventually i would like to be able to take a neural net with two inputs: script and audio, and output sliced up mp3s tagged with relevant audio, which seems like a simple idea, but getting the training data is ... surgery 😄
is there an accepted way to "toggle class" in cljs?
So I want to generalize this "play a sequence of mp3s" function. is there a way to (.createElement js/document "audio")
and also set its source (set! (.-src name-of-audio-element) "chyu.mp3")
without naming it? Or maybe just name it and conj it to a vector?
If you replace set!
with some function that accepts the element as its first argument, you could use doto
.
wow you're a life saver thank you
is it possible to load a map into clojurescript via a regular file?
i'm likely adding many audio files for the relevant text, is there a way to keep expanding this index list of audio files - with - text without resorting to regenerating the js every time? am thinking some sort of external file w/ the map that i can update on the side. seems reasonable?
If you want to embed the data instead of making a request, check out https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745
yeah that's what i want, need shadow-cljs i suppose