Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Jesse

Pages: [1] 2
1
Feature requests / Window rendering and event processing in Windows
« on: March 08, 2009, 02:57:46 am »
Quote from: "jdindia"
I think that's just windows being stupid.  There are lots of cases of that.  For example your app will basically pause while the user is resizing the window.  The default window proc is dumb.  =/

Agreed.

However, it seems there are ways to work around it. A lot of applications (mostly commercial ones) manage to update the rendering area continuously as you move the window around. A few examples:

Windows Media Player
World of Goo
Applications based on Haaf's Game Engine

Other applications 'blank out' the area that's dragged of the screen, but don't have the 'smearing' effect. Marble Blast Gold and Q3-engine-based games are examples of apps that have this behavior.

So I know it can be worked around, and for me at least, having the window continue to render correctly as it's moved around is an important bit of polish for a production-quality app to have. Unfortunately, it doesn't seem that it's entirely straightforward to do. (Solutions I've seen proposed include installing a timer to trigger periodic redraws, or just running everything but the event loop in a separate thread.)

2
Feature requests / Window rendering and event processing in Windows
« on: March 08, 2009, 01:39:55 am »
Currently, if you create a windowed SFML application in Windows (XP - haven't tried Vista), and then drag the window partway off of and then back onto the screen, you get a 'smearing' visual artifact due to the window not updating until the mouse button is released.

Most of the other cross-platform libraries I've tried (SDL, GLFW, etc.) have the same behavior. I've looked into the issue a bit, and unfortunately, it doesn't look like it's entirely trivial to solve, and I imagine fixing this behavior in SFML would probably require significant restructuring of the windowing and events system.

Nevertheless, I thought I'd throw it out there. I've been wrestling with this issue (my project currently uses SDL), and will probably end up re-writing the app to use the native Windows API in order to work around it. In some contexts this 'smearing' probably isn't that big a deal, but for other applications, having the window continue to render correctly as it's moved around the screen can be important.

(This issue may already be in the roadmap, but if so I didn't spot it. Also, if there's a way to work around this problem in SFML, I'd be interested to know about it.)

3
Audio / Looping a music from a certain point
« on: March 03, 2009, 07:11:35 pm »
Quote
By the way, can you confirm that the last audio fix works for you?

Seems to be fixed - I tried my example program from the other thread with the newest debug build, and received no errors :)

4
Audio / Looping a music from a certain point
« on: March 03, 2009, 04:54:49 pm »
Quote
By the way, can you confirm that the last audio fix works for you?

Absolutely, I'll try it in the next couple of days and post back.

5
Audio / Looping a music from a certain point
« on: March 03, 2009, 04:25:57 pm »
Quote
...it's rather a higher-level feature.

True. And as you pointed out earlier, this sort of feature could probably be implemented using sf::SoundStream if someone really needed it.

6
Audio / Looping a music from a certain point
« on: March 03, 2009, 03:39:37 pm »
Just posting a quick follow-up in case anyone finds this thread in the future. Although my 'looping music from an arbitrary point' code worked fine on my PC, I found that it didn't work so well in OS X. I'm not sure why (maybe because my Mac is underpowered relative to the PC, or just because I was doing something wrong), but it seemed that the culprit was ov_pcm_seek(), which was taking too long and hanging up the sound thread.

I think this could probably be addressed via multithreading, but that would have been a lot of work :) So instead I switched to a 'track queuing' system. In this system it's only ever necessary to rewind to the beginning of a track, but multiple tracks can be linked in sequence, with seamless transitions between them. This allows you to do the same thing (intro+loop with proper effects carryover), and also offers additional flexibility in that you can create arbitrarily complex arrangements without using unreasonable amounts of memory.

Since it doesn't involve seeking, 'track queuing' might be an easier feature to add to SFML, and wouldn't require switching to another ogg decoding library. (In fact, now that I'm not using the 'seek' feature, I might try switching to stb_vorbis, since it's more lightweight.)

