hlolli / csound-mode

Emacs major mode for coding in Csound
41 stars 14 forks source link

Enable UDP communication between termux csound-mode and csound app #7

Closed tj64 closed 5 years ago

tj64 commented 5 years ago

Hi, I now prepared csound-mode in a way that I can successfully run it on Android by using it inside Termux Spacemacs, and communicating via UPD with the Csound Android App.

This is based on two enhancements:

  1. I created a "fake process" to keep comint happy
  2. I created a new custom variable csound-repl-start-server-p which is true by default, but inhibits all references to the Emacs Csound server subprocess when nil.

csound-play and csound-repl-start do work, albeit only if inside the Csound Android the UPDlisten.csd has been started and listens at port 8099.

csound-render returns a message that output to a file needs to be configured inside the (server) csd file within <CsOptions> when no Csound server subprocess has been started in Emacs.

I created a new branch for this, tj-master, but since you only have a master branch, my pull-request goes there. You should test the linux desktop version of csound-mode (setq csound-repl-start-server-p t), if I haven't messed up anything. For testing on Android you will need the fantastic termux app.

I made example files work (sound), but due to my beginners ignorance with csound syntax, I could not get "real" example songs play yet. From the examples it looks straightforward, split the song csd file in two files, server and client file so to say, with an f0 variable inside the server score, and (only) the real score content inside the client file. This works when I trigger client events with schedule, but those frequent i1 statements in the example files score do give parser errors. I have to learn more about csound syntax I guess ...

Cheers Thorsten

PS By the way, this is really a marvelous mode, I'm looking forward to play around with it on my smartphone. If you accept this pull request, another superb thing would be a Spacemacs layer for Csound, since with it's one key menus and bindings, and transient modes, Spacemacs would be a fantastic environment for REPL live coding.

Normally, everything useful for a mode goes into a Spacemacs layer. I have one question wrt to this: there is another impressive Emacs mode for Csound, csound-x, why there are two modes, what is their relation? Should both modes complement each other in a Spacemacs layer, or would that be redundant?

hlolli commented 5 years ago

Looks fantastic, thanks for this. I notice that I haven't set up any CI testing, going to set it up asap. The only comment I have before testing this myself is: https://github.com/hlolli/csound-mode/blob/4515081dcff3e54157415f959315ea77a618d695/csound-repl.el#L61

Would make sense to have a default kr tough most users just stick with ksmps. But the default should then be sr divided by ksmps.

tj64 commented 5 years ago

Hi, I now set kr to ksmps by default, but it has its own custom var. By accident (opening the identical csoundtest.txt instead of csoundtest.csd) I figured out that last-csound-buffer is not always a list and built in a check for this.

I'm sorry for all this whitespace noise in the commit, I used whitespace mode on the buffers, but this should have gone in a separate commit.

tj64 commented 5 years ago

BTW, this article about scoreless csound brought me right on track wrt to dealing with csound syntax in Emacs (repl or client csd file).

hlolli commented 5 years ago

It looked good to me, just fixed the 4 spaces indentation to 2 spaces, maybe you can .dir-local your elisp indentation to 2 :) go free on PR's if you bump into fixes. I'm trying to build some tests, hopefully I get it working soon, then I should be able to merge from you without much worries. I could start a develop branch, but I like the fact that latest git commit becomes available on melpa-unstable. Then I can bump the version number and a stable packet gets created.

tj64 commented 5 years ago

Thanks for merging, I think you definitely can delete this tj-master branch that is now in your repo, should not be there anymore. Next time I make a PR from master to master.

And I created a .dir-locals file, but for the heck of it cannot remember or find the variable to set directory local elisp indenting ;-) But I think the 4 spaces came from a little test with semantic indentaton in spacemacs, which I don't use anymore.