Silent fall

Discuss Chaos Strikes Back for Windows and Linux, an unofficial port of Chaos Strikes Back to PC by Paul Stevens, as well as CSBuild, an associated dungeon editor.

Moderator: Zyx

Forum rules
Please read the Forum rules and policies before posting.
User avatar
cowsmanaut
Moo Master
Posts: 4378
Joined: Fri Jun 30, 2000 12:53 am
Location: canada

Post by cowsmanaut »

My initial request :
I'm assuming you desire to refrain from DirectX is not rooted in a deep hatred for M$ but for purley compatability reasons... so under that assumption.. Would it not be possible to just have a button that says "do you want enhanced sounds 'yes' 'no'" and then let the code for sounds be rerouted through a secondary program.. some kind of evil directX sound library.. this providing the option of those on the mac also to take advantage of this by writing an equivilent library or whatever to translate the sounds to be blended as well.
this is essentally what you've done no complaints here. My thought was simply that you were not understanding why it wasn't working on your side. Now that you say you thought it would do all of this automatically. I'm sorry I didn't understand this is what you wanted. Since my above suggestion was a check box so that called to outside code. This way it would be something small on a Mac or Linux and seperate not integral. And manual for those who don't have Direct X or don't want it or don't have the right version.

Ryan mentioned that he thinks you might have a very early version of DX on your win 95 system since it does everything else but play the sounds.. Which again brings in the need for it to be manual.

as for the Dr. Watson.. I'll leave that to him.. I will say that from personal experience.. the longer a win 98 system has been running the less stable it gets and sometimes needs it's DLL's refreshed. I used to do it every 6 months. I've heard others say that win98 had a habit of corrupting Dll's overtime. just a suggestion.

Anyway, I'm very sorry to hear about your tooth. I know how horrible that can feel. I've had 3 root canals. I had taken a face dive from my bike when I was a kid and killed the roots of a few teeth and they eventually festered but I didn't know untill massive pain hit me many years later like 6 years later.. :(

I dunno.. Ryan is still plodding away at the code here and there. so perhaps he'll have some suggestions too. Thanks for the feedback.

moo
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

Great. All is well. And my own comment:
I want anyone who can
run NotePad to be able to run CSBwin
Reminds me that I never did like the .RAR files.
Nobody is going to unpack one of those with NotePad.
I will be converting the files on my 'Index of DB/CSB'
to self-extracting .EXE files so as to more nearly
practice what I preach.
User avatar
ChristopheF
Encyclopedist
Posts: 1544
Joined: Sun Oct 24, 1999 2:36 pm
Location: France
Contact:

Post by ChristopheF »

I use RAR because of the better compression ratio it offers over ZIP, and because there is a free decompression tool for nearly every major OS. I know it can be a pain for users, but there would be far less content on my site without that.

I don't think making self extracting .exe files is a good idea for people who do not use windows, especially for a multi platform program like CSBwin. Even if it may help users running windows (most people in fact), it may also prevent users of other OS to use the dungeons.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

Hi, Christophe:

I only intend to do that for the CSBwin packages
for Windows. Does that make sense? The CSBwin
packages for macintosh or Linux will be packaged
in whatever the authors believe will be easiest for
a novice user on their respective systems.

In fact, I was hoping that some other people might jump
in and put together some of the packages. Especially
their own creations. Since they
have not, I think I will fall back and only put in the
games that can be played on Windows with CSBwin. As the
first exception, I will leave the games that are already
packaged for the PC, especially DM and CSB. But in
the future I will only post PC and other games if they are
provided for me already packaged.
User avatar
cowsmanaut
Moo Master
Posts: 4378
Joined: Fri Jun 30, 2000 12:53 am
Location: canada

Post by cowsmanaut »

YAY! it works wonderfully.. I can hear the door opening as I'm running into it.. UUUF!! HAHAHAHA!

It was as good a test as any :)

moo
User avatar
cowsmanaut
Moo Master
Posts: 4378
Joined: Fri Jun 30, 2000 12:53 am
Location: canada