7
Audio / Looping a music from a certain point
« on: March 01, 2009, 07:49:04 pm »
Quote
If you could find a way to do this using SoundStream and the ogg libs, could you share your code, possible even uploading it onto the wiki?

I don't know if I'll be able to work up a complete, working example (my current code uses SDL_mixer, and would require some revision to work with SFML), but I can at least offer some ideas as to how it might be done.

The first step would be to get the Ogg Vorbis library built and/or installed, and become familiar with the basics of its use. You can find the docs here.

I started by just loading the entire ogg file into memory and playing it back normally (i.e. not streamed). Obviously you won't want to do it this way in practice, but this way you can get familiar with the Vorbis library, and be sure that the basics are working.

Now, looking at the SoundStream docs, I see two functions of interest, OnStart() and OnGetData(). I'm going to venture a guess that OnStart() is called when streaming begins (e.g. in response to a play request), and OnGetData() is called whenever the buffer needs to be refilled.

The Chunk struct appears to contain a buffer of signed 16-bit samples, the size of which is determined by NbSamples. This will need to be filled (presumably) with raw audio extracted from the ogg stream.

You'll need to make sure that the format of the ogg data matches the current audio format. Technically, ogg files can have multiple bitstreams, each with its own sample rate, and even number of channels. I don't know how often this happens in practice though. I've made allowances for it in my code, but as far as I can tell, all the ogg files I'm using only have one bitstream. In short, if you can be sure that the format of the ogg file will match the current audio format, you won't need to perform any conversions and can just copy the ogg audio data directly to the buffer.

If it sounds a bit complicated, I suppose it is (it took me a couple of days to get it all working), but the payoff is seamlessly looped music tracks with the option of arbitrary loop points (which, IMO, is pretty much necessary for a polished, professional game, since looping back to the beginning of a music track can be fairly unnatural if the music is not completely dry).

Also, although I mentioned it earlier, I'll mention again that 'normal' looping works correctly and seamlessly in the current SVN version, so if you're still using the latest binary, you might try compiling from source and see if that fixes the lag issue.

Sorry I can't provide a complete code example right now, but feel free to ask if you have any questions about any of the above.

8
Audio / Looping a music from a certain point
« on: February 28, 2009, 07:45:17 pm »
Quote
Can't you do the same thing by inheriting from sf::SoundStream?

Quite possibly! I will look into it :)

9
Audio / Looping a music from a certain point
« on: February 28, 2009, 05:10:47 pm »
I've been dealing with this issue as well, so I thought I'd share the info I've gathered so far.

I recently posted to this forum regarding seamless music looping in SFML (you can find the thread here). Laurent was nice enough to add support for seamless looping, and as far as I can tell this now works correctly in the current SVN version.

At this point though I'm still using SDL_mixer because (like the OP) I need support for looping from a specific loop point rather than from the beginning of the track.

Now, SDL_mixer doesn't offer this feature either, but it exposes a 'music hook' callback that allows you to do the music mixing yourself. Currently I'm doing the decoding myself using the Ogg Vorbis library, and feeding the data to SDL_mixer via the music mixing callback.

For looping, I'm using the function ov_pcm_seek(), which is documented here. As far as I can tell there's no mention of any seeking inaccuracy in the docs, and I haven't had any problems with it so far. Perhaps the Ogg Vorbis library is able to seek with no error?

If in fact the Ogg Vorbis library is able to do this while stb_vorbis cannot, then perhaps this is a feature that could be added to SFML (either by switching to Ogg Vorbis, or by finding a way to add support for seeking to stb_vorbis). From my point of view at least, seamless looping from arbitrary loop points would really make the 'music' part of the SFML audio API complete (if it would be of any help I'd be glad to share my decoding/looping code, although there's nothing really mysterious about it).

