[X3D-Public] MIDI node was X3D for Web Authors Examples Archive, plus audio test scene of different sound formats

Michalis Kamburelis michalis.kambi at gmail.com
Tue Dec 24 21:09:23 PST 2013


Don Brutzman wrote:
> On 12/12/2013 10:59 AM, Michalis Kamburelis wrote:
>> Don Brutzman wrote:
>>> - it requires multiple retrievals of the souncd file since both url
>>> and pitch are controlled by AudioClip
>>
>> That is why view3dscene can cache by URLs, so multiple AudioClips with
>> the same url load their resources only once :) Each one can still have
>> individual pitch.
>
> Very nice.  But of course for this to work, you have to keep track of http headers and decide to reload or not.  Remote files may change over time - perhaps even frequently for news and announcements - so care must be taken when caching to recheck that a remote resource hasn't changed.  Browsers handle this process well.

(Sorry for delay in answering. Only holidays allow me to catch up with 
emails :)

Yes, the correct behaviour is to implement proper cache on disk, and 
follow http headers to refresh the cache when needed and only when 
needed. view3dscene does not do that *yet* --- as we cache the resources 
only in the memory, and cache disappears if you reload the whole scene, 
so it's only a temporary cache anyway. (Our cache was done originally to 
avoid multiple reads of the same local file.)

While our cache is far from perfect, the gains are quite huge. There are 
many scenes using the same URLs e.g. for textures or inlines (without 
using DEF/USE to share actual nodes). For AudioClip, it's not even 
sensible, as DEF/USE for AudioClip nodes is unfortunately a little 
useless (see 
http://castle-engine.sourceforge.net/x3d_implementation_sound.php#section_def_use 
). Avoiding redownloading the same resources when the URLs are equal is 
quite a large gain in these cases, both for memory and loading speed.

> Michalis, if you (or others) have done this kind of thing already in your player, please advise on the details.  We should document this technique on the website - there may be several alternative approaches.  Thanks in advance for all help.

view3dscene simply keeps a cache with reference counts. If the URLs are 
equal, the cache is reused. When the reference count drops to zero then 
resource is released (and will be redownloaded next).

It's not perfect (we both agree that doing what the WWWW browsers do, 
following http spec, is the real way). But, like I mentioned, it's much 
better than not caching at all --- the gains from such simple cache are 
really large on some scenes.

Regards,
Michalis



More information about the X3D-Public mailing list