Post by cowsmanaut »

ok.. here is what Ryan and my pondering came up with regarding the Watson error.

I too get an error when one or more sounds have been played through the code and it's shut down. However I do not get it if I turn off the DX option after playing a few sounds and then play at least one sound through your code.

So, the conclusion is.. the call to "Win32_SoundMixer_Shutdown" is not occuring or not occuring at the right time. So since it's never uninitialized you get the error.

Did you make sure the call was made before shut down or upon turning off the directX code (check box) ?

only thing he can think of at the moment.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

Thanks for the information/testing/discoveries.

I certainly thought that I shut it down. I have a
global instance of a class that does all the DirectX
calls and its destructor calls your Shutdown()
procedure. But, of course, it is always more complicated
than that. I'll look into it. You may have provided the
needed clue.
Ryan

Post by Ryan »

I could change the design of the code so that the static object does the proper shutdown at program exit. Right now the static object will release the IDirectSound object if it exists since that's its job. I'm used to an external object owning the 'SoundMixer' class instead of it having the flat interface it does.

If you'd like it to be a class that you can new, then call Play() on then when you delete it it does the shutdown just let me know. For some reason I assumed a flat API would be better.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

I would prefer the class object. I had to create my own.
Mine kept flags indicating whether initialization had been
attempted and whether there was failure in initialization so that
I could call it unconditionally each time a sound was to
be played. Because I did not know how much overhead your
initialization required. And the destructor called Shutdown
if initialization had succeeded. At least that was the intent.
I have not gone back to study it since Cowsmanaut sent me
the results of his test.

So I play a sound like this:

Code: Select all


class PLAYSOUND;

bool UI_PlaySound(char *wave)
{
  if (PLAYSOUND.Initialize(hWnd)) PLAYSOUND.Play(wave);
  else   *** the original Windows API method ***
}
User avatar
beowuuf
Archmastiff
Posts: 20687
Joined: Sat Sep 16, 2000 2:00 pm
Location: Basingstoke, UK

Post by beowuuf »

Paul Stevens wrote: All of this can be summarized in four letters. KISS
lol, this got buiried, but are certainly words to live by...reminds me of a short story i never finished...
lectricpharaoh
Neophyte
Posts: 7
Joined: Tue Mar 15, 2005 7:00 pm

Post by lectricpharaoh »

One thing you might be able to do to play sounds simultaneously is use additive mixing in software. Just add all the samples together, then send the resulting buffer to the API. If you're using raw PCM data, this should be quite easy, but if you're using some actual format, like .WAV, you'll have to decode it somehow.

Since one can assume that any platform capable of playing sounds can do so by playing a sample from a memory buffer, if you build the sample yourself which is composed of multiple sounds, one can conclude this approach will support multiple simultaneous sounds on any such platform.

I can think of only one drawback to this approach, besides having to spend the time writing the mixing code. This is that if the resulting sum of multiple samples exceeds the sampling range, your sounds get truncated, much like if you make a recording where the input volume is too high.

This can probably be solved by using a mixing buffer with more bits per samle than the sources. For example, I heard somewhere that (for the ST version, anyways) the samples were only 4 bits (something to do with fitting them onto that single-sided floppy). Mix these into an 8 or 16-bit buffer, and they might sound a bit faint, but they should be reproduced accurately.

To get around this volume loss from upsampling, you could just shift the samples left a few bits. For example, say you're mixing 4-bit samples into a 16-bit buffer. If you determine that the most simultaneous sounds you will ever play will be four, then your maximum 'overflow' will be 2 bits- meaning you've got room to shift the samples 10 bits to the left. All this shifting can be done at build time, or (if you want to support different runtime sample sizes, ie for user-defined dungeon sounds, etc) at load time, so it won't slow anything down.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

I would do the mixing myself except there is no way to know
where in the sound buffer the 'current play position' is.

The DirectX ( now that I understand it ) works very well so
I don't think I will re-invent that wheel.
Post Reply

Return to “Chaos Strikes Back for Windows & Linux (CSBWin) / CSBuild”