10
Audio / Seamless music looping
« on: February 22, 2009, 11:53:40 pm »
Quote from: "Ceylo"
Could you give a minimal example that produces this error ?

Actually, the issue seems to have been resolved by switching from the debug to the release versions of the SFML frameworks.

In case you're interested, here's the test program I was using:

Code: [Select]
#include <iostream>
#include <SFML/Audio.hpp>

int main()
{
    sf::Music music;
    music.OpenFromFile("music.ogg");
    music.Play();

    char c;
    std::cin >> c;
}


When using the debug version of the SFML audio framework, this generated a couple of different errors, depending on which version of the OpenAL framework was used. With the version of OpenAL currently available on the OpenAL website, I got:

Code: [Select]
An internal OpenAL call failed in Sound.cpp (41) :
AL_INVALID_OPERATION, the specified operation is not allowed in the current state


When first playing the music track. With the version of OpenAL that installs along with OS X, I was getting:

Code: [Select]
An internal OpenAL call failed in SoundStream.cpp (276) :
AL_INVALID_OPERATION, the specified operation is not allowed in the current state

On shutdown (or when calling Stop() on the music object).

I'm guessing this is just a case of user error related to using the wrong frameworks. I figured I'd go ahead and post the above information though, just in case.

Thanks,
Jesse

11
Audio / Seamless music looping
« on: February 21, 2009, 10:58:55 pm »
Quote from: "Laurent"
Unfortunately, I can't reproduce this problem on Windows.

Do you have an OS X system that you can test SFML on as you make changes? Or are you currently Windows-only?

If you can test it on a Mac, I'd be interested to know if you get the same results (and if not, what versions of OS X and OpenAL you're using, and whether your Mac is PowerPC or Intel).

Whether or not you can test it in OS X, I'll keep investigating - if I manage to figure out what's causing the bug, I'll let you know :)

Thanks,
Jesse

12
Audio / Seamless music looping
« on: February 21, 2009, 03:37:26 pm »
Every time.

I'll investigate further over the weekend and try to post back with some more useful information (if you haven't solved the problem by then, that is :).

13
Audio / Seamless music looping
« on: February 21, 2009, 01:07:11 am »
I tried it out with a number of different .ogg files, and they all looped perfectly! :)

So far I've only tried it in OS X. The looping works great, but stopping the music generates the following error:

Code: [Select]
An internal OpenAL call failed in SoundStream.cpp (276) : AL_INVALID_OPERATION, the specified operation is not allowed in the current state

Which refers to this line of code:

Code: [Select]
ALCheck(alDeleteBuffers(BuffersCount, myBuffers));

On one occasion it dropped into the debugger instead, but I haven't been able to reproduce that.

Previously I was using the last official SDK release. It didn't have this problem, so I'm assuming it's been introduced since then.

I'm running OS X 10.5.6 on a PowerPC Mac. Please let me know if there's any other info I can provide that would be useful :)

14
Audio / Seamless music looping
« on: February 20, 2009, 10:54:53 pm »
I'll try it out and let you know how it goes :)

15
Audio / Seamless music looping
« on: February 20, 2009, 12:24:06 am »
Cool, thanks for the info.

I've tested a variety of .ogg files with several different sound libraries - BASS, FMOD, and IrrKlang are all able to loop the files seamlessly, while SDL_mixer and SFML introduce a gap or audio glitch at the loop point. I know SFML uses OpenAL under the hood - I haven't tried looping streamed audio directly using OpenAL, but Unity uses OpenAL as well and as far as I can tell it's able to loop .ogg files seamlessly.

Anyway, I just thought I'd share that info, in case it's useful. I have my own open-source project, so I know it's not easy to meet everyone's needs or fulfill every feature request :) For what it's worth though, I'd switch to SFML without a second thought if it were able to loop streamed audio seamlessly (not everyone needs this feature, I don't think, but with rhythmic or electronic music it's hard to do without).

Pages: [1] 2
anything