Packages

A Eurorack-inspired, modular, MIDI generation and manipulation system

Current section

Files

Jump to
underack src underack state.lfe
Raw

src/underack/state.lfe

(defmodule underack.state
(export all))
(defun read
((rack-name) (when (is_atom rack-name))
(read rack-name (erlang:timestamp)))
((path)
(json-file:read path)))
(defun read (rack-name timestamp)
(json-file:read 'state (format-rack-path rack-name timestamp)))
(defun read (rack-name timestamp module-name)
(json-file:read 'state (format-module-path rack-name timestamp module-name)))
(defun write (rack-name timestamp binary)
(json-file:write 'state (format-rack-path rack-name timestamp) binary))
(defun write (rack-name timestamp module-name binary)
(json-file:write 'state (format-module-path rack-name timestamp module-name) binary))
(defun format-ts
((timestamp) (when (is_tuple timestamp))
)
((ts) ts))
(defun format-rack-path (rack-name timestamp)
(filename:join (list (io_lib:format "%s-%s" (list (atom_to_list rack-name) timestamp))
"rack.json")))
(defun format-module-path (rack-name timestamp module-name)
(filename:join (list (io_lib:format "%s-%s" (list (atom_to_list rack-name) timestamp))
(io_lib:format "module-%s.json" (list module-name)))))