diff --git a/crone/osc-methods.txt b/crone/osc-methods.txt index 076742d37..22f51b3c7 100644 --- a/crone/osc-methods.txt +++ b/crone/osc-methods.txt @@ -78,9 +78,6 @@ osc methods: /softcut/buffer/clear_channel [i] /softcut/buffer/clear_region [ff] /softcut/buffer/clear_region_channel [iff] - /softcut/buffer/render [iffi] - /softcut/buffer/process [iff] - /softcut/buffer/return [iff] /softcut/reset [] /set/param/cut/phase_quant [if] /set/param/cut/phase_offset [if] diff --git a/crone/src/BufDiskWorker.cpp b/crone/src/BufDiskWorker.cpp index 3958e976f..e0377af1c 100644 --- a/crone/src/BufDiskWorker.cpp +++ b/crone/src/BufDiskWorker.cpp @@ -5,7 +5,6 @@ //----------------------- //-- debugging -#include #include #include #include @@ -14,15 +13,7 @@ #include #include #include -#include #include -// ------------------- -// for shared memory -#include -#include -#include -#include -// ------------------- #include "BufDiskWorker.h" @@ -37,14 +28,12 @@ std::array BufDiskWorker::bufs; int BufDiskWorker::numBufs = 0; bool BufDiskWorker::shouldQuit = false; int BufDiskWorker::sampleRate = 48000; -int BufDiskWorker::fd = -1; // clamp unsigned int to upper bound, inclusive static inline void clamp(size_t &x, const size_t a) { if (x > a) { x = a; } } - int BufDiskWorker::registerBuffer(float *data, size_t frames) { int n = numBufs++; bufs[n].data = data; @@ -108,16 +97,6 @@ void BufDiskWorker::requestRender(size_t idx, float start, float dur, int sample requestJob(job); } -void BufDiskWorker::requestProcess(size_t idx, float start, float dur, ProcessCallback processCallback) { - BufDiskWorker::Job job{BufDiskWorker::JobType::Process, {idx, 0}, "", start, start, dur, 0, 0, 0, 1, false, 0, nullptr, processCallback }; - requestJob(job); -} - -void BufDiskWorker::requestPoke(size_t idx, float start, float dur, DoneCallback doneCallback) { - BufDiskWorker::Job job{BufDiskWorker::JobType::Poke, {idx, 0}, "", start, start, dur, 0, 0, 0, 1, false, 0, nullptr, nullptr, doneCallback}; - requestJob(job); -} - void BufDiskWorker::workLoop() { while (!shouldQuit) { Job job; @@ -156,11 +135,6 @@ void BufDiskWorker::workLoop() { case JobType::Render: render(bufs[job.bufIdx[0]], job.startSrc, job.dur, (size_t)job.samples, job.renderCallback); break; - case JobType::Process: - process(bufs[job.bufIdx[0]], job.startSrc, job.dur, job.processCallback); - break; - case JobType::Poke: - poke(bufs[job.bufIdx[0]], job.startSrc, job.dur, job.doneCallback); } #if 0 // debug, timing auto ms_now = duration_cast(system_clock::now().time_since_epoch()).count(); @@ -168,22 +142,18 @@ void BufDiskWorker::workLoop() { std::cout << "job finished; elapsed time = " << ms_dur << " ms" << std::endl; #endif } - shm_unlink("BufDiskWorker_shm"); } void BufDiskWorker::init(int sr) { sampleRate = sr; - // don't really love using this as a magic word, - // but I also don't love passing it around. - fd = shm_open("BufDiskWorker_shm", O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR); if (worker == nullptr) { worker = std::make_unique(std::thread(BufDiskWorker::workLoop)); worker->detach(); } } -size_t BufDiskWorker::secToFrame(float seconds) { - return static_cast(seconds * (float) sampleRate); +int BufDiskWorker::secToFrame(float seconds) { + return static_cast(seconds * (float) sampleRate); } float BufDiskWorker::raisedCosFade(float unitphase) { @@ -634,62 +604,3 @@ void BufDiskWorker::render(BufDesc &buf, float start, float dur, size_t samples, callback(window, start, samples, sampleBuf); delete[] sampleBuf; } - -void BufDiskWorker::process(BufDesc &buf, float start, float dur, ProcessCallback processCallback) { - size_t frStart = secToFrame(start); - if (frStart > buf.frames - 1) { return; } - - size_t frDur; - if (dur < 0) { - frDur = buf.frames - frStart; - } else { - frDur = secToFrame(dur); - } - clamp(frDur, buf.frames - frStart); - - if (fd == -1) { - std::cerr << "BufDiskWorker::process(): opening shared memory failed" << std::endl; - return; - } - size_t size = sizeof(float) * frDur; - if (ftruncate(fd, size) == -1) { - // can't process the whole buffer, so let's just give up - std::cerr << "BufDiskWorker::process(): resizing shared memory failed" << std::endl; - return; - } - float *BufDiskWorker_shm = (float *)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - if (BufDiskWorker_shm == MAP_FAILED) { - // again, just give up - std::cerr << "BufDiskWorker::process(): mapping shared memory failed" << std::endl; - return; - } - for (size_t i = 0; i < frDur; ++i) { - BufDiskWorker_shm[i] = buf.data[frStart]; - frStart++; - } - processCallback(frDur); -} - -void BufDiskWorker::poke(BufDesc &buf, float start, float dur, DoneCallback doneCallback) { - size_t frDur = secToFrame(dur); - size_t frStart = secToFrame(start); - clamp(frDur, buf.frames - frStart); - if (fd == -1) { - // just give up - std::cerr << "BufDiskWorker::poke(): opening shared memory failed" << std::endl; - return; - } - size_t size = sizeof(float) * frDur; - float *BufDiskWorker_shm = (float *)mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0); - if (BufDiskWorker_shm == MAP_FAILED) { - // just give up - std::cerr << "BufDiskWorker::poke(): mapping shared memory failed" << std::endl; - return; - } - for (size_t i = 0; i < frDur; ++i) { - buf.data[frStart] = BufDiskWorker_shm[i]; - frStart++; - } - std::cerr << "calling doneCallback" << std::endl; - doneCallback(0); -} diff --git a/crone/src/BufDiskWorker.h b/crone/src/BufDiskWorker.h index 2d77839ae..c400392df 100644 --- a/crone/src/BufDiskWorker.h +++ b/crone/src/BufDiskWorker.h @@ -28,15 +28,13 @@ namespace crone { class BufDiskWorker { public: typedef std::function RenderCallback; - typedef std::function ProcessCallback; - typedef std::function DoneCallback; private: enum class JobType { Clear, ClearWithFade, Copy, ReadMono, ReadStereo, WriteMono, WriteStereo, - Render, Process, Poke + Render, }; struct Job { JobType type; @@ -52,8 +50,6 @@ namespace crone { bool reverse; int samples; RenderCallback renderCallback; - ProcessCallback processCallback; - DoneCallback doneCallback; }; struct BufDesc { float *data; @@ -69,10 +65,9 @@ namespace crone { static bool shouldQuit; static constexpr int sleepPeriodMs = 100; static int sampleRate; - static int fd; static constexpr int ioBufFrames = 1024; - static size_t secToFrame(float seconds); + static int secToFrame(float seconds); static float raisedCosFade(float unitphase); static float mixFade(float x, float y, float a, float b); @@ -85,7 +80,6 @@ namespace crone { static void requestJob(Job &job); public: - // initialize with sample rate static void init(int sr); @@ -121,12 +115,6 @@ namespace crone { static void requestRender(size_t idx, float start, float dur, int count, RenderCallback callback); - // process portion of buffer using custom function - static void requestProcess(size_t idx, float start, float dur, ProcessCallback processCallback); - - // return contents of buffer produced by custon function - static void requestPoke(size_t idx, float start, float dur, DoneCallback doneCallback); - private: static void workLoop(); @@ -153,10 +141,6 @@ namespace crone { float start = 0, float dur = -1) noexcept; static void render(BufDesc &buf, float start, float dur, size_t samples, RenderCallback callback); - - static void process(BufDesc &buf, float start, float dur, ProcessCallback processCallback); - - static void poke(BufDesc &buf, float start, float dur, DoneCallback doneCallback); }; } diff --git a/crone/src/OscInterface.cpp b/crone/src/OscInterface.cpp index 43897c5ed..ef78bba0c 100644 --- a/crone/src/OscInterface.cpp +++ b/crone/src/OscInterface.cpp @@ -4,7 +4,6 @@ // Created by ezra on 11/4/18. // -#include #include #include @@ -799,23 +798,6 @@ void OscInterface::addServerMethods() { }); }); - addServerMethod("/softcut/buffer/process", "iff", [](lo_arg **argv, int argc) { - if (argc < 2) return; - softCutClient->processBuffer(argv[0]->i, argv[1]->f, argv[2]->f, - [=](size_t size) { - lo_send(matronAddress, "/softcut/buffer/do_process", "i", size); - }); - }); - - addServerMethod("/softcut/buffer/return", "iff", [](lo_arg **argv, int argc) { - if (argc < 3) return; - int ch = argv[0]->i; - softCutClient->pokeBuffer(ch, argv[1]->f, argv[2]->f, - [=](int jobType){ - lo_send(matronAddress, "/softcut/buffer/done_callback", "ii", ch, jobType); - }); - }); - addServerMethod("/softcut/query/position", "i", [](lo_arg **argv, int argc) { if(argc < 1) return; int idx = argv[0]->i; diff --git a/crone/src/SoftcutClient.h b/crone/src/SoftcutClient.h index 184d96256..beee79942 100644 --- a/crone/src/SoftcutClient.h +++ b/crone/src/SoftcutClient.h @@ -108,16 +108,6 @@ namespace crone { if (chan < 0 || chan > 1 || count < 1) { return; } BufDiskWorker::requestRender(bufIdx[chan], start, dur, count, callback); } - - void processBuffer(int chan, float start, float dur, BufDiskWorker::ProcessCallback callback) { - if (chan < 0 || chan > 1) { return; } - BufDiskWorker::requestProcess(chan, start, dur, callback); - } - - void pokeBuffer(int chan, float start, float dur, BufDiskWorker::DoneCallback doneCallback) { - if (chan < 0 || chan > 1) { return; } - BufDiskWorker::requestPoke(chan, start, dur, doneCallback); - } // check if quantized phase has changed for a given voice bool checkVoiceQuantPhase(int i) { diff --git a/crone/wscript b/crone/wscript index c3f76ae64..d735d4906 100644 --- a/crone/wscript +++ b/crone/wscript @@ -62,6 +62,5 @@ def build(bld): 'm', 'sndfile' ], - cxxflags=crone_flags, - ldflags=['-lrt'] + cxxflags=crone_flags ) diff --git a/lua/core/norns.lua b/lua/core/norns.lua index 7460b8aca..1e418cf32 100644 --- a/lua/core/norns.lua +++ b/lua/core/norns.lua @@ -88,9 +88,6 @@ _norns.vu = function(in1, in2, out1, out2) end _norns.softcut_phase = function(id, value) end _norns.softcut_render = function(ch, start, sec_per_sample, samples) end -_norns.softcut_process = function(sample_index, current_value) return 0 end -_norns.softcut_do_process = function() end -_norns.softcut_done = function(ch, job_type) end _norns.softcut_position = function(i,pos) end -- default readings for battery diff --git a/lua/core/softcut.lua b/lua/core/softcut.lua index 199483149..f2bcc070b 100644 --- a/lua/core/softcut.lua +++ b/lua/core/softcut.lua @@ -13,7 +13,6 @@ local SC = {} local controlspec = require 'core/controlspec' -local clock = require 'clock' ------------------------------- -- @section constants @@ -381,51 +380,12 @@ SC.render_buffer = function(ch, start, dur, samples) _norns.cut_buffer_render(ch, start, dur, samples) end ---- request that softcut process buffer with user-defined process function --- usage: clock.run(softcut.process_buffer(ch, start, dur, sleep_time, block_size)) --- @tparam integer ch : buffer channel index (1-based) --- @tparam number start : beginning of region in seconds --- @tparam number dur : length of region in seconds --- @tparam number sleep_time : amount of time to wait between blocks in seconds; default 0.2 --- @tparam integer block_size : number of samples per block; default 1024 -SC.process_buffer = function(ch, start, dur, sleep_time, block_size) - if not sleep_time or sleep_time < 0 then sleep_time = 0.2 end - if not block_size or block_size <= 0 then block_size = 1024 end - start = start or 0 - dur = dur or -1 - return function() - _norns.softcut_do_process = function() end - _norns.cut_buffer_process(ch, start, dur) - while true do - for i = 1, block_size do - if _norns.softcut_do_process() then goto done end - end - clock.sleep(sleep_time) - end - ::done:: - _norns.cut_buffer_return(ch, start, dur) - _norns.softcut_do_process = function() end - end -end - --- set function for render callback. use render_buffer to request contents. -- @tparam function func : called when buffer content is ready. args: (ch, start, sec_per_sample, samples) SC.event_render = function(func) _norns.softcut_render = func end ---- set function for processing of buffer. use process_buffer to apply. --- @tparam function func : called when buffer content is processed. args: (sample_index, current_value) -SC.process_func = function(func) - _norns.softcut_process = func -end - ---- set function for job callback. called when process_buffer is complete. --- @tparam function func : called when buffer job is complete. args: (ch, job_type, num_to_expect) -SC.event_done = function(func) - _norns.softcut_done = func -end - --- query playback position -- @tparam integer i : which softcut voice SC.query_position = function(i) _norns.cut_query_position(i) end @@ -445,14 +405,6 @@ end function SC.reset() _norns.cut_reset() SC.event_phase(norns.none) - SC.event_render(norns.none) - SC.event_done(norns.none) - SC.process_func(function(_,_) return 0 end) - if _norns.cut_process_clock then - clock.cancel(_norns.cut_process_clock) - _norns.cut_process_clock = nil - end - _norns.softcut_do_process = function() end end --- get the default state of the softcut system @@ -463,7 +415,7 @@ end -- NB: these values are synchronized by hand with those specified in the softcut cpp sources -- @treturn table table of parameter states for each voice function SC.defaults() - local zeros = {} + zeros = {} for i=1,SC.VOICE_COUNT do zeros[i] = 0 diff --git a/matron/src/event_types.h b/matron/src/event_types.h index 942a10a7d..45429e267 100644 --- a/matron/src/event_types.h +++ b/matron/src/event_types.h @@ -92,10 +92,6 @@ typedef enum { EVENT_CUSTOM, // monome grid tilt EVENT_GRID_TILT, - // softcut done callback - EVENT_SOFTCUT_CALLBACK, - // softcut process chunk - EVENT_SOFTCUT_PROCESS, } event_t; // a packed data structure for four volume levels @@ -327,17 +323,6 @@ struct event_softcut_render { float* data; }; -struct event_softcut_process { - struct event_common common; - size_t size; -}; - -struct event_softcut_callback { - struct event_common common; - int idx; - int job_type; -}; - struct event_softcut_position { struct event_common common; int idx; @@ -389,8 +374,6 @@ union event_data { struct event_crow_event crow_event; struct event_system_cmd system_cmd; struct event_softcut_render softcut_render; - struct event_softcut_process softcut_process; - struct event_softcut_callback softcut_callback; struct event_softcut_position softcut_position; struct event_custom custom; }; diff --git a/matron/src/events.c b/matron/src/events.c index 69f5d8c7a..1d7f1d5fc 100644 --- a/matron/src/events.c +++ b/matron/src/events.c @@ -308,15 +308,9 @@ static void handle_event(union event_data *ev) { case EVENT_SOFTCUT_RENDER: w_handle_softcut_render(ev->softcut_render.idx, ev->softcut_render.sec_per_sample, ev->softcut_render.start, ev->softcut_render.size, ev->softcut_render.data); break; - case EVENT_SOFTCUT_CALLBACK: - w_handle_softcut_done_callback(ev->softcut_callback.idx, ev->softcut_callback.job_type); - break; case EVENT_SOFTCUT_POSITION: w_handle_softcut_position(ev->softcut_position.idx, ev->softcut_position.pos); break; - case EVENT_SOFTCUT_PROCESS: - w_handle_softcut_process(ev->softcut_process.size); - break; case EVENT_CUSTOM: w_handle_custom_weave(&(ev->custom)); break; diff --git a/matron/src/oracle.c b/matron/src/oracle.c index bddd447f4..4527d211e 100644 --- a/matron/src/oracle.c +++ b/matron/src/oracle.c @@ -10,14 +10,12 @@ */ #include -#include -#include -#include #include #include #include #include +#include #include "args.h" #include "events.h" @@ -115,12 +113,6 @@ static int handle_poll_softcut_phase(const char *path, const char *types, lo_arg static int handle_softcut_render(const char *path, const char *types, lo_arg **argv, int argc, lo_message data, void *user_data); -static int handle_softcut_process(const char *path, const char *types, lo_arg **argv, int argc, - lo_message data, void *user_data); - -static int handle_softcut_callback(const char *path, const char *types, lo_arg **argv, int argc, - lo_message data, void *user_data); - static int handle_softcut_position(const char *path, const char *types, lo_arg **argv, int argc, lo_message data, void *user_data); @@ -193,8 +185,6 @@ void o_init(void) { // softcut buffer content lo_server_thread_add_method(st, "/softcut/buffer/render_callback", "iffb", handle_softcut_render, NULL); - lo_server_thread_add_method(st, "/softcut/buffer/do_process", "i", handle_softcut_process, NULL); - lo_server_thread_add_method(st, "/softcut/buffer/done_callback", "ii", handle_softcut_callback, NULL); lo_server_thread_add_method(st, "/poll/softcut/position", "if", handle_softcut_position, NULL); lo_server_thread_start(st); @@ -616,14 +606,6 @@ void o_cut_buffer_render(int ch, float start, float dur, int samples) { lo_send(crone_addr, "/softcut/buffer/render", "iffi", ch, start, dur, samples); } -void o_cut_buffer_process(int ch, float start, float dur) { - lo_send(crone_addr, "/softcut/buffer/process", "iff", ch, start, dur); -} - -void o_cut_buffer_return(int ch, float start, float dur) { - lo_send(crone_addr, "/softcut/buffer/return", "iff", ch, start, dur); -} - void o_cut_query_position(int i) { lo_send(crone_addr, "/softcut/query/position", "i", i); } @@ -853,25 +835,6 @@ int handle_softcut_render(const char *path, const char *types, lo_arg **argv, in return 0; } -int handle_softcut_process(const char *path, const char *types, lo_arg **argv, int argc, - lo_message data, void *user_data) { - assert(argc > 0); - union event_data *ev = event_data_new(EVENT_SOFTCUT_PROCESS); - ev->softcut_process.size = argv[0]->i; - event_post(ev); - return 0; -} - -int handle_softcut_callback(const char *path, const char *types, lo_arg **argv, int argc, - lo_message data, void *user_data) { - assert(argc > 1); - union event_data *ev = event_data_new(EVENT_SOFTCUT_CALLBACK); - ev->softcut_callback.idx = argv[0]->i; - ev->softcut_callback.job_type = argv[1]->i; - event_post(ev); - return 0; -} - int handle_softcut_position(const char *path, const char *types, lo_arg **argv, int argc, lo_message data, void *user_data) { assert(argc > 1); diff --git a/matron/src/oracle.h b/matron/src/oracle.h index 1594f918b..ef181c8a4 100644 --- a/matron/src/oracle.h +++ b/matron/src/oracle.h @@ -144,8 +144,6 @@ extern void o_cut_buffer_read_stereo(char *file, float start_src, float start_ds extern void o_cut_buffer_write_mono(char *file, float start, float dur, int ch); extern void o_cut_buffer_write_stereo(char *file, float start, float dur); extern void o_cut_buffer_render(int ch, float start, float dur, int samples); -extern void o_cut_buffer_process(int ch, float start, float dur); -extern void o_cut_buffer_return(int ch, float start, float dur); extern void o_cut_query_position(int i); extern void o_cut_reset(); // most softcut parameter changs take single voice index... diff --git a/matron/src/weaver.c b/matron/src/weaver.c index a3a82c4b1..0c83169b3 100644 --- a/matron/src/weaver.c +++ b/matron/src/weaver.c @@ -47,10 +47,6 @@ #include "system_cmd.h" #include "weaver.h" -// for shared memory -#include -#include - // registered lua functions require the LVM state as a parameter. // but often we don't need it. // use pragma instead of casting to void as a workaround. @@ -60,9 +56,6 @@ //------ //---- global lua state! static lua_State *lvm; -//----- -//---- global shared memory file descriptor. -static int fd = -1; void w_run_code(const char *code) { l_dostring(lvm, code, "w_run_code"); @@ -234,9 +227,6 @@ static int _cut_buffer_read_stereo(lua_State *l); static int _cut_buffer_write_mono(lua_State *l); static int _cut_buffer_write_stereo(lua_State *l); static int _cut_buffer_render(lua_State *l); -static int _cut_buffer_process(lua_State *l); -static int _cut_buffer_do_process(lua_State *l); -static int _cut_buffer_return(lua_State *l); static int _cut_query_position(lua_State *l); static int _cut_reset(lua_State *l); static int _set_cut_param(lua_State *l); @@ -349,8 +339,6 @@ static void lua_register_norns_class(const char *class_name, const luaL_Reg *met //// extern function definitions void w_init(void) { - fprintf(stderr, "accessing shared memory"); - fd = shm_open("BufDiskWorker_shm", O_RDWR, 0); fprintf(stderr, "starting main lua vm\n"); lvm = luaL_newstate(); luaL_openlibs(lvm); @@ -421,8 +409,6 @@ void w_init(void) { lua_register_norns("cut_buffer_write_mono", &_cut_buffer_write_mono); lua_register_norns("cut_buffer_write_stereo", &_cut_buffer_write_stereo); lua_register_norns("cut_buffer_render", &_cut_buffer_render); - lua_register_norns("cut_buffer_process", &_cut_buffer_process); - lua_register_norns("cut_buffer_return", &_cut_buffer_return); lua_register_norns("cut_query_position", &_cut_query_position); lua_register_norns("cut_reset", &_cut_reset); lua_register_norns("cut_param", &_set_cut_param); @@ -594,9 +580,6 @@ void w_post_startup(void) { } void w_deinit(void) { - fprintf(stderr, "releasing shared memory"); - // don't love using magic words... - shm_unlink("BufDiskWorker_shm"); fprintf(stderr, "shutting down lua vm\n"); lua_close(lvm); } @@ -2452,40 +2435,6 @@ void w_handle_softcut_render(int idx, float sec_per_sample, float start, size_t l_report(lvm, l_docall(lvm, 4, 0)); } -void w_handle_softcut_done_callback(int idx, int type) { - lua_getglobal(lvm, "_norns"); - lua_getfield(lvm, -1, "softcut_done"); - lua_remove(lvm, -2); - switch (type) { - case 0 : - lua_pushinteger(lvm, idx + 1); - lua_pushstring(lvm, "process"); - break; - default : - luaL_error(lvm, "invalid job type"); - } - l_report(lvm, l_docall(lvm, 2, 0)); -} - -void w_handle_softcut_process(size_t size) { - if (fd == -1) { - fprintf(stderr, "error accessing softcut shared memory"); - return; - } - void *BufDiskWorker_shm = mmap(NULL, size * sizeof(float), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - if (BufDiskWorker_shm == MAP_FAILED) { - fprintf(stderr, "error mapping softcut shared memory"); - return; - } - lua_getglobal(lvm, "_norns"); - lua_pushlightuserdata(lvm, BufDiskWorker_shm); - lua_pushinteger(lvm, size); - lua_pushinteger(lvm, 0); - lua_pushcclosure(lvm, &_cut_buffer_do_process, 3); - lua_setfield(lvm, -2, "softcut_do_process"); - lua_pop(lvm, 1); -} - void w_handle_softcut_position(int idx, float pos) { lua_getglobal(lvm, "_norns"); lua_getfield(lvm, -1, "softcut_position"); @@ -2843,52 +2792,6 @@ int _cut_buffer_render(lua_State *l) { return 0; } -int _cut_buffer_process(lua_State *l) { - lua_check_num_args(3); - int ch = (int)luaL_checkinteger(l, 1) - 1; - float start = (float)luaL_checknumber(l, 2); - float dur = (float)luaL_checknumber(l, 3); - o_cut_buffer_process(ch, start, dur); - return 0; -} - -int _cut_buffer_return(lua_State *l) { - lua_check_num_args(3); - int ch = (int)luaL_checkinteger(l,1) -1; - float start = (float)luaL_checknumber(l, 2); - float dur = (float)luaL_checknumber(l, 3); - o_cut_buffer_return(ch, start, dur); - return 0; -} - -int _cut_buffer_do_process(lua_State *l) { - float *shm_buffer = (float *)lua_topointer(l, lua_upvalueindex(1)); - size_t size = (size_t)lua_tointeger(l, lua_upvalueindex(2)); - size_t index = (size_t)lua_tointeger(l, lua_upvalueindex(3)); - if (index > size) { - lua_pushboolean(l, 1); - return 1; - } - lua_getglobal(l, "_norns"); - lua_getfield(l, -1, "softcut_process"); - lua_remove(l, -2); - lua_pushinteger(l, index); - lua_pushnumber(l, shm_buffer[index]); - l_report(l, l_docall(l, 2, 1)); - if (!lua_isnumber(l, -1)) { - fprintf(stderr, "softcut_process did not return number for input %d, %f", (int)index, shm_buffer[index]); - shm_buffer[index] = 0; - } else { - shm_buffer[index] = (float)lua_tonumber(l, -1); - } - lua_pop(l, 1); - index++; - lua_pushinteger(l, index); - lua_replace(l, lua_upvalueindex(3)); - lua_pushnil(l); - return 1; -} - int _cut_query_position(lua_State *l) { lua_check_num_args(1); int i = (int)luaL_checkinteger(l, 1) - 1; diff --git a/matron/src/weaver.h b/matron/src/weaver.h index 54a9e4395..48d0b8723 100644 --- a/matron/src/weaver.h +++ b/matron/src/weaver.h @@ -86,8 +86,6 @@ extern void w_handle_poll_wave(int idx, uint8_t *data); extern void w_handle_poll_io_levels(uint8_t *levels); extern void w_handle_poll_softcut_phase(int idx, float val); extern void w_handle_softcut_render(int idx, float sec_per_sample, float start, size_t size, float* data); -extern void w_handle_softcut_done_callback(int idx, int type); -extern void w_handle_softcut_process(size_t size); extern void w_handle_softcut_position(int idx, float pos); extern void w_handle_engine_loaded(); diff --git a/matron/wscript b/matron/wscript index e8142655d..b98e9fca8 100644 --- a/matron/wscript +++ b/matron/wscript @@ -103,4 +103,4 @@ def build(bld): use=matron_use, lib=matron_libs, cflags=matron_cflags, - ldflags=['-Wl,-export-dynamic,-lrt']) + ldflags=['-Wl,-export-dynamic'])