Fork me on GitHub
#clojure
<
2019-07-19
>
aengelberg03:07:13

anyone have experience using Clojure to control MIDI instruments? (or know of libraries that support this?)

alexmiller03:07:51

Didn’t Rich do a talk about this? The Harmonikit talk?

👍 4
aengelberg04:07:58

I totally forgot about that, now I'm gonna go rewatch it 🙂

aengelberg04:07:03

Btw my goal is to control external devices via MIDI signals, and if I recall correctly Overtone doesn't address that

danielneal07:07:39

if you don’t want to pull in supercollider etc

Luke Zeitlin08:07:23

I think Overtone will do what you want. Although it's not the most stable lib I've ever used. Maybe you'll have a better experience with a java lib : https://docs.oracle.com/javase/tutorial/sound/overview-MIDI.html

aengelberg19:07:48

@U051H1KL1 that's very cool, i'll take a look at pink

Dan Richelson03:07:55

I'm trying to deploy a snapshot build via Maven to Clojars. Here's the relevant bits in the pom.xml: https://github.com/drichelson/LX/blob/ee25e27f98c6e7783d4167620e41aa5fefbcbc2c/LX/pom.xml#L102 It looks like artifacts get uploaded, but it fails when dealing with the metadata:

[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ LX ---
Downloading from clojars: 
Uploading to clojars: 
Uploaded to clojars:  (617 kB at 224 kB/s)
Uploading to clojars: 
Uploaded to clojars:  (3.9 kB at 1.9 kB/s)
Downloading from clojars: 
Uploading to clojars: 
Uploaded to clojars:  (773 B at 367 B/s)
Uploading to clojars: 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  18.641 s
[INFO] Finished at: 2019-07-18T20:55:40-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project LX: Failed to deploy metadata: Could not transfer metadata org.clojars.heronarts:LX/maven-metadata.xml from/to clojars (): Access denied to:  -> [Help 1]

Dan Richelson03:07:17

http://clojars.org help page says to come here..

Dan Richelson04:07:03

mvn --version
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T11:41:47-07:00)

carkh04:07:01

maybe your credentials to clojars not properly configured in maven? or maybe a gpg key issue ?

Dan Richelson16:07:42

@U13RRNF2M credentials are correct. I have tried it with a bad password and it fails earlier with a 401.

carkh16:07:31

i seem to remember there could be issues with unsigned poms

Dan Richelson16:07:04

thanks for the tip. Any ideas on more docs/help on this matter? the http://clojars.org site is pretty sparse

carkh16:07:46

let me try to find something

thanks2 4
carkh16:07:15

checksums

carkh16:07:21

signature seems optional

Dan Richelson16:07:57

the error message I get back is not really helpful, so it’s hard to figure out what to change

carkh16:07:33

yes i had to fiddle quite a lot, mostly in the dark too

Dan Richelson16:07:03

were you using maven? I’m wondering if an example would help.. otherwise I’m not sure clojars is a good fit

carkh16:07:32

i actually had to switch to using maven to make it all work

Dan Richelson16:07:51

ooh are you able to share your pom.xml/commands?

carkh16:07:28

check the start-pom.xml

carkh16:07:05

hum i'm on windows, and i have a cmd file that does a full release

carkh16:07:32

but it isn't on the github >>

carkh16:07:57

del pom.xml
copy start-pom.xml pom.xml
IF [%1]==[] GOTO NO_BUMP
clojure -A:release %1
:NO_BUMP
clojure -A:garamond
call mvn deploy
git push --tags

carkh16:07:38

check the deps.edn ...to see what those clojure calls do

carkh16:07:02

garamond is mostly just editing the pom

carkh16:07:22

the whole process can be seen on this other repository of mine : https://github.com/cark/cark.behavior-tree

Dan Richelson16:07:41

I’m not a clojure person so i may get lost here

Dan Richelson16:07:14

i was looking at some docs and saw that groupID cannot equal member name.. this is the case for us so i changed groupID but still no luck

carkh17:07:51

there is a clojars channel on this slack, maybe someone more knowledgeable can help you there

carkh17:07:31

i just hammered at it until it worked =)

Ashwin Bhaskar09:07:41

Can anyone help me out with how the let macro is implemented? From the implementation let expands to something that calls destructure. And destructure, which is a function, in turn calls let. Where does this mutual recursion end?

bronsa09:07:37

