Superdirt lazy samples loading

Recently (Samples lazy loading · Issue #238 · musikinformatik/SuperDirt · GitHub) a new feature on superdirt was implemented, it permits to avoid loading of the whole sample libraries in memory, and loading every sample the first time it's requested by your tidal code.

To enable it, update superdirt to the last commit (go into the downloaded-quarks/SuperDirt folder then git pull) then, in the superdirt startup code, before any ~dirt.loadSoundFiles call, put a ~dirt.doNotReadYet = true;

I'm using it by default, and my old laptop is happier!
Feedbacks welcome

23 Likes

I haven't tried it yet, but thank you so much for implementing that!

Awesome!

I had to do a

git pull origin develop

by the way. I have tried it for a bit and it seems to be working great. Thank you for implementing this :slight_smile:

1 Like

@th4 @polymorphic.engine
Just for information, that's not an implementation of mine, it was done by @julian (superdirt mantainer), I just did the proposal, debugging and encouragement :smiley:

Thanks for the idea and for helping with the testing @ndr_brt ! It was quite easy to do, so we were lucky …

2 Likes

Just make sure that you use a setter:

~dirt.doNotReadYet_(true)

or

~dirt.doNotReadYet = true
3 Likes

This is huge! Thanks @ndr_brt :slightly_smiling_face:

I run a pretty old machine here too (+10years), it has 16GB of ram but I find superdirt/sc sample loading will often just push it over the edge into swap... which requires meticulous sample set management.

This has made a huge difference to me ... it's made possible the use of some much lower spec machines for teaching/loaning, it's really opened up a lot of possibilities - thanks again :smiley:

edit: one thing I will note, is it doesn't seem to handle missing samples too gracefully now:

ERROR: Message 'at' not understood.
RECEIVER:
   nil
ARGS:
   Symbol 'notYetRead'

PROTECTED CALL STACK:
	Meta_MethodError:new	0x5635fca72b40
		arg this = DoesNotUnderstandError
		arg what = nil
		arg receiver = nil
	Meta_DoesNotUnderstandError:new	0x5635fca74b00
		arg this = DoesNotUnderstandError
		arg receiver = nil
		arg selector = at
		arg args = [ notYetRead ]
	Object:doesNotUnderstand	0x5635fc5cec00
		arg this = nil
		arg selector = at
		arg args = nil
	DirtSoundLibrary:getEvent	0x5635fd3f8000
		arg this = a DirtSoundLibrary
		arg name = lidvox
		arg index = 9.0
		var allEvents = nil
		var event = nil
	DirtEvent:mergeSoundEvent	0x5635fca35cc0
		arg this = a DirtEvent
		var soundEvent = nil
	a FunctionDef	0x5635fca351c0
		sourceCode = "<an open Function>"
	a FunctionDef	0x5635fd813fc0
		sourceCode = "<an open Function>"
	Function:prTry	0x5635fcd09600
		arg this = a Function
		var result = nil
		var thread = a Thread
		var next = nil
		var wasInProtectedFunc = false
	
CALL STACK:
	DoesNotUnderstandError:reportError
		arg this = <instance of DoesNotUnderstandError>
	Nil:handleError
		arg this = nil
		arg error = <instance of DoesNotUnderstandError>
	Thread:handleError
		arg this = <instance of Thread>
		arg error = <instance of DoesNotUnderstandError>
	Object:throw
		arg this = <instance of DoesNotUnderstandError>
	Function:protect
		arg this = <instance of Function>
		arg handler = <instance of Function>
		var result = <instance of DoesNotUnderstandError>
	Environment:use
		arg this = <instance of Event>
		arg function = <instance of Function>
		var result = nil
		var saveEnvir = <instance of Environment>
	DirtEvent:play
		arg this = <instance of DirtEvent>
	OSCFuncBothMessageMatcher:value
		arg this = <instance of OSCFuncBothMessageMatcher>
		arg msg = [*13]
		arg time = 395.80448335991
		arg testAddr = <instance of NetAddr>
		arg testRecvPort = 57120
	OSCMessageDispatcher:value
		arg this = <instance of OSCMessageDispatcher>
		arg msg = [*13]
		arg time = 395.80448335991
		arg addr = <instance of NetAddr>
		arg recvPort = 57120
	Main:recvOSCmessage
		arg this = <instance of Main>
		arg time = 395.80448335991
		arg replyAddr = <instance of NetAddr>
		arg recvPort = 57120
		arg msg = [*13]
^^ The preceding error dump is for ERROR: Message 'at' not understood.
RECEIVER: nil
1 Like

thanks, just commented the issue

1 Like

@BXHD also noticed that synthdefs no longer work with the startup.scd change - haven't had a chance to confirm

1 Like

Unexistent samples stacktrace fixed.
I didn't noticed the synthdefs thing, issue commented.

1 Like

I ran into an issue trying to do the git pull. I initially ran into an error so I tried this:

It then asked me to leave a comment as to why I was merging commits (or something like that). I couldn't figure out how to enter in my comment. I ended up closing the terminal and trying it again and I got a 'fatal error' because of an existing unfinished merge.

Does anyone know what I did wrong?

And thanks, this looks really promising.

I think that's because you weren't on the develop branch. Try to exec git checkout develop then git pull

1 Like

This should be ok now

1 Like

So what happened was there are some changes in your superdirt directory compared to the remote version - hence it requested the merge.

I would do the following:

# cancel the merge
git merge --abort

# reset the state to remote be identical to the remote branch
git reset --hard origin/master

# checkout/switch to the develop branch
git checkout develop
git pull
1 Like

That worked @cleary. Cheers all!

1 Like

There are further issues with synths (and external midi) that @julian has just patched ... knowing your external midi workflow is pretty extensive @ben you will want to update your git:

git status

# make sure it is on the develop branch... if not do a: 
git checkout develop

# fetch and merge latest commits on develop
git pull
1 Like

Ahhhh. Thanks for this!

I indeed got a bunch of errors today so I had to turn off ~dirt.doNotReadYet = true; to get it to work.

I’ll try the new version!

1 Like

Having a bit of trouble with this...keep receiving the same error when i try to do this, not sure what I'm doing wrong here...

Probably you have an old version of superdirt, please try upgrade to 1.7.3