Closed tj64 closed 5 years ago
I must say that I have literally no idea how the Android environment works. The only thing that the csound-repl expects is that csound is executeable from the path. If you can start emacs with an environmental variable like
PATH=$PATH:/path/to/bin/csound emacs -nw
to help it find the csound executeable, than you'd be in good hands. But the UDP communication which I use is purely automatic given that emacs can find the csound executeable.
I investigated a bit more, starting out by making the hint cited above work on my Android 7 phone. All steps are (as well as the necessary csd and txt files) are described in https://github.com/csound/csound/issues/927. (note that in termux, my preinstalled "nc" command did not have a "-u" option (I think that was a 'nc java applet' or so), so I actually had to install netcat in termux and use it).
Then I had a look at csound-mode.el and Emacs network processes, and the hint cited above is the exact solution for the problem.
If you use the csound Android app and start the UDP server at port 8099 as describes in issue 927 cited above, and in termux/emacs put this in an emacs-lisp buffer (reusing the content from updtest.txt from issue 927), and evaluate the buffer, you should be able to hear that annoying tone.
`(setq CsoundProcess (make-network-process :name "Csound" :type 'datagram :buffer "Csound"
:family 'ipv4 :host "127.0.0.1" :service "8099" :sentinel 'listen-sentinel :filter 'listen-filter))
(process-send-string CsoundProcess (string-to-unibyte
"instr 1
prints \"hello world\"
a1 vco2 p5,p5
outs a1 , a1
endin
schedule 1,0,3, 0.2, 440"))`
So it's actually the same approach as in csound-repl.el, and only one problem remains: when I call csound-repl-start
I get "Csound not installed on your computer" instead of a working repl.
To fix this, csound-repl--start-server
should become an optional call, depending on a user prompt, maybe something like this:
`[ ] start local csound server yes-or-no?`
Then, when in termux, I could opt for no and use the csound Android app as local csound udp server.
Cheers Thorsten
Ok, you are totally right. It should be possible to just start listenig on a udp port without starting Csound. Provided with port, one can of course start Csound somewhere else. There's much work I need to do with the repl that I haven't got around to. It compiles instruments and sends events, but I hope to add more tooling.
Would you be ok with an interface like M-x csound-repl-listen RET < port > etc?
I forked the repo and started to hack around a little, its not that trivial like I thought, but should be doable. I ended up adding a new boolean custom csound-repl-start-server-p
in csound-repl that I then use in all places where the server subprocess is called/referenced.
That way I could start a REPL, i.e. I see a REPL buffer, but nothing works yet.
One important thing seems to be to keep comint happy, besides not providing a server process.
This has already be done before (by providing a fake process) and could be copied: https://www.emacswiki.org/emacs/ComintModes.
And maybe with such fake process, there is no need anymore for the somehow hackish use of csound-repl-start-server-p
conditionals in many places?
This weekend and I can dig further, so maybe you just wait for me for a first sketch of a possible solution? But it would of course not be a problem if you come first with a better solution than me ;-)
It would be really nice to have the full REPL functionality already available in csound-mode in Termux/Emacs, just have a slightly different communication style in the background.
Sucessfully closed with PR https://github.com/hlolli/csound-mode/pull/7 Thanks
Hi, I would like to use csound-mode (with repl) in Spacemacs within Termux to edit and eval .csd files. Csound itself is neither in Termux nor in e.g. TermuxArch repos, so I cannot install it on the Linux side. But I did install the Csound App from Google Play Store, which works fine.
From inside Termux, I cannot access the csound executable (permission denied, phone is not rooted).
What I found so far is this hint for communication via UPD.
Do you have any solution for this already? The only way I can think of at the moment is, in termux, put an executable .sh file in /usr/bin (exec path) that recieves the csound-repl calls (instead of the csound executable) and then forwards the calls via UPD to the csound Android app?
Cheers Thorsten