freenode/#lisp - IRC Chatlog
Search
5:11:46
beach
It used to be easy to produce simple sounds on GNU/Linux, but I don't know how to do it anymore. I only need it for some testing purposes, so does anyone know a simple way of producing short sound snippets from, say, SBCL? Specifically, I need to know how to open (and perhaps initialize) a sound device.
5:16:51
beach
But don't get me started on that. I just need to generate a sine wave from Common Lisp and listen to it.
5:17:44
LdBeth
There's a package called alsa-oss provide that device, you'd be able to find it in Ubuntu's package manager
5:20:07
beach
Oh, I guess I could do something like that. Start a program from Common Lisp and pipe things to it. That's what you mean right?
5:21:33
no-defun-allowed
When aplay isn't around, sox also has a `play` tool which needs more context about what's being given to it (as it doesn't default to 8khz/u8/mono), but it's probably more portable.
5:22:28
no-defun-allowed
I used to hate JACK, but I can at least get the latency under 20ms nowadays.
5:22:31
aeth
This could be an interesting low-level Common Lisp project, perhaps? Conventional wisdom would say that a GCed language would be bad at this sort of thing.
5:23:41
no-defun-allowed
My laptop makes enough x-runs without a GCed language. You'd have to be really careful with consing.
5:24:50
no-defun-allowed
AFAIK, to drop down below 10ms-ish, you need a "realtime" Linux kernel which probably switches contexts much faster.
5:27:56
LdBeth
well idon't care much about latency but recently pulseauido just hangs 100% CPU sometimes
5:28:00
beach
Interestingly, CLOSOS could be made to have very fast context switches, since it doesn't need to trap to supervisor mode, doesn't need to remap the address space, and doesn't need to flush the cache.
5:29:09
no-defun-allowed
I was going to bring up that model, actually. The program would effectively be writing to the sound card/DAC/output device itself.
5:30:40
|3b|
there are also tricks with masking off a core or 2, migrating tasks off it, then moving your process onto that core for doing things where linux scheduler is bad, though still need to deal with GC for lisp things
5:31:32
LdBeth
good to hear that, because I didn't figure out how to play proper sound with dev/dsp when I was using FreeBSD
5:31:48
beach
The other thing, of course, is that, since CLOSOS is based on SICL, and SICL has a parallel concurrent GC with a nursery collection taking a few ms at most, the GC would be a problem here.
5:33:59
|3b|
(for files that is, running programs is implementation extension anyway, but pretty sure you can do that there too)
5:34:02
beach
OK, so now I just have to figure out how to run an external program and pipe data to it.
5:35:11
|3b|
ACTION isn't sure which of the portability wrappers let you leave the process running in the background
5:36:01
beach
LdBeth: You assume that I know how to do these things. Not so. I shall have to dig a bit.
5:37:41
LdBeth
A fifo in unix is a named pipe, you create one with mkfifo, and have aplay read it and have common lisp write to the fifo just as writing a regular file
5:41:16
|3b|
yeah, that might be easier, not seeing a way to set element type of streams from run-program
5:53:40
|3b|
ACTION wonders how many currently interesting implementations could be made to reasonably efficiently share memory between specialized arrays of different element types (either using existing displaced array, or something else)
5:55:54
|3b|
not that i have time to investigate, specify, and promote such an extension in either case :/
6:00:55
|3b|
similarly ability to write any type of sequence to ub8 streams as if it were a ub8 sequence would be nice
6:02:03
|3b|
ACTION should probably go back to what i'm actually working on rather than continuing to think about that though
6:18:37
beach
I forget how to write a floating-point value to a stream with element-type double-float.
6:32:43
beach
IT WORKS! So aplay + fifo + RUN-PROGRAM is a workable solution. Thanks LdBeth, no-defun-allowed, |3b|.
6:36:18
no-defun-allowed
and there was a silly celluar automaton-based song "generator" which is quite terrible but still half-impressive i think
6:36:37
beach
|3b|: Good question. When I cat a file to it, it exist after that. But when I do WITH-OPEN-FILE it waits for the next batch of samples.
6:37:23
|3b|
i figure i'd probably do as well with teaching the computer to compose/perform as learning to do it myself, so song generator would be in there too if i ever get to that point
6:38:44
no-defun-allowed
I was half-inspired by http://tones.wolfram.com/ but I didn't have their magic apparently, so the result I have is less impressive.
6:54:57
specbot
Splicing in Modified BNF Syntax: http://www.lispworks.com/reference/HyperSpec/Body/01_daba.htm
6:57:10
|3b|
if you are parsing that sort of thing from CL code, i think alexandria has some functions for that
7:04:59
no-defun-allowed
i think the "my CL is busted, it's making LLVM code" is getting boring, but i got ifs done too https://pastebin.com/pmRWaiXQ
7:09:50
no-defun-allowed
I don't know any FFI, so it's just emitting the textual representation of IR, beach.
7:10:59
no-defun-allowed
The existing cl-llvm library doesn't work without some modification, because it was written for an older LLVM (I think version 3).