sound
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.
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.
Re: sound
The v1.5.1-ED variant of Celestia includes sound support.
See http://www.celestiamotherlode.net/catal ... tional.php
See http://www.celestiamotherlode.net/catal ... tional.php
Selden
Re: sound
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…
Re: sound
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
-
- Developer
- Posts: 1356
- Joined: 07.01.2005
- With us: 19 years 10 months
- Location: Nancy, France
Re: sound
eafbsd,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…
- 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
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
Re: sound
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
Re: sound
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
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
Re: sound
A - M - A - Z - I - N - G!!! . 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...
Never at rest.
Massimo
Massimo
-
- Site Admin
- Posts: 4211
- Joined: 28.01.2002
- With us: 22 years 9 months
- Location: Seattle, Washington, USA
Re: sound
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
--Chris
-
- Developer
- Posts: 1356
- Joined: 07.01.2005
- With us: 19 years 10 months
- Location: Nancy, France
Re: sound
Frank,
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.
Audacity (free audio editor) will easily help you to convert from wav to ogg, and vice versa.
The proteaAudio Lua API (list of functions) is available here: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
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.
Good ! Thanks for testing.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
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).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??
Audacity (free audio editor) will easily help you to convert from wav to ogg, and vice versa.
Yes, you can play up to 8 tracks simultaneously.fsgregs wrote: 2. Is it possible to play two or more sound files simultaneously, as is possible with 151-ED?
@+
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
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
Re: sound
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
- Chuft-Captain
- Posts: 1779
- Joined: 18.12.2005
- With us: 18 years 10 months
Re: sound
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
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
-- Gerard K. O'Neill (1969)
CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS
-
- Developer
- Posts: 1356
- Joined: 07.01.2005
- With us: 19 years 10 months
- Location: Nancy, France
Re: sound
CC,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
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
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
Re: sound
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
Massimo
- Chuft-Captain
- Posts: 1779
- Joined: 18.12.2005
- With us: 18 years 10 months
Re: sound
Cheers Vincent,Vincent wrote:CC,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
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 ?
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
-- Gerard K. O'Neill (1969)
CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS
- Chuft-Captain
- Posts: 1779
- Joined: 18.12.2005
- With us: 18 years 10 months
Re: sound
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.Fenerit wrote:My project aborted: too much files to play. Anyhow, this sound feature is really great: does someone knows links at more "cosmic sounds" files?
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
-- Gerard K. O'Neill (1969)
CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS