Sound patch

The place to discuss creating, porting and modifying Celestia's source code.
Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 8 months
Location: Nancy, France

Post #21by Vincent » 15.01.2006, 20:06

Frank, Victor

Sorry, I can't help since I'm asking myself the same questions... Maybe Victor can help...
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

Topic author
vhpgomes
Posts: 15
Joined: 08.12.2005
With us: 18 years 9 months
Location: Brazil

Post #22by vhpgomes » 17.01.2006, 17:14

Hi all,

Sorry for the delay, but I was offline the past week...

Vicent:
In conclusion, Victor's sound feature doesn't seem to lower - in my case - the display performances.


That's good to know :D . Here everything runs smoothly too, with or without sound. :D

I'll answer the questions below, one by post...

Topic author
vhpgomes
Posts: 15
Joined: 08.12.2005
With us: 18 years 9 months
Location: Brazil

Post #23by vhpgomes » 17.01.2006, 17:34

1. I have no clue what an AL library is. Do I need to "install" an AL library onto my computer before I can hear any sound from a sound script in Celestia?

OpenAL is (description shamelessly taken from the OpenAL site http://www.openal.org):
OpenAL is a cross-platform 3D audio API appropriate for use with gaming applications and many other types of audio applications.


2. If so, where do I install it?

3. Once it is installed, can I include those library files in my education distribution so that a user does not have to install anything special. Just unzip my Celestia folder onto his computer and any "library files" he needs are already in my folder.

I'll answer the second question first: to run the patched version of the celestia you'll need two files: OpenAL32.dll and alut.dll. You can leave these files in the same directory the executable celestia file is, and everything should run just fine.

Now, if you want to compile it, than you'll need other files... you can download the OpenAL SDK from their site, and follow the directions I gave before to Vincent.

4. Is there any keyboard control over the sound? (mute, increase volume, etc.), or are those commands solely within the script?

5. Since the script can be celx, can I assume I could build into the script a code to give users the option to mute the sound with some keystroke if they wish, from within Celestia?


There's no built in key to control sound... maybe it's a good idea to add at least one (mute all)... maybe...

You can do what you said, control the sound with the keyboard via a celx file, but the control is limited... currently you can only start/stop a sound, or change it's volume... you can't, for instance, pause/resume it...

This pause idea is a good one, I think... I'll try to implement it :)


[]'s

Victor

P.S. - Frank, I just saw your PM... later I'll post a reply

Topic author
vhpgomes
Posts: 15
Joined: 08.12.2005
With us: 18 years 9 months
Location: Brazil

Post #24by vhpgomes » 17.01.2006, 17:45

1. It works OK with .WAV files but not with .MP3's -- Are MP3's supposed to be supported? A sound as a WAV file is a lot larger than the same sound as an MP3, which means I can't share my demo with you at the moment because I'm not on broadband (it's 12-30MB with WAV's; with MP3's this would only be a couple of megs). I think it would be good if smaller sound formats could be used as that would reduce the size of addons on the motherlode.

The current version of OpenAL supports only .wav and .au (with a few modifications in the patch (see previous posts)). I agree that support for mp3 would be a great addition, but it would require another library to open it... I'll think on alternatives...

2. Had some problems with starting several short soundbites (from 1 sec to 19 secs long) one after another (on different channels). This kept crashing Celestia.

I didn't had this problem... can you send me the sound files for me to test them here? If so, send them to my gmail acount (vhpgomes@gmail.com)

3. It wouldn't open WAV files with low bit-rates (20kps). I had to convert these ones to 352kps (sample rate=11025, 16bit) for it to work.

I'll look into it.

4. I think it would be good if your patch also searched for sound files installed in any sub-directory of the Extras folder, in the same way addon models are installed. eg. Celestia\extras\<addon-name>\sounds (There's bound to be an existing method call for this)
This I think would be tidier in the long run than having all the sounds from multiple add-ons being dumped in the Celestia\sounds folder, which is the only place your patch looks at the moment. (I think lots of people will want to add sound to Celestia once they have your patch, so it will get very messy in the sound folder!)

5. When you pause time and scripts in Celestia (space bar), the sound should also be paused, because it's usually going to be synchronised to whatever else is going on in the script. Is this possible?


They are both good ideas... gonna look into it...



Thank you all for the replies!!!!

[]'s
Victor

Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 8 months
Location: Nancy, France

Post #25by Vincent » 17.01.2006, 17:57

Victor,

Like you, I thought there were no need to install the OpenAL library as I compiled Celestia with it. So I tried to make the soundpatch run on several Windows systems by adding the two .dll files in the root Celestia folder but it didn't work. I also tried to move the OpenAL32.dll in the Windows/System32 folder but it didn't work either... Each time, I had to install the OpenAL library from the OpenALwEAX.exe file (OpenAL 1.1 Installer for Windows) to make it work... That's why I asked people to download this file from the OpenAL.org website in my Installation Instructions...
Last edited by Vincent on 18.01.2006, 09:36, edited 3 times in total.
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

Avatar
fsgregs
Posts: 1307
Joined: 07.10.2002
With us: 21 years 11 months
Location: Manassas, VA

Post #26by fsgregs » 17.01.2006, 21:19

Vincent and Victor:

Like you, I thought there were no need to install the OpenAL library as I compiled Celestia with it. So I tried to make the soundpatch run on several Windows System by adding the two .dll files in the root Celestia folder but it didn't work. I also tried to copy the OpenAL32.dll on the Windows/System32 folder but it didn't work either... Each time, I had to install the OpenAL library from the OpenALwEAX.exe file (OpenAL 1.1 Installer for Windows) to make it work... That's why I asked people to download this file from the OpenAL.org website in my Installation Instructions...


:? Crap! It a user must install the OpenAL.exe file after he installs the sound version of Celestia, that will complicate its use for me in schools. It seems like a little thing but it causes some problems.

Does anyone know, or can they find out, exactly what OpenALwEAX.exe does when it "installs"? What files does it place where? Is there a Windows registry entry?

Frank

Boux
Posts: 435
Joined: 25.08.2004
With us: 20 years
Location: Brittany, close to the Ocean

Post #27by Boux » 18.01.2006, 09:26

fsgregs wrote:Vincent and Victor:

Like you, I thought there were no need to install the OpenAL library as I compiled Celestia with it. So I tried to make the soundpatch run on several Windows System by adding the two .dll files in the root Celestia folder but it didn't work. I also tried to copy the OpenAL32.dll on the Windows/System32 folder but it didn't work either... Each time, I had to install the OpenAL library from the OpenALwEAX.exe file (OpenAL 1.1 Installer for Windows) to make it work... That's why I asked people to download this file from the OpenAL.org website in my Installation Instructions...

:? Crap! It a user must install the OpenAL.exe file after he installs the sound version of Celestia, that will complicate its use for me in schools. It seems like a little thing but it causes some problems.

Does anyone know, or can they find out, exactly what OpenALwEAX.exe does when it "installs"? What files does it place where? Is there a Windows registry entry?

Frank


I guess the installer is putting something in the registry.
A possible solution would be to search for the entries in the registry, rip them off the registry, and keep them as a separated *.reg file.
Double click on this file and the entries will go back to the registry at the proper place in the hive.
This is an old hacker trick to "duplicate", hemm, sorry, to make a "back-up copy" of an installed program 8O

Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 8 months
Location: Nancy, France

Post #28by Vincent » 18.01.2006, 09:52

If we manage to find out what key(s) the OpenAL library adds into the registry, I could then propose an .exe installer file instead of a zip file. The installer I use has the possibility to add keys in the registry.

Then, we would have two possibilities :
- During installation, the user will have to specify where the Celestia roots folder is, in order to paste all the needed files in it (without overwritting any default file, of course)
or...
- We could also provide a full package with all the default Celestia folders and files in it, that would be installed in a 'Celestia_patch' folder to preserve any installation of the official release...
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

Avatar
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 9 months

Post #29by Chuft-Captain » 18.01.2006, 10:33

2. Had some problems with starting several short soundbites (from 1 sec to 19 secs long) one after another (on different channels). This kept crashing Celestia.

I didn't had this problem... can you send me the sound files for me to test them here? If so, send them to my gmail acount (vhpgomes@gmail.com)


Sent the info in a PM to you Victor
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

Topic author
vhpgomes
Posts: 15
Joined: 08.12.2005
With us: 18 years 9 months
Location: Brazil

Post #30by vhpgomes » 18.01.2006, 19:31

People,

It's good to see that some of you are using my patch, it's a warm feeling to know that I somehow helped someone :)

But enough of this sentimental crap!!!

I will try to implement all the suggestions I've received (mp3, pause, url,...), but before I even start, I want to ask a single question to the official celestia developers.


Is there any chance that someday celestia will have sound capabilities officially? (not necessarily my patch, of course...)

In other words: Which of these two paths should I take?

- I can make a code that will only be used by a couple of people, that requires the instalation of any 3rd party library, with specific features, etc....
- I can make a code more integrated with Celestia, using only a few (if any) GPL libraries, more generic, that can be used, if not direct, as a base for the official version of the sound code.

The first one is a lot easier to implement, so, if there will never be a sound code for celestia, I'd rather take that choice.

What do you say???

Victor

Avatar
fsgregs
Posts: 1307
Joined: 07.10.2002
With us: 21 years 11 months
Location: Manassas, VA

Post #31by fsgregs » 18.01.2006, 22:41

Guys:

As you may know, I now provide a separate installer pkg for folks who want to obtain all of my Activities on CD-ROM. A special version of Celestia, plus all folders and all files, containing all default Celestia files and all of my own educational add-ons/files, is on the CD. Insert the CD and it self-installs. Naturally, I want to include the new Celestia sound/overlay patch file instead of just standard 1.4.1, but if it needs AL Library to also install, then ... I don't know what to do.

I use Inno Setup 5.1 to compile the Windows installer. Vincent, it may be the same installer you use. I know very little about how to use it, but I did learn enough to get Celestia Educational Activities to install in its own folder on a Windows system.

I thought I read somewhere that if someone has two applications to install on a computer, you can set up an installer file to install both of them, sequentially. I don't know if Inno Installer can do this. I do know, however, that Inno Setup 5.1 has the ability to insert registry keys, so if we can figure out exactly what the Al Library installer file is doing, I can duplicate it inside my own installer. Vincent, I think that's what you were suggesting as well.

I am a total novice when it comes to any of this. I have no idea how to find out what AL Library is doing, so I must rely on you guys to figure it all out.

Thanks

Frank

Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 8 months
Location: Nancy, France

Post #32by Vincent » 20.01.2006, 20:48

Frank,

I think a solution can be easily found concerning your personal case. Since OpenAL is Open Source, we should be allowed to integrate it into the Celestia_pack Windows installer, shouldn't we ? I can help you to build this Windows installer if you want...

But as Victor SAID ( :wink: ), he can't take a decision only for one person's interest, but he has to take into consideration all the Celestia users' opinion and interest. According to that, he (and we) has to wait for any sign of a possibe integration of his patch into an official release...
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 8 months
Location: Nancy, France

Post #33by Vincent » 10.05.2006, 16:36

I've added some code in Victor's sound patch to pause the sound playback on channels 1->7 when the spacebar is pressed, since time and script are also paused. Channel 0 is not affected by this pause so that it can be used for background music.

Here are the changes in the code :

- In celestiacore.cpp, we call the pause/resume functions if the spacebar is pressed :

Code: Select all

case ' ':
   if (paused)
   {
      sim->setTimeScale(timeScale);
      scriptPaused = false;
      paused = false;
// Sound - start - Added by Vincent
      resumeSounds();
// Sound - end - Added by Vincent
   }
   else
   {
      sim->setTimeScale(0.0);
      paused = true;

    // If there's a script running then pause it.
    // This has the potentially confusing side effect
    // of rendering nonfunctional goto, center, and
    // other movement commands.
#ifdef CELX
      if (runningScript != NULL || celxScript != NULL)
#else
      if (runningScript != NULL)
#endif
// Sound - start - Added by Vincent
         //scriptPaused = true;
         {
          scriptPaused = true;
          pauseSounds();
          }
// Sound - end - Added by Vincent


- Then, always in Celestiacore.cpp, we define these 'pause' and 'resume' functions, :

Code: Select all

...
void CelestiaCore::stopSounds()
{
    int i;
    for (i = 0; i < MAX_CHANNELS; i++)
        if(soundSources[i])
            alSourceStop(soundSources[i]);
}
// Sound - end - Victor

// Sound - start - Added by Vincent
void CelestiaCore::pauseSounds()
{
    int i;
    for (i = 1; i < MAX_CHANNELS; i++)
        if(soundSources[i])
            alSourcePause(soundSources[i]);
}

void CelestiaCore::resumeSounds()
{
    int state;
    int i;
    for (i = 1; i < MAX_CHANNELS; i++)
    {
    alGetSourcei(soundSources[i], AL_SOURCE_STATE, &state);
        if(state==AL_PAUSED)
            alSourcePlay(soundSources[i]);
    }
}
// Sound - end - Added by Vincent


- We finally declare these functions in celestiacore.h

Code: Select all

    ALuint soundBuffers[MAX_CHANNELS];
    ALuint soundSources[MAX_CHANNELS];

    void stopSounds();
// Sound - start - Added by Vincent
    void pauseSounds();
    void resumeSounds();
// Sound - end - Added by Vincent


Be careful if you change the volume of channel 0 : since this channel is not affected by the pause, your volume changes won't be synchronized anymore with the other channels. Channel 0 has to be kept for background music only.
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

Avatar
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 9 months

Post #34by Chuft-Captain » 11.05.2006, 03:22

That's great Vincent,

Thanks very much for all your efforts.

Just wondering however what you think about my other suggestion: http://celestiaproject.net/forum/viewtopic.php ... ght=#71254
which would allow "pause-ability" to be specified as a parameter of the play command.
This would make ALL channels available for use either as background or pausable however the writer desired.
By reserving channel zero for background music, it will forever be unavailble for non-background use. This may be restrictive for some situations. ie. Someone who wants their sound to be always pausable may require all eight channels at some point, but be unable to utilise channel zero because it is un-pausable.
Also, I'm thinking that those users who only want background music (whether looped or not) may need more than 1 channel at times.

I think this would be more flexible as it would allow ALL channels to be used for either purpose.
I know this possibly being very nit-picky but just wondered what your thoughts were. (perhaps this scheme is more difficult to implement???)

Regards

CC
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 8 months
Location: Nancy, France

Post #35by Vincent » 12.05.2006, 18:02

Chuft-Captain wrote:Just wondering however what you think about my other suggestion: http://celestiaproject.net/forum/viewtopic.php ... ght=#71254
which would allow "pause-ability" to be specified as a parameter of the play command.
This would make ALL channels available for use either as background or pausable however the writer desired.I know this possibly being very nit-picky but just wondered what your thoughts were. (perhaps this scheme is more difficult to implement???)

CC,

I agree with your arguments and it IS indeed a little bit more complex to implement... and to use... I'm going to try as soon as possible since I think I will use the version you suggested for myself. Now if the majority of interested users also want it to be implemented in Celestia_patch2, I'll do it... :wink:
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

ANDREA
Posts: 1543
Joined: 01.06.2002
With us: 22 years 3 months
Location: Rome, ITALY

Post #36by ANDREA » 12.05.2006, 18:47

Vincent wrote:I agree with your arguments and it IS indeed a little bit more complex to implement... and to use... I'm going to try as soon as possible since I think I will use the version you suggested for myself. Now if the majority of interested users also want it to be implemented in Celestia_patch2, I'll do it... :wink:

I have no problem with this further improvement, even if I don't see a practical use of it. :oops:
CC, can you give me an example of its use? :wink:
Thank you, probably I'll use it, if the results are worth the effort.
Bye

Andrea :D
"Something is always better than nothing!"
HP Omen 15-DC1040nl- Intel® Core i7 9750H, 2.6/4.5 GHz- 1TB PCIe NVMe M.2 SSD+ 1TB SATA 6 SSD- 32GB SDRAM DDR4 2666 MHz- Nvidia GeForce GTX 1660 Ti 6 GB-WIN 11 PRO

Avatar
fsgregs
Posts: 1307
Joined: 07.10.2002
With us: 21 years 11 months
Location: Manassas, VA

Post #37by fsgregs » 12.05.2006, 20:49

Vincent:

I can see some value to a new parameter that allows a particular sound channel to be paused or not paused on any channel when the spacebar is pressed. I support your effort to implement it.

Thanks as always

Frank

Avatar
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 9 months

Post #38by Chuft-Captain » 13.05.2006, 15:17

ANDREA wrote:
Vincent wrote:I agree with your arguments and it IS indeed a little bit more complex to implement... and to use... I'm going to try as soon as possible since I think I will use the version you suggested for myself. Now if the majority of interested users also want it to be implemented in Celestia_patch2, I'll do it... :wink:
I have no problem with this further improvement, even if I don't see a practical use of it. :oops:
CC, can you give me an example of its use? :wink:


Andrea,
My initial thoughts are something along the lines of this:

1. Default behaviour: all channels would be pausable,
2. any specific instance of a play command could be specified as nopause.

In the example below, all active channels except the background music on channel 0 would be paused if the spacebar was pressed, but the background music would continue regardless (for 260 seconds in this case)

Script example:
============
# start playing background music
play { channel 0 volume 1 loop 0 nopause filename "BlueDanube.wav" }
wait { duration 260 }

...

# start narration
play { channel 1 volume 0.4 loop 0 filename "2001_open.wav" }
wait { duration 3 }
play { channel 2 volume 0.4 loop 0 filename "2001_cant_do_that.wav" }
wait { duration 4 }
play { channel 3 volume 0.4 loop 0 filename "2001_disconnet.wav" }
wait { duration 8 }
play { channel 4 volume 0.4 loop 0 filename "2001_mission.wav" }
wait { duration 5 }
play { channel 5 volume 0.4 loop 0 filename "2001_stress_pill.wav" }
wait { duration 20 }

============

Just my 2 cents worth.
Any better ideas?

CC
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

ANDREA
Posts: 1543
Joined: 01.06.2002
With us: 22 years 3 months
Location: Rome, ITALY

Post #39by ANDREA » 13.05.2006, 15:50

Chuft-Captain wrote:Andrea, My initial thoughts are something along the lines of this:

1. Default behaviour: all channels would be pausable,
2. any specific instance of a play command could be specified as nopause.
In the example below, all active channels except the background music on channel 0 would be paused if the spacebar was pressed, but the background music would continue regardless (for 260 seconds in this case)
Just my 2 cents worth.
Any better ideas? CC

No, I think it can work OK for any needs, including mine. So green light from my side (a bit too immodest, isn't it? I'm jocking, obviously! :wink: )
Bye

Andrea :D
"Something is always better than nothing!"
HP Omen 15-DC1040nl- Intel® Core i7 9750H, 2.6/4.5 GHz- 1TB PCIe NVMe M.2 SSD+ 1TB SATA 6 SSD- 32GB SDRAM DDR4 2666 MHz- Nvidia GeForce GTX 1660 Ti 6 GB-WIN 11 PRO

Avatar
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 9 months

Post #40by Chuft-Captain » 13.05.2006, 17:00

Thanks Andrea,

Vincent, as you are the one doing the work, let us know if you have any issues with this, or if it's too difficult to do.

I don't see this feature as being essential if it is very difficult to implement, or if it introduces other issues or breaks the code. It's just a bit more flexible, so if no big problems, would be nice to have.

I think that what you've done so far in continuing Victor's work on the sound patch is excellent.

Thanks a lot.
CC
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS


Return to “Development”