1- clojure has let* built in, 2- clojure.core defines a let macro on top of let*w/o destructuring support 3- clojure.core defines destructure function using the simple `let macro 4- clojure.core redefines the let macro with destructuring support using destructure

👍 4
quadron12:07:09

what am I doing wrong?

bronsa12:07:07

clojure.core.protocols/Datafiable

bronsa12:07:17

a protocol is a Var not a Class

✔️ 8
Kanister17:07:49

I have weird problem. I am trying to create a project with lein new droid but it does not find com.android.support:multidex:aar:1.0.0 can it be removed from the repo?

sogaiu09:07:40

has clojure on android revived? you might have luck asking @U06PNK4HG

noisesmith17:07:08

lein droid is a bit weird - maybe the maven artifact it used has been "unpublished" ?

leblowl19:07:24

Does anyone know of a way to reload Java classes from a Clojure REPL? Or any suggestions for other Java/Clojure workflow? Should I just test thoroughly in Java before importing into Clojure? I like the idea of testing in the REPL and don't like to restart the REPL only for some Java changes... thanks!

noisesmith19:07:52

my approach is to do only things that I absolutely need java for in java (either clean unboxed numerics or tooling mandated inheretence or features that exploit the metadata that javac puts on classes), and as much as possible fill out the rest via clojure (with java finding and calling clojure code) for repl friendlyness

👍 4
noisesmith19:07:16

reloading java classes is hacky at best, sadly

noisesmith19:07:34

all the logic is looked up in clojure code on the fly

noisesmith19:07:55

(other than the top level error handler)

leblowl19:07:05

@noisesmith thanks... so it's easier to invert the relationship sort-of and call Clojure code from Java and then use that Java class from the REPL? Then you can write a function, use it with the Java class and edit/reload the function as you like?

noisesmith19:07:29

exactly - more convolute than invert maybe :D

noisesmith19:07:55

you create the java so some class knows how to find and use it (usually), then the implementation calls back into clojure again

noisesmith19:07:33

in my example it just uses a convention (this system property must point to the name of a namespace, these defns must exist in the namespace)

noisesmith19:07:22

but you could even pass the var in to the class constructor, then invoke it (delegation pattern sort of) - since it has the var, redefinitions will be used properly

noisesmith19:07:22

another approach is via gen-class, but as I've said recently, I find a minimal java file more straightforward than equivalent gen-class, ymmv

leblowl20:07:45

@noisesmith Ok thank you so much. Just curious, do you know what is holding us back from reloading Java classes in Clojure? I found this also: https://github.com/ztellman/virgil ... not sure what they are doing or if it works.

noisesmith20:07:28

it's one of the hacks I'm referring to - you can make a new class with the same name as an existing one, but you can't update the methods of one that is already instantiated

noisesmith20:07:30

note that the class definitions are replaced, but any instances of classes you still hold are not going to change

leblowl20:07:17

@noisesmith Ok, I think that sounds reasonable. It's interesting. Thanks again

alexmiller20:07:49

you can actually do hot reloading via java agents, but it's a much more invasive process

leblowl20:07:52

@alexmiller thanks, that does look exactly like what's required

Joshua Suskalo22:07:59

Are there any good websocket client libraries that work for both Clojure and ClojureScript?

octahedrion13:07:51

I prefered plain Aleph as it provides the channel astraction, whereas Sente replaces channels with events/handlers. For Clojurescript I did it myself with core.async & goog.websocket, but there's probably a good lib for that now

Joshua Suskalo22:07:44

My understanding of that library is that it is a Clojure server and ClojureScript client.

nenadalm05:07:43

Sente works also on ClojureScript server. There is Macchiatto adapter: https://github.com/ptaoussanis/sente/blob/master/src/taoensso/sente/server_adapters/macchiato.cljs Only bad thing on this library and reason I didn't use it on latest project is that it uses some undocumented protocol and I needed to connect microcontrollers to it and since the protocol isn't documented anywhere, I just used ws library (https://www.npmjs.com/package/ws) on the server instead and WebSocket api in the browser (https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API). Sente seems to be nice library though, if you only want to connect devices written with Sente library together (or willing to find out how the protocol works and implement it on other devices).

Joshua Suskalo22:07:33

I'm currently using gniazdo for my library so that I can have a websocket client on the Clojure side, but I'm trying to add ClojureScript support so that users can work on node instead of the JVM.

leblowl22:07:56

I see... that's interesting. Not sure if such a client library exists, but maybe someone else knows better, sorry

Joshua Suskalo22:07:34

Yeah I've been looking for a year and never found one, so I guess it doesn't exist. I might be able to write one myself, but it might just be easier to have two different impl namespaces depending on the language being used.

Joshua Suskalo22:07:59

Which using this: https://github.com/nilenso/wscljs I may be able to get a near-identical interface for using it, making the amount which needs to be in each ns very little

leblowl23:07:56

@suskeyhose I think that's a good idea, that's probably what I would do to start. The CLJ/CLJS reader macros make it easy to define a single function that can support both clj/cljs with different dependencies... I found this for Node: https://www.npmjs.com/package/ws and this mega thread https://stackoverflow.com/questions/16392260/which-websocket-library-to-use-with-node-js ... it looks like ws and gniazdo sort of share a similar API too. Regarding wscljs, will js/Websocket work in Node? I was thinking that's a browser only API?

Joshua Suskalo23:07:29

That's a good question. I haven't really dived too deeply into the cljs environment.

leblowl23:07:51

This is a much better guide: https://clojure.org/guides/reader_conditionals ... I have found they make it super easy to write some mixed CLJ and CLJS specific code in a single namespace or function. So I think all you would need to do is find the correct library/API for Node websocket client and add a reader conditional for CLJS inside your existing CLJ client function. When you run the app on Node, as long as all other code is Node compatible, it will execute the CLJS specific version of the client function.

Joshua Suskalo23:07:05

I was aware of reader conditionals, but I hadn't ever used them before

Joshua Suskalo23:07:34

but yeah, that sounds great! Thanks for the help!

lilactown00:07:03

If you only care about browser cljs, then just use the native APIs

lilactown00:07:21

If you need to support both node and web it's mor complicated