[directmusic] Re: Creating, downloading and unloading segments with DirectMusic

  • From: "Vytautas Leonavicius" <vytas@xxxxxxxxxxxxx>
  • To: <directmusic@xxxxxxxxxxxxx>
  • Date: Sat, 3 Jul 2004 20:27:02 +0300

Thank you for your reply.

I am not going to load them all at once. I am just trying to determine - how 
many files it is safe to have opened at once. The problem is that I should 
choose some magic number, say, 100, and manage loaded segments. But who 
could guarantee that this will work on other machine? What is that magic 
number for all machines?

The files I am opening are small in  length - ~1 - 3 sec. Based  on DirectX 
audio book - they will be not streamed, but read into memory...

But the most weird and interesting thing for me - what is relationship 
between loader, and downloading? As you could see from my previous emails, I 
tested everything lots of times, and noticed rule: more segments loaded from 
files - less segments could be downloaded onto performance. Why these two 
things affect each other? I don't see any relationships between them.

Another question, what AutoDownload global performance parameter does? In 
docs it's said "autodownloads bands". But I am not using bands, I just 
create segments from wave files. Then I enabled this flag, my segments play 
well without downloading. What's happening with this flag enabled? Is 
segment downloaded/unloaded each time it is playing? If so it is very 
expensive if DM do not uses some wise strategy. Documentation says "do not 
use where segment timing is critical?" As I understood, this means that 
segment could start playing a bit later with autodwnloading enabled? Or 
autodownloading slows down WHOLE application using it?
Autodownload solved a part of problem - because I don't need to download 
segments, I do not encounter bad return values. All segments are playing 
well, but is this good solution for big app.? If I will manage 
download/unload myself I will magic number again, how many? As I noticed 
that depends on size of segments.

My application is not crashing. But I get return code I mentioned. It is 
saying nothing about the problem. I could interpret that return value as 
signal to free/unload something, but is this a good way to do that?

Vytautas
----- Original Message ----- 
From: "Todor Fay" <todor@xxxxxxxxxxxxx>
To: <directmusic@xxxxxxxxxxxxx>
Sent: Saturday, July 03, 2004 6:52 PM
Subject: [directmusic] Re: Creating, downloading and unloading segments with 
DirectMusic


> This may be an issue with file handles. If the waves are over a certain
> length, dmusic opens them in streamed mode and keeps the file handles
> open so it can read from disk while playing them. Unfortunately, Windows
> has a limit of how many file handles it can allow open at one time. The
> solution would be to change these files into non-streaming (and I know
> that can be done in Producer as well as possibly via the api - but I
> forget how.) Or, don't open so many files at once, since you can't
> possibly plan to play them all at the same time!
>
> But, you say "crash" as opposed to "error". Is the program actually
> crashing or failing to load the file?
>
> Hope this helps,
>
> Todor
>
> -----Original Message-----
> From: directmusic-bounce@xxxxxxxxxxxxx
> [mailto:directmusic-bounce@xxxxxxxxxxxxx] On Behalf Of Vytautas
> Leonavicius
> Sent: Sunday, July 04, 2004 8:10 AM
> To: directmusic@xxxxxxxxxxxxx
> Subject: [directmusic] Re: Creating, downloading and unloading segments
> with DirectMusic
>
> My problem get narrowed to IDirectMuscicLoader only.
>
> I created big list of files, and try to load them at startup just for
> test.
> No audiopaths, no performances are created, just
> IDirectMusicLoader::LoadObjectFromFile. After loading approximately ~400
>
> small (90kb) sounds loader crashes with MUS_E_LOADER_FAILEDOPEN return
> value.
>
> Here are words from directX audio exposed:
>
> "Segment
> A Segment represents any playable audio. It might be a MIDI or wave
> file, or
> it might be a DirectMusic Segment file authored in DirectMusic Producer.
> You
> can load any number of Segments from disk, and you can play any number
> of
> them at the same time. You can even play the same Segment multiple times
>
> overlapping itself."
>
> But for me this is not true - even more, loader's crashes are somehow
> related to manual downloading of segments.
>
> I could manage segments and throw out least used to load other, the
> problem
> is HOW MANY OF THEM IT IS SAFE TO HAVE AT ONCE? Return value is saying
> nothing about some resource exhaustion.
>
> BTW - I had same error when I tried to do everything with DMP scripts.
> When
> scripts get large enough - they crashed at load. Sometimes they crashed
> with
> same return value.
>
> I also tried to disable Loader's cache - this don't solved the problem.
>
> Do wave files have some GUIDs?
>
> Vytautas
>
> ----- Original Message ----- 
> From: "Vytautas Leonavicius" <vytas@xxxxxxxxxxxxx>
> To: <directmusic@xxxxxxxxxxxxx>
> Sent: Saturday, July 03, 2004 3:15 PM
> Subject: [directmusic] Creating, downloading and unloading segments with
>
> DirectMusic
>
>
>> Hello Group,
>> I'll be very thankful for any help, cause I really need it.
>>
>> I am developing sound subsystem in our game. It uses DirectMusic API.
> I
>> got lots of troubles with DirectMusic, so I begin to suspect that the
> main
>> problem is in my wrong model of using DirectMusic. I addition to lack
> of
>> information on that's going on inside DM, I got stuck finally.
>>
>> I started this way - I loaded all segments from files based on list of
>
>> filenames. Later, I downloaded them all onto performance. The problem
> was
>> with download - it failed if too many sounds were downloaded.  Then I
>> introduced some kind of cache, that managed all segments, and unloaded
>
>> least useful, while downloading new ones. That worked. For some time.
>> Later, I faced another problem. Instead of creating all segment files
> at
>> startup, I created them on first use. After this modfication, I found
> that
>> now I am able to download much more segments than prior to that! So,
> looks
>> like IDirectMusicLoader and IDirectMusicSegment::Download, affect each
>
>> other - the less segments you load from file, the more segments
> downloaded
>> onto performance successfully and vice versa.
>> Another weird thing, is that both loader and segment downloading fail
> with
>> same return value. : DMUS_E_LOADER_FAILEDOPEN File open failed because
> the
>> file does not exist or is locked. From above, looks like
>> CreateSegmentFromFile and Download affect some shared memory or
> resource,
>> however, return value is saying nothing about memory etc.
>>
>> So it looks like I am doing something wrong, cause while searching
> forums,
>> I found no topics with similar problems.
>>
>> When should I create segments from wave files? Should I destroy/create
>
>> them again during runtime, and that's more important, how many of them
>
>> could be created at once, without being afraid of crash?  When should
> I
>> download and unload them? Is DMUS_E_LOADER_FAILEDOPEN saying: "too
> many
>> segments created, release some then retry"?
>>
>> Another problem is with audiopaths. I am using separate audiopath per
> each
>> sound with separate volume. And I noticed, that even if I don't use
>> audiopaths, just create them, they slow down application. I suppose
> I'll
>> going to implement some audiopath sharing between sounds, however,
> what is
>> 'too many audiopaths"? How many audiopaths are allowed without
> noticeable
>> perfromance penalty?
>>
>> Weird thing, I don't know how many segments are allowed to be created
> from
>> file at once, I don't know how many of them could be downloaded at
> once,
>> and same thing with audiopaths. In DM documentation no single word
> about
>> all these things...
>>
>> Vytautas
>>
>
>
>
>
>
> 



Other related posts: