Page 1 of 1

Sound advice

Posted: Fri Jun 20, 2014 10:38 pm
by Smivs
From the Progress thread.
cim wrote:
Smivs wrote:
Now, can somebody point to me any documentation on the new sound options, like how the 7.1 surround thing is going to work etc...
As far as I can tell, the process should be: plug in 7.1 surround speakers; play Oolite. I've been testing it with headphones, not really having the space to put that many speakers around my computer desk...

If you have a soundset OXP installed, then all the sound files in it will need converting to mono if they're stereo, or the positioning won't work. Unfortunately this hasn't been important before, so I expect a lot of sound sets will have a mix of stereo and mono sounds with no particular consistency - I had to spend an hour or two converting half of the core sounds to mono when this first went in.

Port and starboard lasers are good ones to test if it's working, while the "being hit" noises are the ones with the most positional variation in the game.
Where do I start? :D Well, by starting a new thread instead of hijacking 'Progress' 8)
The first bit (plug it in) sounds good, but the mono source and positioning I'm not sure about, and in fact the idea I have been thinking about is more script-triggered audio effects rather than single sounds.
Off the head example - half a dozen alien probes approach your ship, and as they touch each one scrapes a bit and 'clunks' on solidly, each from a different direction.

Code: Select all

   
 var magneticAlienProbesSound = new SoundSource; 
 this.magneticAlienProbesSound.playSound = ("magneticAlienProbes.ogg");
where magneticAlienProbes.ogg is a six-channel (5.1) sound file.
I assumed at first that this would require a multi-channel sound file (say six channels for a standard 5.1 layout) with each position fed by a channel, and the sound file mixed to give the spread of sound required. Is this not how it works?
Does the game instead take a (mono) sound and then send it to the appropriate speaker? How does it know which channel/position it needs?
I think I need a crash-course in the basics, and I'm sure I'm not the only one out here who finds this prospect intrigueing, so hopefully this might help others out as well.

Re: Sound advice

Posted: Fri Jun 20, 2014 11:15 pm
by Neelix
I'm only speculating here but I suspect that depends on whether or not you want to control the positional information from the script. ie - If you want the script to be able to play a sound at a specific position it needs to be mono, but if you play a multichannel sound file, the positioning will be based on how the the sound file was designed, and trying position it via the script will not work.

- Neelix

Re: Sound advice

Posted: Fri Jun 20, 2014 11:24 pm
by Smivs
Yeah, that's how I assumed it worked, the sound file is triggered by script but the positional information is channel-based (like 2-ch stereo only bigger).

Re: Sound advice

Posted: Sat Jun 21, 2014 7:40 am
by cim
Ah, right, I see - sorry, I completely misunderstood your question.

To position a sound, encode the sound file as mono, and then:

Code: Select all

 var magneticAlienProbesSound = new SoundSource;
magneticAlienProbesSound.position = [0,0,-1]; // they're behind you...
magneticAlienProbesSound.playSound = ("magneticAlienProbes.ogg");
The OpenAL sound library then works out what levels to send to each speaker given the position property and the number of connected speakers. The sound has to be mono so that it can split it appropriately for all supported sound hardware.

The position vector is just used to give a direction the sound should come from - we don't have volume fall-off with distance applied. Use the "volume" property of the SoundSource if you want to do that.

Re: Sound advice

Posted: Sat Jun 21, 2014 8:19 am
by Smivs
Ah, thanks, it's starting to make sense now. So

Code: Select all

magneticAlienProbesSound.position = [0,-1,-1];
would position the sound in the right-rear quadrant. One more quicky - how would you move/pan a sound? Say a scraping noise going from front to back - can that be done?

Re: Sound advice

Posted: Sat Jun 21, 2014 8:34 am
by cim
Smivs wrote:
One more quicky - how would you move/pan a sound? Say a scraping noise going from front to back - can that be done?
Yes - use a frame callback to smoothly reposition the sound as it plays.

Re: Sound advice

Posted: Sat Jun 21, 2014 8:46 am
by Diziet Sma
cim wrote:
To position a sound, encode the sound file as mono, and then:

Code: Select all

 var magneticAlienProbesSound = new SoundSource;
magneticAlienProbesSound.position = [0,0,-1]; // they're behind you...
magneticAlienProbesSound.playSound = ("magneticAlienProbes.ogg");
The OpenAL sound library then works out what levels to send to each speaker given the position property and the number of connected speakers. The sound has to be mono so that it can split it appropriately for all supported sound hardware.
Presumably, non of this introduces problems for regular stereo music tracks in HyperRadio, for example?

And the other related question, will it now be possible to create full surround-sound music tracks for HyperRadio?

Re: Sound advice

Posted: Sat Jun 21, 2014 8:56 am
by cim
Diziet Sma wrote:
Presumably, non of this introduces problems for regular stereo music tracks in HyperRadio, for example?
Stereo tracks are played as regular L/R stereo and aren't positioned at all. Over headphones I find there's a distinct difference in sound between a stereo track with two identical channels, and a mono sound positioned at [0,0,0], though I'm not sure why - possibly with speakers that wouldn't be noticeable.
Diziet Sma wrote:
And the other related question, will it now be possible to create full surround-sound music tracks for HyperRadio?
Probably, though HyperRadio would need some modifications to do it - encode each channel as a separate mono source, and then play them simultaneously from the appropriate positions.

Re: Sound advice

Posted: Sat Jun 21, 2014 9:05 am
by Diziet Sma
cim wrote:
Diziet Sma wrote:
And the other related question, will it now be possible to create full surround-sound music tracks for HyperRadio?
Probably, though HyperRadio would need some modifications to do it - encode each channel as a separate mono source, and then play them simultaneously from the appropriate positions.
Ok.. thanks.. since, from a recent discussion with Svengali, I'll probably be taking over maintenance of HyperRadio from him (although no doubt I'll need to ask him for the occasional assist while I get up to speed)..