January 27, 2014 at 2:36 am #18507
Hi, this is my code for requesting patch names from Prophet08:
-- Create a coroutine in order to wait getting patch name before insertion in table GetPatchName = coroutine.create(function() for patch_number = 0, 127 do Receive_request_program_dump(0,patch_number) coroutine.yield(x) console ("Inserting patch name in table") Bank1PatchesTable[patch_number] = PatchName end end) coroutine.resume(GetPatchName)
Everything works fine, but I want to create a message to inform the user about the dump progress and tried this :
DumpProgress = AlertWindow.showMessageBoxAsync(AlertWindow.InfoIcon, "Patch dump", "Patch 0 of 256", "Cancel") GetPatchName = coroutine.create(function() for patch_number = 0, 127 do Receive_request_program_dump(0,patch_number) coroutine.yield(x) console ("Inserting patch name in table") Bank1PatchesTable[patch_number] = PatchName RealPatchNumber = patch_number + 1 DumpProgress:setMessage("Patch "..RealPatchNumber.." of 256") end DumpProgress:~AlertWindow() end) coroutine.resume(GetPatchName)
SetMessage doesn’t work to change AlertWindow message and compilation failed with the command “~AlertWindow()”. I don’t know how to achieve it… Any help would be very appreciated.January 27, 2014 at 9:07 am #18512
I’ll have a look why AlertWindow is not working (i know it was when i was writing it, but maybe something changed in JUCE and broke it)
One thing is 100% you can’t call ~AlertWindow(), this is the destructor of that class, all the lifetime of those classes is controlled in C++ or by the Lua’s garbage collector, don’t do that.
Also this won’t really do what you want, this is all done on one thread (the main GUI thread) so you won’t see any updates in the AlertWindow cause Lua will be blocking it with whatever you are doing, you’d need a new thread or the specialized class in JUCE called (ThreadWithProgressWindow) to do this stuff. It’s not implemented because threading lua and Ctrlr might cause loads of issues.
I’ll try to figure this out so we can make progress indicators for lengthy operations (this sort of stuff is partially implemented in the new program manager so hopefuly it won’t be needed, but i’ll think about it)January 27, 2014 at 5:37 pm #18534
Thanks Atom, maybe a solution would be to open an AlertWindow for each patch loaded and to close it each time a new patch is loaded. I understand now why I can’t use ~AlertWindow(), is there an other way to programmaticaly close the window (without waiting for user to click “ok”)?January 27, 2014 at 6:50 pm #18537
Well in theory calling exitModalState on the AlertWindow object should make it exit (since AlertWindow is a Component object). But i haven’t tested it yet, i’ll get back to you on that.January 27, 2014 at 6:53 pm #18538
I also noticed you are using coroutines, theese are run on different thread. Without locking using different threads will cause unexpected results and crashes all over the place. Please remember that.February 3, 2014 at 10:53 pm #18873
Yes I use coroutines to stop program dump loop until midi message is received and treated by other function. It works well so far.
I tried to use exitModalState but it doesn’t work. But I finally found a better solution by displaying current loaded patch name and number in the panel lcd display.
- The forum ‘Programming’ is closed to new topics and replies.