Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Sohalt committed Jun 16, 2024
1 parent 8b45e90 commit f2d8b40
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 217 deletions.
207 changes: 0 additions & 207 deletions sonic-pi-console.el

This file was deleted.

5 changes: 1 addition & 4 deletions sonic-pi-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@

(defun sonic-pi-restart () (interactive) (sonic-pi-quit) (sonic-pi-jack-in))
(defun sonic-pi-stop-all () (interactive) (sonic-pi-tool-command "stop"))
;; (defun sonic-pi-start-recording () (interactive) (sonic-pi-osc-send-command "record"))
;; (defun sonic-pi-stop-recording (filename) (interactive "FSave to:")
;; (sonic-pi-osc-send-command "stop-recording")
;; (sonic-pi-osc-send-command-with-arg "save-recording" (buffer-name) filename))
(defun sonic-pi-start-recording (filename) (interactive "FSave to:") (sonic-pi-tool-command (format "record %s" filename)))

(defvar sonic-pi-mode-map
(let ((map (make-sparse-keymap)))
Expand Down
4 changes: 1 addition & 3 deletions sonic-pi-tool.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
(require 'cl-lib)
(require 'highlight)

(require 'sonic-pi-console)

(defvar flash-time 0.5)

(defface eval-sonic-pi-flash
Expand All @@ -24,7 +22,7 @@

(defun sonic-pi-eval-text (start end)
"Evaluate text between start and end position in the current buffer."
(sonic-pi-tool-command (format "eval \"%\"" (buffer-substring-no-properties start end))))
(sonic-pi-tool-command (format "eval \"%s\"" (buffer-substring-no-properties start end))))

(defun sonic-pi-send-file ()
"Evaluate contents of file of current buffer."
Expand Down
27 changes: 24 additions & 3 deletions sonic-pi.el
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,15 @@

(defvar sonic-pi-margin-size 1)

(defvar sonic-pi-server-cmd "sonic-pi-tool start-server")
(defconst sonic-pi-message-buffer-name "*sonic-pi-messages*")
(defcustom sonic-pi-log-messages t
"If non-nil, log protocol messages to the `sonic-pi-message-buffer-name' buffer."
:type 'boolean
:group 'sonic)

(defvar sonic-pi-tool-cmd "sonic-pi-tool")
(defun sonic-pi-server-cmd () (format "%s start-server" sonic-pi-tool-cmd))
(defun sonic-pi-logs-cmd () (format "%s logs" sonic-pi-tool-cmd))

(defun sonic-pi--sonic-pi-tool-present-p ()
"Check sonic-pi server exists"
Expand All @@ -61,22 +69,35 @@
((sonic-pi--sonic-pi-tool-present-p) t)
(t nil)))

(defun sonic-pi-messages-buffer-init ()
(when sonic-pi-log-messages
(start-file-process-shell-command
"sonic-pi-logs"
sonic-pi-message-buffer-name
;;FIXME properly wait for sonic pi to start
(format "sleep 3;%s"(sonic-pi-logs-cmd)))))

(defun sonic-pi-sonic-server-cleanup ()
(when (get-process "sonic-pi-server")
(delete-process "sonic-pi-server")))

(defun sonic-pi-messages-buffer-cleanup ()
(when (get-process "sonic-pi-logs")
(delete-process "sonic-pi-logs")))


;;;###autoload
(defun sonic-pi-jack-in (&optional prompt-project)
"Boot and connect to the SonicPi Server"
(interactive)
(when (sonic-pi-valid-setup-p)
(if (not (get-process "sonic-pi-server"))
(let* ((cmd sonic-pi-server-cmd))
(progn
(message "Starting SonicPi server...")
(start-file-process-shell-command
"sonic-pi-server"
"*sonic-pi-server-messages*"
cmd)))
(sonic-pi-server-cmd))))
(set-window-margins (get-buffer-window) sonic-pi-margin-size)
(sonic-pi-connect)
(message "Ready!")))
Expand Down

0 comments on commit f2d8b40

Please sign in to comment.