sound

Have a question about using Celestia? Check here first for FAQs and helpful advice.
Forum rules
Please help to make this forum more useful by checking the FAQs before posting! Keep it clean, keep it civil, keep it truthful, stay on topic, be responsible, share your knowledge.
Topic author
eafbsd
Posts: 31
Joined: 12.10.2007
With us: 17 years 1 month
Location: na

sound

Post #1by eafbsd » 28.09.2009, 17:40

I’m still running, or should I say forced to run, Celestia 1.4.1 because of the sound capabilities of the 1.4.1 patch 3. Is there any way to achieve sound in the later versions (1.5 or 1.6) ?

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 2 months
Location: NY, USA

Re: sound

Post #2by selden » 28.09.2009, 21:37

The v1.5.1-ED variant of Celestia includes sound support.
See http://www.celestiamotherlode.net/catal ... tional.php
Selden

Topic author
eafbsd
Posts: 31
Joined: 12.10.2007
With us: 17 years 1 month
Location: na

Re: sound

Post #3by eafbsd » 02.10.2009, 19:16

Selden – first, thanks for the quick reply. Celestia is great, but I have a hard time understanding why it’s necessary to download a 489Mb 1.5.1 ED version file when the 1.4.1 patch3 sound download was only 4.91Mb? The only reason I’m kind of complaining is that my Celestia folder is currently at 4.77Gb. Is it possible there’s a patch somewhere that can enable sound in 1.5 or 1.6? Once again, thanks for the reply…

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 2 months
Location: NY, USA

Re: sound

Post #4by selden » 02.10.2009, 19:27

The base ED download includes many Addons. The modified executable is only about 2MB. I don't know what else is needed in order for sound to work, if that's really all you want.. Hopefully Frank will comment.
Selden

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

Re: sound

Post #5by Vincent » 04.10.2009, 17:37

eafbsd wrote:Selden – first, thanks for the quick reply. Celestia is great, but I have a hard time understanding why it’s necessary to download a 489Mb 1.5.1 ED version file when the 1.4.1 patch3 sound download was only 4.91Mb? The only reason I’m kind of complaining is that my Celestia folder is currently at 4.77Gb. Is it possible there’s a patch somewhere that can enable sound in 1.5 or 1.6? Once again, thanks for the reply…
eafbsd,

- Bad news: I won't release a patched version of Celestia 1.6
- Good news: I managed to add sound support to Celestia - at least, to the Windows version for now - without adding one single
line to the Celestia source code. :) This can be done using proteaAudio, which is a free cross-platform stand-alone Lua audio library.

You can download the 'sound of a pulsar' test package below.

The zip contains:
- a pulsar_sound.celx script file
- a pulsar.ogg audio file
- the lua51.dll and proAudioRt.dll files.

The lua51.dll and proAudioRt.dll files should be placed right into your celestia base folder.
Other files can be placed wherever on your disk, e.g., in your celestia/extras/ folder...
Just make sure the sound file is located in the same folder as the script file.

The volume of the sound depends on the distance from the pulsar,
and the left/right components vary according to the position
of the pulsar relative to the observer. So you can test the stereo
audio effect by moving the pulsar around the observer using the 4/6 keys.

Please let me know how it works on your system.
@+
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

Ricardo
Posts: 14
Joined: 03.09.2009
With us: 15 years 2 months

Re: sound

Post #6by Ricardo » 04.10.2009, 18:59

Vincent wrote:I managed to add sound support to Celestia - at least, to the Windows version for now -

I confirm this do not work on Mac... Too bad, this is great...
I tried to put the dll files everywhere, but no chance with the script... (no feedback in the console either)
MBP 2.6 GHz Intel 4Go GeForce 8600M GT 512 - osX 10.5.8

Avatar
fsgregs
Posts: 1307
Joined: 07.10.2002
With us: 22 years 1 month
Location: Manassas, VA

Re: sound

Post #7by fsgregs » 04.10.2009, 23:59

Vincent:

Your knowledge of programming continues to put me in awe. I have looked at some of the commands in the celx script that you included with the pulsar sound test, and well ... they look completely Greek to me :?

I have tested out the pulsar sound and it works fine on a Windows XP machine with Celestia 1.6.0, including stereo effects as you swing the view left or right

Two questions: (1) The sound file is an extension ending in .ogg. How would one convert a wav file to an ogg file, or can we use a .wav in the script instead? If we can use a wav file, what would the line in the celx script look like??

2. Is it possible to play two or more sound files simultaneously, as is possible with 151-ED?


eafbsd: I will answer you in more detail about 151-ED, after Vincent has a chance to comment on my two questions above.

Frank

Avatar
Fenerit M
Posts: 1880
Joined: 26.03.2007
Age: 17
With us: 17 years 7 months
Location: Thyrrenian sea

Re: sound

Post #8by Fenerit » 05.10.2009, 10:17

