Pages: [1]
  Print  
Author Topic: OGG support  (Read 22456 times)
CGB01
Half-Nub


Cakes 2
Posts: 63



« on: May 09, 2013, 08:58:59 AM »

Does Open Arena have .ogg sound file support?  I thought I read somewhere it did.  I'm trying to add a file (see attachment) and it just doesn't play.  To test, I've set the spawnflags to glabal/loop.

When I try with regular .wav files, it works.

Any thoughts?

TIA.
Logged
Gig
In the year 3000
***

Cakes 45
Posts: 4394


WWW
« Reply #1 on: May 09, 2013, 09:05:45 AM »

OA supports OGG, at least for background music...
In pak6-patch088.pk3 --> music/OA01.ogg, music/OA07.ogg
I don't know if that applies to in-game sounds, too... but I suppose yes: in pak6-patch088.pk3, I see that while most files under "sound" folder are in .wav format, those in sound/player/neko are in .ogg format. Do Neko's sounds work?

I don't know anything about the spawnflags global/loop thing...
AFAIK, to choose a background music for a map, it's music (path/name) key for worldspawn.
Are you trying to make a trigger-activated sound or what?
« Last Edit: May 09, 2013, 09:09:03 AM by Gig » Logged

I never want to be aggressive, offensive or ironic with my posts. If you find something offending in my posts, read them again searching for a different mood there. If you still see something bad with them, please ask me infos. I can be wrong at times, but I never want to upset anyone.
CGB01
Half-Nub


Cakes 2
Posts: 63



« Reply #2 on: May 09, 2013, 11:52:06 AM »

Hey Gig, just trying to add background sound to an area of a map I'm creating in a swamp area.

How does one add background music for the whole level?  Maybe I'll try learning from there...

Logged
Akom74
Member


Cakes 9
Posts: 906


Q3A/OA Mapper


WWW
« Reply #3 on: May 09, 2013, 01:15:45 PM »

Hey Gig, just trying to add background sound to an area of a map I'm creating in a swamp area.

How does one add background music for the whole level?  Maybe I'll try learning from there...

Ehm, you know that the background music comes from a command gived to the editor after compiling, right ?
Watch out at this:


Just select a brush (not an entity !) and push "n" button and the entity menu' will appear.
Now you have to "change" (??) from wav to ogg and make sure you write the right folder where is the music track you want to use.

Wink
Logged

...sorry for my English, i'm Italian... Tongue



CGB01
Half-Nub


Cakes 2
Posts: 63



« Reply #4 on: May 09, 2013, 04:03:44 PM »

Ehm, you know that the background music comes from a command gived to the editor after compiling, right ?

No I didn't.  There are many things I don't know yet!  LOL!

Quote
Just select a brush (not an entity!) and push "n" button and the entity menu' will appear.
Now you have to "change" (??) from wav to ogg and make sure you write the right folder where is the music track you want to use.

Ok, so this worked and played the .ogg file properly.

However, an entity called target_speaker only seems able to play .wav files.  Any reasons why?
Logged
Neon_Knight
In the year 3000
***

Cakes 49
Posts: 3775


Trickster God.


« Reply #5 on: May 09, 2013, 07:55:10 PM »

You could have done the same in a cleaner way, by pressing L to open the Entity List, then search or worldspawn, and then pressing N to add the Entity Menu. Tongue
Logged


"Detailed" is nice, but if it gets in the way of clarity, it ceases being a nice addition and becomes a problem. - TVT
Want to contribute? Read this.
andrewj
Member


Cakes 24
Posts: 584



« Reply #6 on: May 09, 2013, 10:36:59 PM »

However, an entity called target_speaker only seems able to play .wav files.  Any reasons why?

The game code forces the file to have a ".wav" extension -- if you use ".ogg" then it adds a ".wav" on the end and you get something like "filename.ogg.wav" which does not work.

See SP_target_speaker in g_target.c
Code:
        if (!strstr( s, ".wav" )) {
                Com_sprintf (buffer, sizeof(buffer), "%s.wav", s );
        } else {
                Q_strncpyz( buffer, s, sizeof(buffer) );
        }

Nothing you can do about it.
Logged
sago007
Posts a lot
*

Cakes 62
Posts: 1664


Open Arena Developer


WWW
« Reply #7 on: May 09, 2013, 11:41:56 PM »

I think I remember that the OA engine will look for filename.ogg then asked for filename.wav if filename.wav does not exist.
Logged

There are nothing offending in my posts.
CGB01
Half-Nub


Cakes 2
Posts: 63



« Reply #8 on: May 10, 2013, 04:31:49 AM »

However, an entity called target_speaker only seems able to play .wav files.  Any reasons why?

The game code forces the file to have a ".wav" extension -- if you use ".ogg" then it adds a ".wav" on the end and you get something like "filename.ogg.wav" which does not work.

See SP_target_speaker in g_target.c
Code:
        if (!strstr( s, ".wav" )) {
                Com_sprintf (buffer, sizeof(buffer), "%s.wav", s );
        } else {
                Q_strncpyz( buffer, s, sizeof(buffer) );
        }

Nothing you can do about it.

That code snipet checks if ".wav" is found anywhere in the string, so a string of "river.waves" would pass the test and as you've stated, if it fails to find it, it adds it to the end of the string.  So I tried renaming my file to "swamp.ogg.wav" and run the engine.  OA crashed on me Sad  So much for fooling it!  LOL!

So it would seem that .ogg support only works for worldspawn classnames.  One would have to look deeper into the code to find out why a worldspawn can have either an .ogg file or a .wav file and still work.  There has to be a test to determine which audio driver to use at one point or another.  So it would make sense to add the same logic in the section of code that processes events as the sound is eventually added to an event queue by the line;

G_AddEvent( activator, EV_GENERAL_SOUND, ent->noise_index );

You can't say you have .ogg file support and only have half of it working Wink

Perhaps there's another reason why it's not supported in the target_speaker entity but without digging into the code, I can't tell and I don't want to start looking too deeply into code yet.  I want to continue with my mapping and get comfortable with it first.

Thanks for your help guys.  I really appreciate it.

Cheers!
Logged
grey matter
Member


Cakes 8
Posts: 381

>9k


« Reply #9 on: May 10, 2013, 05:03:12 AM »

That code snipet checks if ".wav" is found anywhere in the string, so a string of "river.waves" would pass the test and as you've stated, if it fails to find it, it adds it to the end of the string.  So I tried renaming my file to "swamp.ogg.wav" and run the engine.  OA crashed on me Sad  So much for fooling it!  LOL!

Did you mean swamp.wav.ogg? The way you have it it'll look for a .wav file.
If the engine crashes, you should most likely file a bug. Warnings in console are fine, but a crash is not.
Logged

This space is for rent.
CGB01
Half-Nub


Cakes 2
Posts: 63



« Reply #10 on: May 10, 2013, 05:34:42 AM »

That code snipet checks if ".wav" is found anywhere in the string, so a string of "river.waves" would pass the test and as you've stated, if it fails to find it, it adds it to the end of the string.  So I tried renaming my file to "swamp.ogg.wav" and run the engine.  OA crashed on me Sad  So much for fooling it!  LOL!

Did you mean swamp.wav.ogg? The way you have it it'll look for a .wav file.
If the engine crashes, you should most likely file a bug. Warnings in console are fine, but a crash is not.

Err, yes you're right.  It was swamp.wav.ogg that I tried.  However, the strstr test would have passed in either way as it checks for a string within a string, not a file extension.

Don't know how to file a bug here.  I agree it should have just given me a console warning and ignored the sound file.
Logged
Gig
In the year 3000
***

Cakes 45
Posts: 4394


WWW
« Reply #11 on: May 10, 2013, 06:31:19 AM »

