OGG File Rendering - Page 2

OGG File Rendering

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: OGG File Rendering

Post by Argh »

I'd say it's not so much crippled, as lacking a method to access the file and perform any real stuff with it. It just sends it straight to the OGG DLL, pretty much. It totally works, it's just not quite detailed enough to work with via LUA.

It looked like it was reading chunk-by-chunk, though, in the code (er, don't slap me if I read that wrong, but that's what it looks like) so it could probably provide some sort of index location parameter that LUA could read, and use to call the music at the next index... or something.

Most games with streaming formats for music require you to leave the main UI to change volumes, etc... honestly, that might also be a good idea, just assigning a volume for "Streaming Files" in the Settings application, and using that as a multiplier of the volume sent when the file's supposed to start playing...
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: OGG File Rendering

Post by Argh »

Last modification: Rev 5684 - kloot - 2008-04-09 01:28:11 +0200 (Wed, 09 Apr 2008)
Log message:
add a PauseSoundStream Lua callout
Excellent- that solves the main problem! Can I use that frame-by-frame, to pause it, then restart it at a different volume level?

That'd give me enough for a stepped volume control. I am probably too dumb to design a slider in the UI (meh, my grasp of UI is still really terrible, but I am slowly getting somewhere), but at least I could do fade-in / fade-out...

<slaps self> Yes, I will go read the code now...
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: OGG File Rendering

Post by Argh »

Hrmm, doesn't appear that we can re-send the parameters when un-pausing. That's probably going to be necessary, imo, because otherwise the volume chop will be really obvious, 'specially if the "battle music" is louder and more strident than the "not fighting" music.

Ah well, better than nothing, it'll let me write the battle-detection code and flesh this out a little more, so that maybe it'll be worth sticking into the bundle of Gadgets that ship with World Builder (it's really totally generic code, so unlike some stuff, where I'll have to provide documentation and extricate it from the rest of the game, it'll be really appropriate for release in that package, imo).

Oh, and I didn't know we could apply a boolean to loop stuff... nor did I know that we are flat-out restricted to a single stream. I've corrected the Wiki... hmm... I should probably add a note about the single-stream thing, too.

So, just for the record everybody (who didn't already know, of course), it's extremely important that you make the play-length longer than the length of the stream, and / or kill the stream when it needs to be terminated to allow another stream to play. I do both, in my simple-minded theme-music app., but that is probably not real intuitive, unless you've read through the source.

Oh, and again... if anybody makes this VFS-compliant, please let me know.
User avatar
LordMatt
Posts: 3393
Joined: 15 May 2005, 04:26

Re: OGG File Rendering

Post by LordMatt »

Argh wrote:let me write the battle-detection code
Someone already wrote that for the dynamic music widget. If you want to use it and don't have a copy I can post it here.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: OGG File Rendering

Post by Argh »

TBH, I'd rather write my own, just to get a feel for it, and write the dynamic-volume step stuff as a part of the responsiveness code. I haven't done any event-driven stuff that operates on that scale yet.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: OGG File Rendering

Post by Argh »

Drat and Darnation!

It doesn't play from a SDZ or SD7 volume, even if the Lua is given an explicit path :P

I.E. "mods/PURE.sdd/Music/MyOgg.ogg" works great... "mods/PURE.sdz/Music/MyOgg.ogg" does not work, and says, "could not open ogg file".
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: OGG File Rendering

Post by Argh »

I've tested whether VFS can even find .OGG files, and no, it can't :|

I didn't know that this would be necessary when made into an SDZ archive, now that I've ready through the source for archive handling, I see I was wrong. Hopefully this is a relatively easy fix, and somebody has time to get to it, it's the only thing that's badly broken in P.U.R.E. atm, and I want to release the last Alpha...
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: OGG File Rendering

Post by lurker »

Argh wrote:Drat and Darnation!

It doesn't play from a SDZ or SD7 volume, even if the Lua is given an explicit path :P

I.E. "mods/PURE.sdd/Music/MyOgg.ogg" works great... "mods/PURE.sdz/Music/MyOgg.ogg" does not work, and says, "could not open ogg file".
Did you not read your own thread?


I can try to add a version that uses the vfs.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: OGG File Rendering

Post by Argh »

Sorry, I was a little sleep-deprived when ya said that bit. Yes, I need to have VFS working for this, there just isn't any other way.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: OGG File Rendering

Post by Argh »

Any progress on this?

I've looked over the code, and it appears (although meh, I may be wrong), after reading everything over, that you just need to link in the FileSystem include, and change a couple of lines in OggStream.cpp. OggStream just can't find directories unless they're raw right now, because it doesn't hook into the code dealing with 7zip / zip...
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: OGG File Rendering

Post by Kloot »

Argh wrote: (although meh, I may be wrong)
Quite. The issue with VFS'ing Oggs is that the OV library would then
require a raw FILE* to a mod archive (sdz, sd7) member, which can
not be obtained (for obvious reasons) through the VF handler. The
other option (copying every byte of some archived .ogg into a buffer
and then writing the buffer to a temporary file so it could be opened)
is even worse, and would royally defeat the point of the Ogg stream
format. Don't assume all things are as simple as #including a bunch
of headers please. ;)
User avatar
ILMTitan
Spring Developer
Posts: 410
Joined: 13 Nov 2004, 08:35

Re: OGG File Rendering

Post by ILMTitan »

So perhaps what we need to do is give Lua the ability to copy a file from the archive, or even simply write one (but into a limited scope on the hard drive). That would allow the music to be distributed in the archive, and simply automatically written to the hard-drive at the start of the first game, and read from there subsequently by a Lua music *get.

P.S. is *get good terminology for generic widget/gadget?
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: OGG File Rendering

Post by Kloot »

Very well, I'll add a Lua(UI) callout to do that.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: OGG File Rendering

Post by Argh »

Ah, I see. I was wondering about that. So... um, where's it going to be written, etc., and is this going to be automated, or am I going to need to rewrite my Gadget code to make use of this?
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: OGG File Rendering

Post by Kloot »

See revision 5838. If you have a "karaoke.ogg" in the virtual
directory "mods/PURE.sdz/music/", extract it *once* with the
call

Code: Select all

Spring.ExtractModArchiveFile("music/karaoke.ogg")
and then pass "music/karaoke.ogg" as the first parameter to
the PlaySoundStream callout. Do not extract anything at any
time except during initialization, large files *will* incur delays.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: OGG File Rendering

Post by Argh »

Okie doke! Sounds like I'll be in business, then, as soon as I can get home and modify the game.
User avatar
LOrDo
Posts: 1154
Joined: 27 Feb 2006, 00:21

Re: OGG File Rendering

Post by LOrDo »

Argh, would there be a possibility of you releasing your ogg player to the public after it is completed? God knows we are in need of one, and its definatly something that modders and players alike would be grateful of. :-)
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: OGG File Rendering