A - M - A - Z - I - N - G!!! 8O . This is a "must have" in LUATOOLS toolkit as "sounds" in general. BTW: for whom are interested should be easy to modify the .OGG file to add surround... :wink:
Never at rest.
Massimo

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Re: sound

Post #9by chris » 05.10.2009, 11:34

I have the proteaAudio library working on the Mac as well. I will try and release a version of it as soon as I have the time (later today, I think...) This audio library should also work on Linux, but I haven't tested that.

--Chris

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

Re: sound

Post #10by Vincent » 05.10.2009, 16:46

Frank,

fsgregs wrote:I have looked at some of the commands in the celx script that you included with the pulsar sound test, and well ... they look completely Greek to me :?
The proteaAudio Lua API (list of functions) is available here:
http://www.viremo.de/proteaAudio/proteaaudiolua.html

Also, we could write our own functions and put them in a lua file to make the sound commands look more like the other existing celx commands.

fsgregs wrote:I have tested out the pulsar sound and it works fine on a Windows XP machine with Celestia 1.6.0, including stereo effects as you swing the view left or right
Good ! Thanks for testing.

fsgregs wrote: (1) The sound file is an extension ending in .ogg. How would one convert a wav file to an ogg file, or can we use a .wav in the script instead? If we can use a wav file, what would the line in the celx script look like??
Both wav and ogg/vorbis files can be used. I'd suggest to use ogg files, though, since wav files are quite big (uncompressed format).
Audacity (free audio editor) will easily help you to convert from wav to ogg, and vice versa.

fsgregs wrote: 2. Is it possible to play two or more sound files simultaneously, as is possible with 151-ED?
Yes, you can play up to 8 tracks simultaneously. :)
@+
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: 22 years 1 month
Location: Manassas, VA

Re: sound

Post #11by fsgregs » 05.10.2009, 21:22

Vincent:

Thanks so much for your quick reply. I will explore it all ASAP. :D

Frank

Topic author
eafbsd
Posts: 31
Joined: 12.10.2007
With us: 17 years 1 month
Location: na

Re: sound

Post #12by eafbsd » 06.10.2009, 00:16

Frank,
I eagerly await any info you can provide. I am indebted to you. Thanks

Ricardo
Posts: 14
Joined: 03.09.2009
With us: 15 years 2 months

Re: sound

Post #13by Ricardo » 06.10.2009, 01:45

chris wrote:I have the proteaAudio library working on the Mac as well. I will try and release a version of it as soon as I have the time (later today, I think...) This audio library should also work on Linux, but I haven't tested that.

--Chris

Very nice news!
MBP 2.6 GHz Intel 4Go GeForce 8600M GT 512 - osX 10.5.8

Ricardo
Posts: 14
Joined: 03.09.2009
With us: 15 years 2 months

Re: sound

Post #14by Ricardo » 08.10.2009, 06:37

chris wrote:I have the proteaAudio library working on the Mac as well...

How can we get the dll files version Mac?
MBP 2.6 GHz Intel 4Go GeForce 8600M GT 512 - osX 10.5.8

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

Re: sound

Post #15by Chuft-Captain » 08.10.2009, 11:51

Thanks Vincent, works fine for me, although I haven't tried any multi-track stuff yet.
A brief read of the proteaAudio documentation doesn't make it obvious what is the correct syntax for assigning sounds to tracks for polyphonic playback.

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 10 months
Location: Nancy, France

Re: sound

Post #16by Vincent » 08.10.2009, 15:49

Chuft-Captain wrote:Thanks Vincent, works fine for me, although I haven't tried any multi-track stuff yet.
A brief read of the proteaAudio documentation doesn't make it obvious what is the correct syntax for assigning sounds to tracks for polyphonic playback.

CC
CC,

You're welcome.
To play several samples simultaneously, you just need to load and ...play them.

Code: Select all

track1= proAudio.sampleFromFile(scriptpath.."sound1.ogg")
track2 = proAudio.sampleFromFile(scriptpath.."sound2.wav")
track3 = proAudio.sampleFromFile(scriptpath.."sound3.wav")

proAudio.soundPlay (track1)
proAudio.soundPlay (track2)
proAudio.soundPlay (track3)

Each sample will be automatically assigned to a track.
Do you have an example where you'd need to control the sample/track assignment ?
@+
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
Fenerit M
Posts: 1880
Joined: 26.03.2007
Age: 17
With us: 17 years 7 months
Location: Thyrrenian sea

Re: sound

Post #17by Fenerit » 08.10.2009, 16:08

Vincent, I think that CC's "example" could be sourround. One could to assign the rear channels to a second track once the file audio has been properly encoded. In this manner one track is for the front channels and a second for the rear. I will try to split the pulsar.ogg in two files, one with the front channels encoded and one with the rear channels encoded. When one go to pulsar would to listen also on rear when have the pulsar backface.
Never at rest.
Massimo

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

Re: sound

Post #18by Chuft-Captain » 08.10.2009, 17:40

