Sound advice

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

Post Reply
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Sound advice

Post 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.
Commander Smivs, the friendliest Gourd this side of Riedquat.
Neelix
---- E L I T E ----
---- E L I T E ----
Posts: 288
Joined: Sat May 31, 2014 9:02 pm
Location: Melbourne, Australia

Re: Sound advice

Post 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
Talaxian Enterprises: [wiki]Vacuum Pump[/wiki] [wiki]Waypoint Here[/wiki]
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Sound advice

Post 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).
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Sound advice

Post 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.
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Sound advice

Post 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?
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Sound advice

Post 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.
User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6312
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

Re: Sound advice

Post 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?
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Sound advice

Post 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.
User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6312
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

Re: Sound advice

Post 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)..
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied
Post Reply