diff --git a/README.md b/README.md index 5aced32..1edcfd4 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,8 @@ Then start the LFE REPL with prefined options for undermidi: $ rebar3 as undermidi repl ``` +**IMPORTANT!!**: the command given above automatically starts undermidid. If you do not use that command, you will need to manually start undermidi. Not doing so will result in many commands cusing a segmentation fault of the Erlang VM due to the MIDI NIF not being initialised! + Once the LFE REPL is ready, you can start the app: ```cl @@ -59,13 +61,11 @@ Note that, depending upon the configured log level, you may see a fair amount of (set term (midimsg:note-off channel 48 64)) (um.ml:send device term) -(undermidi:start) (undermidi:list-devices) (set device "model_15") (set channel 1) (um.note:play device channel (um.note:make 'C3)) -(undermidi:start) (undermidi:list-devices) (set device "model_15") (set channel 1) @@ -75,7 +75,6 @@ Note that, depending upon the configured log level, you may see a fair amount of (set notes (um.note:make '(C3 C3 Eb3 C3 Eb4 Bb3 C4 C3))) (um.note:play-notes device channel notes 250 8) -(undermidi:start) (undermidi:list-devices) (set device "model_15") (set `#(ok ,d) (undermidi.devices:new device)) @@ -88,16 +87,14 @@ Note that, depending upon the configured log level, you may see a fair amount of (undermidi:play-notes d '(seq-2a) 250 8) (undermidi:play-notes d '(seq-3a) 250 8) -(undermidi:start) (undermidi:list-devices) (set device "midi_bus_1") (set device "provs-mini_provs-mini_midi_1_24_0") (set `#(ok ,d) (undermidi.devices:new device)) (include-lib "priv/seqs/basic.lfe") -(set notes (um.note:legnthen (um.chord:make-fuzzy (seq-3a) 80))) +(set notes (um.note:lengthen (um.chord:make-fuzzy (seq-3a)) 80)) (undermidi:play-notes d notes 8200 1) -(undermidi:start) (set device "midi_bus_1") (set `#(ok ,d) (undermidi.devices:new device)) (set cmaj7 (um.chord:lengthen (um.chord:make-fuzzy '(C4 E4 G4 B4)) 40)) diff --git a/include/errors.lfe b/include/errors.lfe index 8139e91..11f8b84 100644 --- a/include/errors.lfe +++ b/include/errors.lfe @@ -1,2 +1,6 @@ (defun ERR_NO_DEVICE () #(error "no such device; see (um:list-devices) for known system MIDI devices.")) +;; This function is for display purposes when used in the REPL +;; and needs to be the last function in the include file. +(defun |-- loaded include: errors --| () + 'ok) \ No newline at end of file diff --git a/rebar.config b/rebar.config index 28642b6..0ceabe4 100644 --- a/rebar.config +++ b/rebar.config @@ -51,7 +51,7 @@ {plugins, [rebar3_hex]} ]}, {undermidi, [ - {lfe, [{nobanner, true}]} + {lfe, [{repl, [{nobanner, true}]}]} ]} ]}. @@ -78,7 +78,7 @@ %% The following should be run with `rebar3 as undermidi repl`: {repl, [ clean, - {lfe, repl, "--name undermidi@local"} + {lfe, repl, "--name undermidi@local --apps undermidi"} ]}, {publish, [ compile, diff --git a/src/undermidi.app.src b/src/undermidi.app.src index 49699c2..d422e52 100644 --- a/src/undermidi.app.src +++ b/src/undermidi.app.src @@ -6,6 +6,7 @@ {applications, [kernel, stdlib, + logjam, lfe ]}, {env,[]}, diff --git a/src/undermidi.lfe b/src/undermidi.lfe index 29c5ee3..9b13bfc 100644 --- a/src/undermidi.lfe +++ b/src/undermidi.lfe @@ -17,12 +17,7 @@ (include-lib "logjam/include/logjam.hrl") (defun start () - (let ((cfg-file "config/sys.config")) - (io:format "~s" (list (undermidi.util:banner))) - (logjam:set-config `#(path ,cfg-file)) - (log-notice "Starting undermidi, version ~s ..." (list (undermidi:version))) - (application:ensure_all_started 'undermidi) - (log-debug "\nVersions:\n~p\n" (list (versions))))) + (application:ensure_all_started 'undermidi)) (defun stop () (application:stop 'undermidi)) diff --git a/src/undermidi/app.lfe b/src/undermidi/app.lfe index 3102696..670aac2 100644 --- a/src/undermidi/app.lfe +++ b/src/undermidi/app.lfe @@ -16,9 +16,15 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun start (_start-type _start-args) - (log-info "Starting OTP application ..." '()) - (um.nif:initialise) - (undermidi.supervisor:start_link)) + (let ((cfg-file "config/sys.config")) + (logjam:set-config `#(path ,cfg-file)) + (log-info "Starting OTP application ..." '()) + (um.nif:initialise) + (io:format "~s" (list (undermidi.util:banner))) + (logjam:set-config `#(path ,cfg-file)) + (log-notice "Starting undermidi, version ~s ..." (list (undermidi:version))) + (log-debug "\nVersions:\n~p\n" (list (undermidi:versions))) + (undermidi.supervisor:start_link))) (defun stop (_state) (um.nif:deinitialise)