Post by Argh »

[EDIT]

It's not working, nevermind. Too tired to test it correctly. It created a directory in my Spring root, Kloot, but the Lua callout failed:

error = 2, LuaGadgets/gadgets.lua, [string "LuaRules/Gadgets/theme.lua"]:53: Could not create directory "Music/" for file "MyOgg.ogg"... relevant unsynced code reads:

Code: Select all

	function gadget:Initialize()
		Spring.ExtractModArchiveFile("Music/MyOgg.ogg")
	end
Um, given that it did, in fact, create the directory, do you have any idea what might be causing this to happen?

[/EDIT]

[FURTHER EDIT]

Ok, it works when I extracted it manually and placed the relevant files into the directory that was created. Therefore... it's either a file-system issue or maybe due to the fact that I didn't compress the SDZ... lemme test...

[EVEN FURTHER EDIT]

It appears that more's broken with VFS access from Lua.

As I said, it created the directory, "Music" in the root, then failed... and I have at least one Gadget broken, which was working before... it's almost like it doesn't have the path to the game, after creating that directory...

[FINAL EDIT]

Ok, it's some issue with VFS that occurs, *after* the callout to extract is made. After that, it no longer "knows" where files are, within the game. If I remove my music-player, then the Gadgets all run just fine. If I remove the extract line, the music Gadget fails, but everything else is all right. It's like it's all been assigned to new paths right after the Extract creates that directory, so all subsequent calls to the VFS (including the immediate step of copying / extracting the .oggs) are failing. If you want me to just send you a current build of the game to test all of this, I'll be happy to comply...
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: OGG File Rendering

Post by Kloot »

Please do. ;)
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: OGG File Rendering

Post by Argh »

K, I'll post ya a link soonish.
Post Reply

Return to “Engine”