GameOfLife / Unit-Lib

The Unit Library is a system that provides high level abstractions on top of the SuperCollider language.
25 stars 6 forks source link

Sometimes starting a unit is taking a lot of time. #2

Closed miguel-negrao closed 12 years ago

miguel-negrao commented 12 years ago

( x = DiskSndFile(Platform.resourceDir +/+ "sounds/a11wlk01.wav"); y = U(\diskSoundfile,[\soundFile, x]); UChain(y, \output).gui )

bench{ y.prepare(s) } time to run: 0.42901564400017 seconds.

bench{ y.start(s) } time to run: 0.87287230099992 seconds. 0.87287230099992 late 0.688585972 late 0.688585972

Specifying the target cuts the time in half: bench{ y.start(s) } time to run: 0.43069267400006 seconds. 0.43069267400006 late 0.244571431

woutersnoei commented 12 years ago

Typo: \diskSoundfile should be \diskSoundFile

( x = DiskSndFile(Platform.resourceDir +/+ "sounds/a11wlk01.wav"); y = U(\diskSoundFile,[\soundFile, x]); UChain(y, \output).gui )

bench{ y.prepare(s) } time to run: 0.00044149399991511 seconds.

bench{ y.start(s) } time to run: 0.00052955599994675 seconds.

I think it was trying to load a \diskSoundfile udef from disk, finding \diskSoundFile instead (apparently case-insensitive), but every time the U was prepared it found that the name of it's udef didn't correspond with its key, therefore loaded it again. This is the only way to explain this strange behaviour. We should probably make some kind of error detection mechanism for this, as it might drive people wild (like it did me and you :-) )

miguel-negrao commented 12 years ago

Ouch... you mean it can't distinguish between a file named diskSoundfile.scd and diskSoundFile.scd ?? That's a nasty bug.

woutersnoei commented 12 years ago

but what should it do? Should we ignore case, and correct the defName to the actual case of the loaded def? Or should we be strict, and let it post a "not found" message in this case?

miguel-negrao commented 12 years ago

I think we should be strict and say it's not found.

woutersnoei commented 12 years ago

hmm, not so easy. The case insensitivity seems to be system wide. Not sure how to check if a file really exists..

File.exists( Udef.createDefFilePath( Udef.defsFolders[0], \bufSoundFile) ) -> true File.exists( Udef.createDefFilePath( Udef.defsFolders[0], \bufSoundfile) ) -> also true File.exists( Udef.createDefFilePath( Udef.defsFolders[0], \bufSoundfil) ) -> false

woutersnoei commented 12 years ago

Ok, I pushed a fix for this. It is a bit hacky but it works. Also check the comments. Now it will break when you try to use a non-existing udef.

Perhaps a better solution still would be to allow U's with no udef, but give warnings about them in the post window. But it's quite some work to figure out on what places we'd need to change things for that. So for now; it just breaks. The chances of this happening via gui are minimal, it's only a code thing.

miguel-negrao commented 12 years ago

ok, at least it doesn't cause misterious issues. We'll fix it for good when we "upgrade" to 3.5. I've also commited the fix to the prepare thing and the new specs.