aboutsummaryrefslogtreecommitdiffhomepage
path: root/applause.lua
AgeCommit message (Collapse)AuthorFilesLines
2016-01-25added DupMux() function and Stream:dupmux() methodRobin Haberkorn1-7/+19
These are useful whenever a single-channel stream should be muxed into multi-channel stream (e.g. mono to stereo signal)
2016-01-25added brown and pink noise streamsRobin Haberkorn1-3/+79
* benchmark() has been inmproved. * added Stream:benchmark()
2016-01-25multi-channel stream supportRobin Haberkorn1-87/+331
* 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-12make applause.lua reloadable using the reload() global functionRobin Haberkorn1-3/+18
2016-01-12fixed memory leaking in Stream:play() due to garbage collector disablingRobin Haberkorn1-10/+11
2016-01-12added Stream:foreach(), Stream:pipe() and Stream:gnuplot() methodsRobin Haberkorn1-20/+52
* Stream:foreach() is also useful on the command line. It is used to apply a function to all samples of a stream as fast as possible. Some existing methods have been simplified using foreach() * an alternative to foreach() would be to use Streams exclusively to introduce side-effects into sample processing and provide a simple method like sink() to fetch all samples as fast as possible. Other methods like save() could then be simple wrappers
2016-01-07use the LuaJIT FFI interface for the MIDI streamsRobin Haberkorn1-12/+47
* 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/+5
2016-01-05rewritten Stream:play() as a Lua functionRobin Haberkorn1-13/+70
* 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-04fixed stream resetting for the IndexStream and filter streamsRobin Haberkorn1-19/+26
* all sub-substreams must now be in the `streams` attribute
2016-01-04major class system revision: Support :instanceof(), dedicated ctor() methods ↵Robin Haberkorn1-74/+156
and construction using the Class() idiom * Class:instanceof() deprecates several fields like is_azipstream; is_a_stream is still useful * Constructors are now defined as ordinary methods (looks better) * every object and class table now has a `base` field that points to the base class since getmetatable() will no longer point to the base table/class. * Objects can be constructed both using Class:new() and Class(). The old behaviour of stream() for serialization is used less frequently. * Streams can be serialized using the Stream:eval() method. I don't think that the object system should be tweaked even more to support different metamethods for class tables and objects as it is quite convoluted already.
2016-01-04allow constructors to return other things than class instancesRobin Haberkorn1-3/+3
* could be used to introduce classes like SinOsc that are simply shortcuts for some higher order stream (just like Stream.SinOsc is currently) but can be instantiated consistently using SinOsc:new().
2016-01-04added RepeatStream: allows you to repeat some stream for a number of times ↵Robin Haberkorn1-0/+33
(or infinitely) * this currently also works for very long streams without precalculating stuff * On the other hand, after each iteration the target stream must be reinitialized. This is not safe in generator functions (FIXME).
2016-01-03fixed optimizations for multiple consecutive arithmetic operatorsRobin Haberkorn1-18/+16
* we have to make sure that exactly the same function values are used
2016-01-03SyncedStream optimization: Allow streams to be reused within one stream ↵Robin Haberkorn1-59/+121
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-1/+33
2015-12-31support only LuaJIT and use some additional (insignificant) optimizationsRobin Haberkorn1-2/+2
2015-12-31fixed potential segfaults in MIDI processing & 1-based channelsRobin Haberkorn1-6/+10
* 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-2/+92
* 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-0/+21
* MIDICCStream provides a stream of CC values as if polled from the controller (this is emulated in applause.c)
2015-11-03fixed ZipStream for non-stream operands (like numbers)Robin Haberkorn1-1/+2
2015-05-03changed semantics of the __call metamethod: create VectorStreamRobin Haberkorn1-18/+25
* the call metamethod is most useful in compositions in order to evaluate a stream to save computing power at runtime. * this meant that in addition to adding () to a stream expression it was necessary to convert the table to a stream (e.g. using tostream()). * Now the totable() method converts to a pure table, while __call returns a VectorStream. This means it will be sufficient to add "()" in order to evaluate a stream eagerly
2015-04-30added Stream.save() and SndfileStream based on FFI wrapper around libsndfileRobin Haberkorn1-0/+56
2015-04-30use LuaJIT's FFI instead of lposix library for clock_gettime()Robin Haberkorn1-5/+33
2015-04-30added RavelStream and minor changes to make streams of non-numbers possibleRobin Haberkorn1-5/+68
2015-04-28optimizations, scalar operations and ZipStream as an abstraction of stream ↵Robin Haberkorn1-138/+211
operations
2015-04-20resample() and toplot() methodsRobin Haberkorn1-0/+49
2015-04-20added bit-crusher effectRobin Haberkorn1-0/+6
2015-04-20filters: handle input streams shorter than the frequency streamRobin Haberkorn1-18/+24
2015-04-20filtering: handle frequency streams short than the input streamRobin Haberkorn1-4/+16
2015-04-20added filter streams adapted from ChucK and revised wave form functionsRobin Haberkorn1-19/+373
* LPF, HPF, BPF, BRF filters are 2nd order Butterworth filters. Derived verbatim from ChucK's implementation. This can probably be optimized by caching the tan/cos functions. Also, they do not yet handle frequency streams shorter than the stream to filter. * Basic wave forms are now Stream methods to allow concatenative style of FM synthesis (or LFOs). To generate e.g. a sine wave with constant frequency, you can still write Stream.SinOsc(440); or tostream(440):SinOsc()
2015-04-11added custom interactive Lua interpreter for evaluating applause expressionsRobin Haberkorn1-1/+1
* implements Stream:play() using Jack as the audio backend
2015-04-09additional useful stream operationsRobin Haberkorn1-13/+54
2015-04-07replaced co-routine based implementation with closuresRobin Haberkorn1-72/+153
* this improves performance by 10 times (both lua5.1 and luajit) * also, when using luajit, there appears to be little peformance loss when using stream compositions instead of maps (which are sometimes even slower!?)
2015-04-07initial commit based on coroutinesRobin Haberkorn1-0/+462