Need for command to reset all ! settings to default
My recent work with the sonic-pi-cli has thrown up again the need for an easy way to reset all ! functions like set_sched-ahead_time! and set_volume! to their default values.
If you are playing remotely files one after another and you stop between them, then you may have a volume or sched time setting from one file that is carried across to the next when it is not wanted. I can add a function to reset all these values at the start of every program, and then override those that need these settings adjusted, but it tedious to have to do this. One problem is that the defaults for Pi and Mac are different, so you need an OS test as well! For these reasons I think a built in command would be useful.
I did suggest and give code before for a command reset! but you didn't like the name.
Can this be looked at again?
Hi Robin,
yep, we definitely do need a reset! fn. However, I'm a bit loathe to add it to the current implementation as it would be quite messy to maintain. I already have plans for it in v3.0 which hopefully should be ready to play with before the summer.
Until then I do plan on adding a namespace functionality to allow you to create separate libraries of code which won't clash with other people's libs. This will then allow you to create your own helper fns to implement your own reset!. I'll hopefully have namespace support in v2.5.
Ok fair enough. Got a headless Sonic Pi jukebox going now, controlled by telegram. Gives a dynamically generated index of sonic pi tunes and you choose what you want to play by number. Had a tedious time putting set_sched_ahead_time! and set_volume! into each one appropriate for the file, to compensate for the few that needed these non standard. Hence the grouse above :-)
The simple solution for use with sonic-pi-cli and telegram was to get the interface program to send reset commands before every file via the cli. That way none of the files have to be changed, and it doesn't matter if they alter pling values.
This is related to #241 and #1831. Perhaps we need some 'untouchable' global state which can only be masked with calls to set_* and not changed. Once we remove/undo global set changes with something like reset!, the original 'untouchable' values would then be visible again.
Sort-of related to this (but probably a different function?), would it also make sense to have a way to reset the Time State?
Some pieces may rely on state being nil at the start, but if other things have been played beforehand that might not be the case. Being able to clear any previous state at the start would help to ensure the same code always sounds the same independently of any previous state.