aboutsummaryrefslogtreecommitdiffhomepage
path: root/applause.c
AgeCommit message (Collapse)AuthorFilesLines
2024-05-20detect libreadline via pkg-configRobin Haberkorn1-1/+0
2024-01-12minor FreeBSD compatibility fixes and documentationRobin Haberkorn1-1/+2
2023-11-16improved interruption (SIGINT, CTRL+C) supportRobin Haberkorn1-32/+67
* Just like the original LuaJIT interpreter, this will use a hook to automatically raise an error from Lua code. * Unfortunately, as long as Jit compilation is enabled, this cannot reliably work. Therefore we still set an `interrupted` flag that must be polled from tight loops. * Instead of polling via applause_push_sample() which gave interruption-support only to Stream:play(), we now have a separate checkint() function. * checkint() should be manually added to all tight loops. * Stream:foreach() and everthing based on it is now also supporting interruptions (via checkint()). * This internally works via applause_is_interrupted(). A C function was exposed only because LuaJIT does not support volatile-qualifiers and would optimize away reads to the interrupted-flag. As a side effect, we can also reset the hook. * Flags set in signal handlers should be `volatile`. * Added likely() and unlikely() macros to C code. * Updated sample.ipynb Jupyter notebook: Everything important is now supported, albeit requiring custom ILua patches.
2023-11-12support running scripts in batch modeRobin Haberkorn1-38/+65
* This should be largely compatible with the standard Lua interpreter. The `arg` array is also initialized.
2023-09-05moved common definitions into applause.hRobin Haberkorn1-7/+1
2023-09-05MIDI stuff has been moved into midi.luaRobin Haberkorn1-2/+2
* common definitions are now in midi.h
2023-09-05Added HID support via EvdevRobin Haberkorn1-0/+1
* This works for relative, absolute and keyboard devices * devices can be grabbed, so they do not interfere with the rest of the system
2017-10-21Fix crashes on terminationRobin Haberkorn1-2/+3
* some internal datastructures were freed, but Jack was not properly shut down. This resulted in occasional crashes on shutdown. * The (incomplete) cleanup code has been commented out, which should work for the time being. Of course, the program should clean up properly but this is tedious and the internal datastructures will change in the forseeable future.
2017-01-26revised MIDI supportRobin Haberkorn1-182/+49
* introduced MIDIStream which provides a raw stream of MIDI messages (mangled into a single integer). * MIDIVelocityStream has been replaced by MIDIStream:mvelocity() * MIDICCStream has been replaced by MIDIStream:CC() * MIDIStreams can be directly passed to DSSIStreams
2016-08-02options are now passed in POSIX style (ie. -o and -b)Robin Haberkorn1-7/+25
command line help is provided using -h or when specifying an unknown option
2016-01-26allow client connections to be terminated prematurelyRobin Haberkorn1-0/+63
* use socat now for SciTECO integration. It correctly shuts down the connection when interrupted. This has the effect as cancelling the current command, just as ^C would on the Applause command line.
2016-01-25fixed command server: unterminated stringRobin Haberkorn1-1/+2
2016-01-25multi-channel stream supportRobin Haberkorn1-105/+158
* This is implemented without introducing the notion of frames into the tick() methods since most multi-channel stream operations can be understood as duplicating the operation on each channel. * Instead there is only ONE explicitly multi-channel stream: MuxStream. It can be used to construct a multi-channel stream from various normal mono streams and is also used internally. * MuxStreams can still be used just like any other stream since the new base class MuxableStream will automatically apply the class constructors on each channel in order. The channels of streams being combined must be equal, unless mono streams are involved. * Mono-streams are automatically blown-up to multi-channel streams when involved in operations with a multi-channel stream. * The remaining multi-channel specific code has been isolated in Stream:foreach() which now receives frames instead of individual samples. * When playing() a multi-channel stream, the applause output ports are played in order. I.e. playing a mono-stream fills output_1. A stereo stream, output_1 and output_2. * The number of Jack output ports can be specified on the applause command line. * All system playback ports are tried to be connected to corresponding applause output ports.
2016-01-12added history support: it is saved in .applause_history of the current ↵Robin Haberkorn1-3/+17
working directory
2016-01-07improve error messages in case loading applause.lua failsRobin Haberkorn1-4/+8
2016-01-07use the LuaJIT FFI interface for the MIDI streamsRobin Haberkorn1-51/+57
* should speed up things since the C function calls can be inlined * the C function does only rudimentary argument checking using assert() since they are only called internally. This means, calling it with wrong arguments can result in controlled crashes. This will point to programming errors since the real argument checking is done in Lua code at stream construction. * The MIDI*Stream.getValue() functions have been kept as wrappers around the native functions, to ease using them in other stream implementations that want to support MIDI natively.
2016-01-05flush LuaJIT compiled code cache before executing commandsRobin Haberkorn1-0/+14
2016-01-05rewritten Stream:play() as a Lua functionRobin Haberkorn1-104/+43
* the low-level C part is now implemented in a normal C function applause_push_sample() which is called using the FFI API * this is supposedly faster than the old Lua/C way, but the speed improvement seems to be miniscule. However changes like this are still good since they simplify the C core. * speed improvements will probably be larger for the MIDI*Stream functions since here we call Lua/C functions at sample rate.
2016-01-04added a simple server functionality and some SciTECO macros to interface itRobin Haberkorn1-39/+211
* the server is basically a second way to modify the Lua state of Applause * concurrently to interactive input, messages can be sent over a TCP socket which are evaluated just like command lines. All stdout/stderr output is returned and the socket is closed. * Server currently hardcoded at 127.0.0.1:10000 * Interruptions are currently not possible. This would require another thread. * The threading could be simplified by making the applause binary a server-only application. The Read-Eval-Print loop could then be a standalone LuaJIT script.
2016-01-04support the "=" shortcut at the beginning of lines (to print expressions) ↵Robin Haberkorn1-3/+48
and print stack tracebacks
2016-01-03SyncedStream optimization: Allow streams to be reused within one stream ↵Robin Haberkorn1-5/+26
graph without recomputation * Since it comes with an overhead, it has to be enabled by constructing a SyncedStream or calling Stream:sync() * Reusing samples works by sharing generator functions and caching samples until a clock signal changes. The clock signal is currently a global variable "clock_signal" that oscillates between true and false. * This means that all sample generating methods like :play() or :totable() will have to advance the clock using the global clockCycle() function. It is a global function, so it can be invoked more or less efficiently by the :play() implementation (currently using the old-school Lua/C API). These restrictions might fall when using the LuaJIT way of interacting with native code. * Since playback must begin from the beginning for every :play(), an explicit reset() mechanism has been introduced which can usually be ignored in Stream implementations. It does however allow SyncedStream to reset the generator closure. * SndfileStream has been simplified since now it is possible to keep the file handle open. However as long as Stream synchronization is not automatic, SndfileStreams must be explicitly synced when using one stream multiple times. * Syncing is thought to be performed automatically by an optimizer when one object is used more than once e.g. in a :play() call. * Non-synced streams are currently slightly slower than before this commit, probably because of the additional clockCycle() call.
2016-01-03preliminary (broken) client forking supportRobin Haberkorn1-8/+89
2015-12-31support only LuaJIT and use some additional (insignificant) optimizationsRobin Haberkorn1-0/+8
2015-12-31fixed potential segfaults in MIDI processing & 1-based channelsRobin Haberkorn1-11/+18
* there are at most 128 different MIDI notes; mtof() will now also work for all of them * channels have origin 1 now in the public APIs. This is what most applications seem to use, so in order to avoid confusion it's probably a good idea to use it as well.
2015-12-31implemented basic support for MIDI NOTE ON/OFF eventsRobin Haberkorn1-28/+126
* MIDIVelocityStream will report the velocities on a particular note. This can be used to build polyphonic instruments. * MIDINoteStream will report all possible notes on a particular channel. The velocity of the note last triggered is also encoded into the stream values. This can be used to build simple monophonic instruments. * Map bit methods to stream methods, e.g. Stream:band() Is especially useful for streams that encode multiple values into single integers for performance reasons. * mtof() and ftom() methods for converting from and to MIDI note numbers. mtof() is very efficient since its values are all precalculated in a lookup table. * fixed tostring() method for streams smaller than 1024 samples
2015-11-04added simple support for MIDI CC commandsRobin Haberkorn1-2/+121
* MIDICCStream provides a stream of CC values as if polled from the controller (this is emulated in applause.c)
2015-11-03enforce minimum buffer size for lua<->realtime communication based on ↵Robin Haberkorn1-2/+17
jack_get_buffer_size()
2015-11-03fixed semaphore for realtime<->lua thread synchronizationRobin Haberkorn1-8/+16
2015-11-03allow Stream:play() to be interrupted by CTRL+CRobin Haberkorn1-1/+35
* more precisely, Stream:play() will now throw an error whenever the process receices SIGINT. * this allows us to interrupt long playbacks
2015-11-03ring buffer size is configurable now via ./applause command-line parameter ↵Robin Haberkorn1-9/+32
in milliseconds * default buffer size: 100ms
2015-11-03synchronize buffer access via System V semaphoreRobin Haberkorn1-10/+74
* allows the Lua thread to block when the ringbuffer is full while keeping the realtime thread (jack_process()) realtime-safe. Hopefully :-) * since audio generation is usually faster than consumption (if you don't want to have buffer underruns), this fixes audio generation longer than BUFFER_SIZE (currently 1s)
2015-11-03report buffer underrunsRobin Haberkorn1-6/+23
2015-04-11stop garbage collector temporarily during play()Robin Haberkorn1-1/+16
This improves the real-time properties of sample generation since it avoids CPU spkikes. On the other hand, this may not be ideal as playing a long streams could have non-constant space requirements now. A proper solution would probably involve calling the garbage collector incrementally during the play() loop.
2015-04-11added custom interactive Lua interpreter for evaluating applause expressionsRobin Haberkorn1-0/+274
* implements Stream:play() using Jack as the audio backend