Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am preparing sounds system to my game in xna. I am using XACT Tools, and i got problem.

There is class SoundCategory. I can change sound level for all sounds in that category easily.

SoundCategory category = engine.GetCategory("music");
category.SetVolume(float_value);

But there is no such function like:

category.AddVolume(float_value);

Which would increase or deacrease that value. There is also no function that get current volume so i can do thing like:

float vol = category.Add(float_value);
vol += 0.1;
category.SetVolume(vol);

Is there some clever way to achive what i want without creating some additional variables which keep current volume for all sounds categories ?

share|improve this question
    
What's wrong with storing one variable holding the volume? –  The Communist Duck Jun 5 '11 at 16:53
1  
@Duck the problem is the inital value. What value will that be? Crappy API IMHO –  Maik Semder Jun 5 '11 at 16:56
    
@Maik Semder I assume it would be 0. –  The Communist Duck Jun 5 '11 at 17:19
    
@Duck that means the sound-designer can't set that value in its sound-project, or if s/he does anyway, the values are out of sync. –  Maik Semder Jun 5 '11 at 17:26
    
It IS a crappy API. This might be out of scope for what Skotnik wants. But what I would do is make sure that I've got a hold of the .XAP and parse that for initial settings of everything that isn't available in the api. You could make a pre-build step that parses the XAP and pulls out relevant information into an XML file then add that to the Content project so you can deserialize it into an AudioCategoryInfo object or something. –  michael.bartnett Jun 6 '11 at 5:30

2 Answers 2

up vote 1 down vote accepted

I think you can get volume from category, beacouse various sound in this category can have various volumes. When you set volume for category, you set the same for all.

share|improve this answer

I suspect what you are trying to implement is a slider control in your game that allows the user to select the SFX volume and the Music volume independently.

Assuming that's the case, whatever volume the user picks IS the value you set in .SetVolume(float); For example, every time the Music Volume slider changes, it changes a float variable from 0.0 to 1.0 and at that time, you call .SetVolume(sliderValue); If you are trying to implement an Up/Down volume control which moves in increments, you don't need to add .05f to the current sound, you need to always know what it was before (storing the volume value outside the SoundCategory).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.