the-drunk-coder / megra

Mégra is a mini-language to make music with variable-order markov chains and some other stochastic shenanigans.
GNU General Public License v3.0
69 stars 4 forks source link

ERROR: start chain FIRST #3

Closed yangh closed 4 years ago

yangh commented 4 years ago

Hi Megra

I've installed Megra under Ubuntu 18.04 x86_64 by following the guide in the new tutorial, everything goes well, Potacle started and no critical error on startup, but when I try to run the first example in the basic chapter, after press ctrl+enter, I can hear nothing and an error message printed:

ERROR: start chain FIRST

Any commen please?

I have some experience with Racket but not at sbcl and emacs.

Thanks

the-drunk-coder commented 4 years ago

Hi @yangh

Sorry about the error message, it's just a historical debug printout that i never removed because it always was a good indicator for me that fit into my performance practice ... it really just means that the thing you wanted to start started, nothing wrong here.

About the sound, I assume you started ScSynth in the background somehow, either from the command line or using ScIDE ?

Thanks for your feedback !

yangh commented 4 years ago

Hi Nik

Thanks for your reply, I noticed it should a debug print after I entered another generator and try to run it.

Well, the tutorial doesn't mention scsynth is needed to run in the background and how to run it, and I'm not familiar with it. Do you have an example/guide to start it? I did a quick search via internet, but found a good start for run with megra.

Thanks in advance

yangh commented 4 years ago

Hi Nik

After run ScIDE and Start Server from Language menu, Megra rolls as expected, it's fantastic!

Have fun with it right now. Thanks

paddywwoof commented 4 years ago

Hi, also attempting to use megra on ubuntu 18.04. After a very tedious process of compiling supercollider things seem to mostly run - but as above no sound running the simple beep. I get this error

The function COMMON-LISP-USER::SINE is undefined.
   [Condition of type UNDEFINED-FUNCTION]

Restarts:
 0: [CONTINUE] Retry using SINE.
 1: [USE-VALUE] Use specified function
 2: [RETRY] Retry SLIME interactive evaluation request.
 3: [*ABORT] Return to SLIME's top level.
 4: [ABORT] abort thread (#<THREAD "worker" RUNNING {1003E79A83}>)

Backtrace:
  0: (SB-IMPL::RETRY-%COERCE-NAME-TO-FUN SINE NIL)
  1: (SB-INT:SIMPLE-EVAL-IN-LEXENV (SINE (QUOTE A4) :LVL 0.5 :DUR 500) #<NULL-LEXENV>)
  2: (SB-INT:SIMPLE-EVAL-IN-LEXENV (INFER (QUOTE BEEP) :EVENTS (QUOTE TONE) (SINE (QUOTE A4) :LVL 0.5 :DUR 500) :RULES ...) #<NULL-LEXENV>)
  3: (SB-INT:SIMPLE-EVAL-IN-LEXENV (SX (QUOTE FIRST) T (INFER (QUOTE BEEP) :EVENTS (QUOTE TONE) (SINE # :LVL 0.5 :DUR 500) :RULES ...)) #<NULL-LEXENV>)
  4: (EVAL (SX (QUOTE FIRST) T (INFER (QUOTE BEEP) :EVENTS (QUOTE TONE) (SINE # :LVL 0.5 :DUR 500) :RULES ...)))
  5: ((LAMBDA NIL :IN SWANK:INTERACTIVE-EVAL))
  6: (SWANK::CALL-WITH-RETRY-RESTART "Retry SLIME interactive evaluation request." #<CLOSURE (LAMBDA NIL :IN SWANK:INTERACTIVE-EVAL) {1003E048CB}>)
  7: (SWANK::CALL-WITH-BUFFER-SYNTAX NIL #<CLOSURE (LAMBDA NIL :IN SWANK:INTERACTIVE-EVAL) {1003E048AB}>)
  8: (SB-INT:SIMPLE-EVAL-IN-LEXENV (SWANK:INTERACTIVE-EVAL "(sx 'first t ..)
  9: (EVAL (SWANK:INTERACTIVE-EVAL "(sx 'first t ..)
 10: (SWANK:EVAL-FOR-EMACS (SWANK:INTERACTIVE-EVAL "(sx 'first t ..)
 11: ((LAMBDA NIL :IN SWANK::SPAWN-WORKER-THREAD))
 12: (SWANK/SBCL::CALL-WITH-BREAK-HOOK #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK> #<FUNCTION (LAMBDA NIL :IN SWANK::SPAWN-WORKER-THREAD) {52D2EBEB}>)
 13: ((FLET SWANK/BACKEND:CALL-WITH-DEBUGGER-HOOK :IN "/home/patrick/lisp/lin-portacle/portacle/all/emacsd/elpa/slime-20190716.2022/swank/sbcl.lisp") #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK> #<FUNCTION (LAMBD..
 14: (SWANK::CALL-WITH-BINDINGS ((*STANDARD-INPUT* . #1=#<SWANK/GRAY::SLIME-INPUT-STREAM {1002CD17F3}>) (*STANDARD-OUTPUT* . #2=#<SWANK/GRAY::SLIME-OUTPUT-STREAM {1002DCEFC3}>) (*TRACE-OUTPUT* . #2#) (*ERR..
 15: ((LAMBDA NIL :IN SWANK::SPAWN-WORKER-THREAD))
 16: ((FLET SB-UNIX::BODY :IN SB-THREAD::INITIAL-THREAD-FUNCTION-TRAMPOLINE))
 17: ((FLET "WITHOUT-INTERRUPTS-BODY-4" :IN SB-THREAD::INITIAL-THREAD-FUNCTION-TRAMPOLINE))
 18: ((FLET SB-THREAD::WITH-MUTEX-THUNK :IN SB-THREAD::INITIAL-THREAD-FUNCTION-TRAMPOLINE))
 19: ((FLET "WITHOUT-INTERRUPTS-BODY-1" :IN SB-THREAD::CALL-WITH-MUTEX))
 20: (SB-THREAD::CALL-WITH-MUTEX #<CLOSURE (FLET SB-THREAD::WITH-MUTEX-THUNK :IN SB-THREAD::INITIAL-THREAD-FUNCTION-TRAMPOLINE) {7F804B506D6B}> #<SB-THREAD:MUTEX "thread result lock" owner: #<SB-THREAD:THR..
 21: (SB-THREAD::INITIAL-THREAD-FUNCTION-TRAMPOLINE #<SB-THREAD:THREAD "worker" RUNNING {1003E79A83}> NIL #<CLOSURE (LAMBDA NIL :IN SWANK::SPAWN-WORKER-THREAD) {1003E79A2B}> NIL)
 22: ("foreign function: call_into_lisp")
 23: ("foreign function: new_thread_trampoline")

So it looks like it might be megra installation. The script file didn't seem to do all the git cloning and copying so I redid some of that manually one line at a time to make sure it had worked (but maybe I did something wrong). Is there a simple way to check a) that the sound side is working (I tried scsynth from command line but didn't know whether to use upd or tcp and which port to use. I installed ScIDE but running language->boot server seems to generate error messages in the post window) b) that the correct bits of megra are in the right place?

Paddy

paddywwoof commented 4 years ago

OK, so just going through it step by step I see I get this error on starting portacle.run

Unable to load foreign library (PORTMIDI).
  Error opening shared object "libportmidi.so":

So it looks like I need to add that dependency.

paddywwoof commented 4 years ago

Added libportmidi-dev and libgsl-dev (bit of a gruelling job to find what I need to load for the other dependencies!) and it seems to load and compile without error messages in the top pane. Some warnings during compile but the only thing that looks like it might stop the sound is jack_client_open failure

....
To load "cm":
  Load 1 ASDF system:
    cm
; Loading "cm"

ERROR: jack_client_open failure
WARN: failed to start the realtime thread
To load "closer-mop":
  Load 1 ASDF system:
    closer-mop
; Loading "closer-mop"

But when I try to run the test it can't find SINE function again.

the-drunk-coder commented 4 years ago

Hi @paddywwoof, it's true that the installation process isn't all that convenient right not ... it's my next task down on the list, and in fact it's one of the most tedious ones, bundling everything up in portable manner.

Nonetheless, Portmidi and Gsl are in fact mentioned on the dependency list given in the tutorial.

Anyway, are you using the default file after opening portacle ? Any megra file should start with (in-package :megra). That way, you should be able to find all the Mégra functions.

There probably is a way around this, changing the default package to Mégra, but I need to research that.

The error regarding the JACK client probably means that JACK2 isn't running. If you start JACK2 using qjackctl, cadence, the command line, or any other convenient method to start JACK, you should be able to start Mégra.

paddywwoof commented 4 years ago

Hi, Yes I saw the dependencies but there are already an awful lot already installed on this computer.. without knowing what they're actually called it's not easy to check - so I tend to try running and see what error messages turn up! In the end I painstakingly went through them - so you could add this list to your installation list if you want libsndfile-dev fftw-dev portaudio19-dev libportmidi-dev libgsl-dev graphviz I was entering the code sample you put at the start of chapter01 at the CL-USER> prompt in the lower window but if I enter the code in the top window and/or copy the (in-package :megra) to the lower window I can get it to run without some of the errors (generally I can get ERROR: start sync FIRST-BEEP when running the sx)

But no sound. Jack is running using qjackctl from command line and looks OK - though I get the same jack_client_open failure on startup. Supercollider server is running on localhost and scIDE works, producing sounds when instructed!

the-drunk-coder commented 4 years ago

Thanks for the info, I'll include it !

The most common way to interact with Mégra is by executing the code from the code window (that displays the *.megra file). You might be able to use the REPL (the lower window) directly but it's pretty inconvenient and i wouldn't recommend it. Ideally, move the cursor to the expression you want to evaluate (like the (sx ...) function) and hit CTRL+Return.

The ERROR: start sync message isn't actually an error, jus some historical debug out that I never got around to turn into an INFO message. It's expected and means you successfully executed the code and should hear sound.

Now, if you can't connect to JACK, then there won't be any sound, because that's how event scheduling is handled. If you have scide running and supercollider makes sound, that's somewhat surprising.

So, some points to check:

1.) Is there any log output in QJackCtl's "Message" window ? 2.) Is there any errors in ScIDE's post window ? 3.) Is SuperCollider running at the default port, or are you using a custom port ?

If Mégra starts successfully, you should see a client called "incudine" in QJackCtl's "Graph" window.

paddywwoof commented 4 years ago

qjackctl message window has this when I first run it

15:51:22.974 Statistics reset.
15:51:22.980 ALSA connection change.
15:51:22.987 D-BUS: Service is available (org.jackaudio.service aka jackdbus).
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
15:51:23.102 ALSA connection graph change.

then when I start it

15:52:09.782 D-BUS: JACK server is starting...
15:52:09.869 D-BUS: JACK server was started (org.jackaudio.service aka jackdbus).
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Fri May  1 15:52:09 2020: Starting jack server...
Fri May  1 15:52:09 2020: JACK server starting in realtime mode with priority 10
Fri May  1 15:52:09 2020: self-connect-mode is "Don't restrict self connect requests"
Fri May  1 15:52:09 2020: ERROR: Cannot lock down 82280346 byte memory area (Cannot allocate memory)
Fri May  1 15:52:09 2020: Acquired audio card Audio0
Fri May  1 15:52:09 2020: creating alsa driver ... hw:0|hw:0|1024|2|44100|0|0|nomon|swmeter|-|32bit
Fri May  1 15:52:09 2020: configuring for 44100Hz, period = 1024 frames (23.2 ms), buffer = 2 periods
Fri May  1 15:52:09 2020: ALSA: final selected sample format for capture: 32bit integer little-endian
Fri May  1 15:52:09 2020: ALSA: use 2 periods for capture
Fri May  1 15:52:09 2020: ALSA: final selected sample format for playback: 32bit integer little-endian
Fri May  1 15:52:09 2020: ALSA: use 2 periods for playback
Fri May  1 15:52:09 2020: ERROR: Cannot use real-time scheduling (RR/10)(1: Operation not permitted)
Fri May  1 15:52:09 2020: ERROR: AcquireSelfRealTime error
Fri May  1 15:52:09 2020: graph reorder: new port 'system:capture_1'
Fri May  1 15:52:09 2020: New client 'system' with PID 0
Fri May  1 15:52:09 2020: graph reorder: new port 'system:capture_2'
Fri May  1 15:52:09 2020: graph reorder: new port 'system:playback_1'
Fri May  1 15:52:09 2020: graph reorder: new port 'system:playback_2'
15:52:11.925 JACK connection change.
15:52:11.927 Server configuration saved to "/home/patrick/.jackdrc".
15:52:11.928 Statistics reset.
15:52:11.943 Client activated.
15:52:11.944 Patchbay deactivated.
15:52:12.063 JACK connection graph change.
Cannot lock down 82280346 byte memory area (Cannot allocate memory)
Fri May  1 15:52:11 2020: Saving settings to "/home/patrick/.config/jack/conf.xml" ...
Fri May  1 15:52:11 2020: New client 'qjackctl' with PID 4183

scIDE reports this when I s.boot I don't specify anything else so assume this is the standard port:

Booting server 'localhost' on address 127.0.0.1:57110.
JackDriver: client name is 'SuperCollider'
SC_AudioDriver: sample rate = 44100.000000, driver's block size = 1024
JackDriver: connected  system:capture_1 to SuperCollider:in_1
JackDriver: connected  system:capture_2 to SuperCollider:in_2
JackDriver: connected  SuperCollider:out_1 to system:playback_1
JackDriver: connected  SuperCollider:out_2 to system:playback_2
SuperCollider 3 server ready.
JackDriver: max output latency 46.4 ms
Requested notification messages from server 'localhost'
localhost: server process's maxLogins (1) matches with my options.
localhost: keeping clientID (0) as confirmed by server process.
Shared memory server interface initialized

When I start scIDE it reports a couple of errors

Couldn't set realtime scheduling priority 1: Operation not permitted
Class tree inited in 0.01 seconds
ERROR: A primitive was not bound. 0 734
Instance of Method {    (0x55a0b57df4c0, gc=01, fmt=00, flg=11, set=04)
...
    primitiveName : Symbol '_ScIDE_Connected'
    filenameSymbol : Symbol '/usr/local/share/SuperCollider/SCClassLibrary/scide_scqt/ScIDE.sc'
    charPos : Integer 2661
}
ERROR: Primitive '__none' failed.
Failed.
RECEIVER:
the-drunk-coder commented 4 years ago

Hmm seems like you're lacking real-time privileges on you system ... i'm surprised the ScSynth works that way.

https://jackaudio.org/faq/linux_rt_config.html https://wiki.ubuntu.com/Audio/TheAudioGroup

Basically you have to add your user to the audio group.

paddywwoof commented 4 years ago

Oh well, I tried adding myself to the audio group but it didn't change anything. I tried starting qjackctl as root using sudo but that froze everything - had to press the power button to recover! Maybe it has he same root cause but if I try to start portacle as normal user it seg faults (this seems to happen to other people running it under ubuntu 18.04 but the maintainer doesn't know why) so I have to run it with sudo. But the jack issue crops up before trying to start lisp so it's not the direct cause.

the-drunk-coder commented 4 years ago

Hmm now that i think about it, this might be the root cause ... Mégra needs a real-time thread to do its scheduling, so if jack doesn't allow it to open a real-time client, then that might explait why it doesn't work.

You have to add your user to the audio group AND unlock the respective permissions for that group, that is, the memory limits and real-time priority limits of in limits.conf ... i haven't used ubuntu in a while, so i'm not 100% sure how it works there, but the keywords are 'realtime permissions', 'pam limits' etc ...

Am 1. Mai 2020 21:11:02 MESZ schrieb paddywwoof notifications@github.com:

Oh well, I tried adding myself to the audio group but it didn't change anything. I tried starting qjackctl as root using sudo but that froze everything - had to press the power button to recover! Maybe it has he same root cause but if I try to start portacle as normal user it seg faults (this seems to happen to other people running it under ubuntu 18.04 but the maintainer doesn't know why) so I have to run it with sudo. But the jack issue crops up before trying to start lisp so it's not the direct cause.

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/the-drunk-coder/megra/issues/3#issuecomment-622522307

-- Diese Nachricht wurde von meinem Android-Gerät mit K-9 Mail gesendet.