help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Emacs music everywhere/REPL Elisp/Nyquist/XLISP


From: Emanuel Berg
Subject: Emacs music everywhere/REPL Elisp/Nyquist/XLISP
Date: Thu, 25 Nov 2021 04:44:26 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Hello music lovers,

I thought one would do music with Emacs, and have the
interactiveness of Emacs Lisp (I was about to say Lisp, but
I've only seen it 100% in Elisp, even in SLIME and SBCL
I couldn't get further than what amounted to a very fancy
REPL, with the tedious loading and redoing on error ...).

So terminology - the REPL prompt is interactive - Elisp is
- what is it - everywhere?

Anyway this is another case of the same phenomenon (as my
SLIME experience), it is the music composing language/software
Nyquist which is based on XLISP (which I've never heard of,
but there are a lot of Lisp dialects, thanks to the simplicity
of said REPL ironically) - anyway here, if you take a look at
the code below, if I can feed code into the interactive
interpreter (Lisp cruncher or prompt), why can't I/how can
I just `eval-last-sexp' as I do in Emacs?

If one changes mode to `inferior-lisp-mode' can't it introduce
(optimally replace/rewire for the mode being) eval-last-sexp
and corresponding functions with the likes of
"inferior-lisp-eval-last-sexp" and what will happen is the
code read will be fed into the REPL prompt or rather it would
be evaluated and executed under the hood just the same!

Question 2 - can't we clone Nyquist and move the C to us and
have it available from Elisp so one do not have to bother with
XLISP and inferior-etc at all?

Fork?

Question 3 - here is the source: [first - Elisp, second - XLISP]

;;; -*- lexical-binding: t -*-
;;;
;;; this file:
;;;   https://dataswamp.org/~incal/emacs-init/ny.el
;;;
;;; original commands/docstrings:
;;;   
https://www.audacity-forum.de/download/edgar/nyquist/nyquist-doc/examples/emacs/how-to/init-nyquist.html
;;;
;;; all Nyquist files:
;;;   https://dataswamp.org/~incal/ny/

(require 'inf-lisp)

(let*((ny-buff "*Nyquist*")
      (ny-proc "inferior-lisp")
      (inferior-lisp-buffer ny-buff) )
  (defun ny-running-p ()
    "Return non-nil iff a Nyquist process is running."
    (get-process ny-proc) )
  (declare-function ny-running-p nil)

  (defun ny-start ()
    "Start a new Nyquist process."
    (run-lisp "/bin/ny")
    (switch-to-buffer (format "*%s*" ny-proc))
    (rename-buffer ny-buff)
    (setq inferior-lisp-buffer ny-buff) )
  (declare-function ny-start nil)

  (defun ny-kill ()
    "Kill the Nyquist process and buffer."
    (when (get-buffer ny-buff)
      (kill-buffer ny-buff) )
    (when (processp ny-proc)
      (delete-process ny-proc) ))
  (declare-function ny-kill nil)

  (defun ny ()
    "Switch to the Nyquist buffer, if not running start one."
    (interactive)
    (if (and (ny-running-p)
             (get-buffer ny-buff) )
        (switch-to-buffer ny-buff)
      (ny-kill)
      (ny-start) ))
  (declare-function ny nil) )

;; this file:
;;   https://dataswamp.org/~incal/ny/init-incal.lsp

(defun load-init ()
  (load "/home/incal/ny/init-incal.lsp") )

(setq *snd-list-devices* nil)
(setq *snd-device*       7)

(defun midi-note-p (note)
  (when (and (<= 0 note)
             (<= note 127) )
    t) )

(defun orgel-note-p (note)
  (when (and (<= 1 note)
             (<= note 88) )
    t) )

(defun piano-note-p (note)
  (when (and (<= 1 note)
             (<= note 61) )
    t) )

(defun play-midi (note)
  (when (midi-note-p note)
    (play (osc note)) ))

(defun play-midi-orgel (note)
  (when (orgel-note-p note)
    (play (osc (+ 20 note))) ))

(defun play-midi-piano (note)
  (when (piano-note-p note)
    (play (osc (+ 35 note))) ))

(defun play-midi-interval (beg end)
  (when (and (midi-note-p beg)
             (midi-note-p end)
             (< beg end) )
    (do ((n beg (setq n (+ 1 n))))
        ((< end n))
      (play (osc n)) )))

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]