Vincent wrote:
Chuft-Captain wrote:Thanks Vincent, works fine for me, although I haven't tried any multi-track stuff yet.
A brief read of the proteaAudio documentation doesn't make it obvious what is the correct syntax for assigning sounds to tracks for polyphonic playback.

CC
CC,

You're welcome.
To play several samples simultaneously, you just need to load and ...play them.

Code: Select all

track1= proAudio.sampleFromFile(scriptpath.."sound1.ogg")
track2 = proAudio.sampleFromFile(scriptpath.."sound2.wav")
track3 = proAudio.sampleFromFile(scriptpath.."sound3.wav")

proAudio.soundPlay (track1)
proAudio.soundPlay (track2)
proAudio.soundPlay (track3)

Each sample will be automatically assigned to a track.
Do you have an example where you'd need to control the sample/track assignment ?
Cheers Vincent,
That may well work for ogg and wav samples Vincent (I haven't tried it yet), however it doesn't seem to work with generated samples.
Here's a simple example which is designed to play a well known 4 note motif (if you follow SciFi movies) simultaneously in an upper and lower octave.
(As posted, it will play just the higher octave by itself --- un-comment the lines marked as "lower octave" to activate the second octave)

Based on what you suggest, then both octaves should play polyphonically as the notes come from 2 different samples (and therefore 2 different tracks), however it appears that the second (lower) octave is unable to play until the first (higher) note has finished in each case.
This suggests to me that both upper, and lower octaves, in this case are being assigned to the same track, which means I've either done something wrong, or the library only allows multi-track playback of static wav/ogg files, but not generated waveforms.

EDIT: Oops! I just read the following sentence in the documentation which expains it.
"There is no equivalent to the C++ AudioSample class in the proteaAudio Lua API. However, mono audio samples may be dynamically created by the following call:

proAudio.sampleFromMemory(data, sampleRate)"


Code: Select all

-- function creating a sine wave sample:
function sampleSine(freq, duration, sampleRate)
   local data = { }
   for i = 1,duration*sampleRate do
      data[i] = math.sin( (i*freq/sampleRate)*math.pi*2)
   end
   return proAudio.sampleFromMemory(data, sampleRate)
end

-- plays a sample shifted by a number of halftones for a definable period of time
function playNote(sample, pitch, duration, volumeL, volumeR, disparity)
   local scale = 2^(pitch/12)
   local sound = proAudio.soundLoop(sample, volumeL, volumeR, disparity, scale)
   proAudio.sleep(duration)
   proAudio.soundStop(sound)
end

-- create an audio device using default parameters and exit in case of errors
require("proAudioRt")
--if not proAudio.create() then os.exit(1) end
if not proAudio.create( 8, 88200, 1024 ) then os.exit(1) end

-- Define target
target = celestia:find("Devils Tower")
--celestia:select(target)
--obs = celestia:getobserver()
--obs:gotodistance(target, 1000, 3)
--wait(3)

-- generate a sample:
local sample = sampleSine(440, 0.5, 88200)
local sample2 = sampleSine(220, 0.5, 88200)

-- play scale (a major):
local duration = 0.5
for d = duration, 0.1 , -0.1 do
   for i,note in ipairs({ 9, 11 }) do
      playNote(sample, note, d)
      --playNote(sample2, note, d) -- same note at a lower octave
      wait()
   end
   for i,note in ipairs({ 7 }) do
      playNote(sample, note, d  )
      --playNote(sample2, note, d) -- same note at a lower octave
      wait()
   end
   for i,note in ipairs({ -5 }) do
      playNote(sample, note, d )
      --playNote(sample2, note, d) -- same note at a lower octave
      wait()
   end
   for i,note in ipairs({ 2 }) do
      playNote(sample, note, d * 3.5 )
      --playNote(sample2, note, d * 3.5 ) -- same note at a lower octave
      wait()
   end
   wait()
end
local d2 = 0.3

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

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

Avatar
Fenerit M
Posts: 1880
Joined: 26.03.2007
Age: 17
With us: 17 years 7 months
Location: Thyrrenian sea

Re: sound

Post #19by Fenerit » 09.10.2009, 10:33

My project aborted: too much files to play. :roll: Anyhow, this sound feature is really great: does someone knows links at more "cosmic sounds" files?
Never at rest.
Massimo

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

Re: sound

Post #20by Chuft-Captain » 09.10.2009, 13:16

Fenerit wrote:My project aborted: too much files to play. :roll: Anyhow, this sound feature is really great: does someone knows links at more "cosmic sounds" files?
Scripts in Celestia will crash if they haven't returned control to Celestia within 5 seconds. This can be an issue for example with loops if they are doing a lot of work and/or have many iterations.
Generally you can solve this with judicious use of wait() statements in your code.
This will periodically return control to Celestia, thus avoiding a crash.

Notice how I do a wait() in each iteration of the loops in the script above.
You don't necessarily have to use as many as I've used (one in the outer loop alone would probably do the job in this case, but it does no harm).
If you suspect any part of your code is using a lot of time, try adding a wait().

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 “Help Central”