I recorded my mic with ClojureScript

I learned how to work with the user’s microphone in ClojureScript. I coded 90% of this code using JavaScript interop. I learned to use JS classes in ClojureScript (prepend “js/” and append “."). To record from the microphone, I needed to understand the Navigator, MediaRecorder, Blob, and URL classes in JavaScript. I created two functions for two handlers: js/window's onload event to get the user media, and js/MediaRecorder's ondateavailable, so that I could work with the user’s audio after I stopped recording.

Using classes in ClojureScript

Whenever I see a class in js, just do (js/className. arg1 ... argN). Treat the dot at the end as the new keyword in js. Pass an audio/visual stream to a MediaRecorder with (js/MediaRecorder. %).

Getting microphone permission in JS

Use js/navigator (ClojureScript’s way of accessing JS’s Navigator) to pull the user’s microphone stream. I haven’t recorded the stream data yet, but I’ve finished the first step: Getting the user’s permission. You can’t ask for mic permission straight away; you need the JS tools need to load, which means creating an onload handler (function) for the js/window. In ClojureScript: (set! (.-onload js/window) (fn [] (js/navigator.getUserMedia #js {:audio true} #(println "Success: " %) #(println "Error message: " %)))) ;; #object[MediaStream [object MediaStream]] I tested switching between js/document and js/window.

Parking vs. blocking makes no difference to me atm

When using asynchronously running processes, i.e. with go macros or futures, blocking or parking make no difference to me atm. Atm I see no reason not to simplify things, using <!! exclusively instead of <! sometimes in a go block. ;; Control, can use multiple expressions in the go body (def my-chan (chan)) (println 1) (go (println 2) (println 3)) (println 4) ;; (def my-chan (chan)) (println 1) (go (>!

I need to understand the MediaRecorder API to record and store audio in the browser

I require knowledge of ArrayBuffers to build my imagestreaming app. I need to asynchronously collect a stream of data from the user’s microphone and pass it to the MediaRecorder API. Then as it records, it apparently passes chunks of bytes to the blob. Once I signal it to stop, I can ostensibly do something with this.

Remember your closing tags

To exercise my CSS skills, I tried placing two 100px by 100px divs beside each other. After putting two div tags in the html and setting the height and width of divs to 100px, my Codepen preview showed one box, not two. Did Codepen not render multiple divs? Did it have overriding, wonky CSS? To find out, I spawn a fresh index.html and styles.css file with the same div ruleset. Two divs in the html later, I see two blue boxes in the live preview.

Reallocating $

To protect myself from Dogecoin’s +38% and -38% variations, I changed my holdings from ~97% Dogecoin (27k Doge) to ~30% Dogecoin (7k Doge), assets, etc. I successfully told the group that I reallocated, without getting crucified. I told the truth, and now my conscience is cleared. I’m presenting myself authentically, so I’m doing okay. Also, Nick Ballz, a Doge millionaire who I think is cool, remained my follower. That makes me happy 😊

Dogecoin and Litecoin communities sponsor Nascar drivers for June 19th race

Dogecoin community (who specifically?) sponsored Stefan Parsons and Voyager sponsored Landon Cassill.

Having trouble passing JS objects as arguments in ClojureScript/JS interop

Despite me passing in (js-obj "audio" true) or other variants into getUserMedia, i.e. (.. js/window -navigator -mediaDevices getUserMedia (js-boj {"audio" true})), it complains about not having a video or audio constraint: “Failed to execute ‘getUserMedia’ on ‘MediaDevices’: At least one of audio and video must be requested”. What method of passing in the object would work here?

Use `set!` and `-property` to modify DOM elements with ClojureScript

To modify a DOM element, select it and then use set!. To select it, try (def h2 (.querySelector js/document "h2")). Then with your element, use set!, .., and - for (set! (.. h2 -style -color) "red"). Use this, and you’ll see the first h2 element, if there is one, turn red.