Thoughts...
I suppose (I'm not sure) OGG support is something added by ioquake3 guys to the engine, hence I think one might do some tests with "Q3A+ioquake3" with OGG and check what happens there... if you try to use it as worldspawn, and if you try to use it as target_speaker. I would also be curious to know what happens if using it for a character's sounds.

However, changes one can make modifying the engine only, without modifying gamecode (game logic), have limits. Of course we can update OA gamecode, but we have to consider that, unlike engine updates, gamecode changes do not apply to old mods.

I mean that, if we can complete OGG support in "extra" features like target_speaker updating the engine only, it's okay... but if we require to change also the game logic, it's a problem: we would risk to have maps working in "new" baseoa, but crashing the game (or simply not playing such sounds, who knows) when trying to play them while using any mod!


Well, I just tried using the Neko character (its sounds are in .ogg format) in OA. Its sounds are played in baseoa, and also in the two Q3 mods I tried (Alternate Fire and Bazooka Q3). This seems a good indicator that .ogg can be used also for things different than background music.  Smiley But, if that part of the code posted by andrewj is something that is in the gamecode, it may anyway be a problem.  Embarrassed If that code applies to target_speaker only, I suppose a workaround has not been created yet: simply removing that code from the gamelogic may break some existing maps, and would not work when playing mods. One would need to tweak the engine to "undo" what that gamelogic code does, if the .ogg is available?
Maybe someone knowing about coding may find a solution... in the meanwhile, continuing using .wav files for target_speaker (not so common in the game) does not seem a tragedy.

As I said, these are just "thoughts"... I do not know enough about coding to tell if that fix is possible or easy or not.


-------
PS: To submit a bug found with the current version of the game -0.8.8-, you can write about it in the apposite 0.8.8 bugs thread, and then add a link to that post in the "Bugs" page of the wiki ((DO NOT LINK) h t t p s : / / openarena . wikia . com/wiki/Bugs#Sounds). Of course, you can also link to this thread for further info.
« Last Edit: May 10, 2013, 06:56:36 AM by Gig » Logged

I never want to be aggressive, offensive or ironic with my posts. If you find something offending in my posts, read them again searching for a different mood there. If you still see something bad with them, please ask me infos. I can be wrong at times, but I never want to upset anyone.
andrewj
Member


Cakes 24
Posts: 584



« Reply #12 on: May 10, 2013, 09:15:51 AM »

I think OA's gamecode for target_speaker can be easily fixed without breaking compatibility with anything.

Though CGB01's crash with swamp.wav.ogg is a big concern, perhaps a bug in the engine related to loading OGG as normal sound data (rather than streaming it, as done for music).
Logged
CGB01
Half-Nub


Cakes 2
Posts: 63



« Reply #13 on: May 10, 2013, 10:05:20 AM »

Gig, I don't know enouh about the code to comment on breaking compatibility or not.  I've not looked at how it's all put together yet, but it would seem to me that anything that plays music is on the client side of things and not the server side, so one would think that this is an oversight in not supporting .ogg files in target_speaker.  I mean, there's already logic somewhere to look at the file extension when playing the worldspawn music (it needs to know this in order to pass the file to the proper sound decoder), so I think making this change would be backward compatible with older maps that only use .wav files.

But again, iwthout looking at the code, I'm just guessing here  Undecided

PS:  Thanks for showing me how to post a bug but I'll wait (or let) other more experienced coders look at it first and decide if indeed it should be reported as a bug.

Cheers!
-Claude.
Logged
Gig
In the year 3000
***

Cakes 45
Posts: 4394


WWW
« Reply #14 on: May 10, 2013, 10:38:21 AM »

I mean, there's already logic somewhere to look at the file extension when playing the worldspawn music (it needs to know this in order to pass the file to the proper sound decoder), so I think making this change would be backward compatible with older maps that only use .wav files.
Yes... what I don't know is if the engine tweaks/workarounds that already allow to search for .ogg files other than for .wav (transparently to the gamecode, because working with old mods) in other parts of the game (background music, character sounds... others?), have already dealt with gamecode that automatically adds ".wav" extension if missing, or not.

I don't even know if worldspawn music does an "automatic search for ogg before -or after?- wav" at all:
I've just looked into oa_akomdm2.map, and I see that Akom specifed the .ogg extension in the key ("music" "music/OA02.ogg")... I have not tested yet what happens if writing "music/OA02" or "music/OA02.wav" instead and recompiling the map.

For characters sounds, instead, I suppose the "automatic search for ogg before -or after?- wav" is really working (unless the model itself has got a way to manually specify which sound files to use, but I don't think so).
« Last Edit: May 14, 2013, 12:06:00 AM by Gig » Logged

I never want to be aggressive, offensive or ironic with my posts. If you find something offending in my posts, read them again searching for a different mood there. If you still see something bad with them, please ask me infos. I can be wrong at times, but I never want to upset anyone.
CGB01
Half-Nub


Cakes 2
Posts: 63



« Reply #15 on: May 10, 2013, 11:24:13 AM »

I mean, there's already logic somewhere to look at the file extension when playing the worldspawn music (it needs to know this in order to pass the file to the proper sound decoder), so I think making this change would be backward compatible with older maps that only use .wav files.
Yes... what I don't know is if the engine tweaks/workarounds that already allow to search for .ogg files other than for .wav (transparently to the gamecode, because working with old mods) in other parts of the game (background music, character sounds... others?), have already dealt with gamecode that automatically adds ".wav" extension if missing, or not.

Right, that line of code would have to be removed (the strstr and adding the .wav is missing), so any maps that did not specify the file extension would not longer work.  For backwards compatibility (for those that didn't specify the file extension (DOH!)) you'd have to change the check to thee following;

if (!strstr( s, ".wav" ) && ! strstr( s, ".ogg)) ) {
                Com_sprintf (buffer, sizeof(buffer), "%s.wav", s );


If neither extension is present, then add the .wav extension.  I think that would do for that section of code, you'd still have to make sure the event queue code passes the filename to the proper sound driver (and I have no idea which file that's in Smiley ).

Logged
Gig
In the year 3000
***

Cakes 45
Posts: 4394


WWW
« Reply #16 on: May 10, 2013, 01:22:20 PM »

I don't know how to fix it... however we have to assure compatibilty with existing maps, mods and both at the same time (old and new maps, old and new mods, new mods with old maps, old mods with new maps).
Logged

I never want to be aggressive, offensive or ironic with my posts. If you find something offending in my posts, read them again searching for a different mood there. If you still see something bad with them, please ask me infos. I can be wrong at times, but I never want to upset anyone.
fromhell
Administrator
GET A LIFE!
**********

Cakes 35
Posts: 14520



WWW
« Reply #17 on: May 10, 2013, 08:41:57 PM »

Ioq3 had ogg playback but OA has had a hack to look for ogg files if a wav isn't found (for getting ogg sound effects to work). It could be done more seamlessly though
Logged

asking when OA3 will be done won't get OA3 done.
Progress of OA3 currently occurs behind closed doors alone

I do not provide technical support either.

new code development on github
CGB01
Half-Nub


Cakes 2
Posts: 63



« Reply #18 on: May 13, 2013, 05:25:11 PM »

Ioq3 had ogg playback but OA has had a hack to look for ogg files if a wav isn't found (for getting ogg sound effects to work). It could be done more seamlessly though

Yes... Huh
Logged
Gig
In the year 3000
***

Cakes 45
Posts: 4394


WWW
« Reply #19 on: June 05, 2013, 09:37:00 AM »

I was thinking again about this (after some time, so I may repeat something someone previously said)... I think that at engine level it should be possible to have the engine take care of the filename to search for after the gamelogic already determined it. I mean, if you tell the editor to just use "sound" or "sound.wav", the game logic searches for "sound.wav" anyway... the engine actually searches for it, and if it does not exist, it should search for "sound.ogg". Even if it does not it yet, I think it should be possible to modify the engine that way (then with the map creator having to do not specify the .ogg suffix at all... however we may further tweak the engine to tell it to search for sound.ogg if the gamecode tells to search for sound.ogg.wav).

Did you already try to tell the map to search for "path/filename.wav" and place a file named "filename.ogg" in the right path? What did happen?
« Last Edit: June 05, 2013, 09:43:57 AM by Gig » Logged

I never want to be aggressive, offensive or ironic with my posts. If you find something offending in my posts, read them again searching for a different mood there. If you still see something bad with them, please ask me infos. I can be wrong at times, but I never want to upset anyone.
fromhell
Administrator
GET A LIFE!
**********

Cakes 35
Posts: 14520



WWW
« Reply #20 on: June 05, 2013, 01:29:12 PM »

You mean like this patch?
Logged

asking when OA3 will be done won't get OA3 done.
Progress of OA3 currently occurs behind closed doors alone

I do not provide technical support either.

new code development on github
Gig
In the year 3000
***

Cakes 45
Posts: 4394


WWW
« Reply #21 on: June 05, 2013, 11:53:18 PM »

You mean like this patch?

Interesting. Being dated 2007, I can guess it's already in OA engine. Does that theoretically affect any sound, including those from target_speaker, or not?
I was curious to know from CGB01 what happens if he does specify sound.wav in the map, but places a sound.ogg in its place.
« Last Edit: June 06, 2013, 06:31:41 AM by Gig » Logged

I never want to be aggressive, offensive or ironic with my posts. If you find something offending in my posts, read them again searching for a different mood there. If you still see something bad with them, please ask me infos. I can be wrong at times, but I never want to upset anyone.
CGB01
Half-Nub


Cakes 2
Posts: 63



« Reply #22 on: June 06, 2013, 05:38:10 AM »

You mean like this patch?

Interesting. Being dated [http://www.mancubus.net/svn/openarena/source/ioq3_1106_oggsub.diff?op=log& 2007], I can guess it's already in OA engine. Does that theoretically affect any sound, including those from target_speaker, or not?
I was curious to know from CGB01 what happens if he does specify sound.wav in the map, but places a sound.ogg in its place.

Nothing happened.  All you get is a warning message in the console stating it's using the default sound for sound.wav file.

Logged
Pages: [1]
  Print  
 
Jump to: