Player and expansion communication......
-
@David-Healey --- havent even considered that, any way you want.
-
@Lindon said in Player and expansion communication......:
@David-Healey state is simply "open" or "closed" (0 or 1) for every library (which has categories in it) and Categories(which have instruments in them)
State needs to be transferable BOTH ways so we start with all libs closed....
In the player we open LibA, open CatA and load InstrumentAA
InstrumentAA opens and displays the LibPanel with all libs closed except LibA, and within that CatA is also open...
In instrumentAA we close LibA and Open LibB, then we close InstrumentAA,
The player opens with all libs closed except LibB
The problem(well theres a truck load of problems..) here is I can see how I can save state (in some file) and read it on plugin(player) load...and as soon as the user requests a load of an instrument we write the current states to the file.
The instrument reads this state file on load and sets the display correctly. On instrument unload (so the instrument is unloading itself) the instrument saves the new state(assuming its changed) and unloads itself.....
..but I dont know how the player now reads this new state file in any efficient manner- meaning not running a timer every 0.5 seconds to re-read the state file......???
The player never knows the instrument is now unloaded does it? Or can it tell from
ExpansionHandler.getCurrentExpansion() if it == "" then whatever it loaded is now unloaded... ???
Or how is the player itself loading/unloading whilst a Full Instrument is in play? I guess I need to know the mechanics of player/instrument load/unload ....do we execute init again? ...@Christoph-Hart !!!
-
@Lindon If you set the current expansion to "" that will trigger the unload action, so you can respond to that. I'm not sure if that reruns the player's
on initbut you could test.I think a timer and polling on the message thread is the way to go, the timer won't run when the interface is minimised anyway.
-
@David-Healey said in Player and expansion communication......:
@Lindon If you set the current expansion to "" that will trigger the unload action, so you can respond to that. I'm not sure if that reruns the player's
on initbut you could test.I think a timer and polling on the message thread is the way to go, the timer won't run when the interface is minimised anyway.
Yeah its the expansion that will be setting the current expansion to "" - so I'm not sure how the player responds to that....I cant see a expansion changed callback or listener...
-
@Lindon said in Player and expansion communication......:
cant see a expansion changed callback
ExpansionHandler.setExpansionCallback()Not sure if it works in this scenario the way you need but give it a try. -
Long time that I worked on this, but setting an empty expansion in a full player plugin should get you back to the shell - it's onInit callback should be compiled too again.
-
@Christoph-Hart said in Player and expansion communication......:
Long time that I worked on this, but setting an empty expansion in a full player plugin should get you back to the shell - it's onInit callback should be compiled too again.
Im not sure I understand what you mean, no actually I clearly dont understand what you mean....
I load the player - its init executes,
I load an Full instrument expansion from the player - its init executes
I unload the instrument, from within the instrument, the player reloads.... does its init execute? Or does it some how magically retain its own state ? -
@Lindon said in Player and expansion communication......:
does its init execute?
We think yes but try it and see
-
@David-Healey Ok will do but assuming YES...
Problem #2:
Just before I unload I save a file....so this:
myFile.saveObject(myJSON); myExpansionHandler.getCurrentExpansion("");What happens?
Is the file save async? or better still blocking?
is it running in a differnt thread?
will it even happen?
Will it get aborted?
How will I know when its finished? -
@Lindon or do I have to do this....
myFile.saveObject(myJSON); runSomeShittyTimerToDoTheUnload();As you may surmise - I dont find it "elegant"
-
@Lindon Pretty sure it's synchronous because it's calling JUCE's
replaceWithTextfunction and returning a bool.So you could probably do something like
if (f.writeObject(myJson)) unloadTheExpansion