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 - MrShedman

Pages: [1]
1
Audio / Re: Getting a sample buffer in sync with music's own.
« on: March 31, 2014, 11:46:34 pm »
In the previous thread I linked there was a delay between the samples being analysed (roughly 2 seconds for a 44.1kHz sound) and the ones actually being played through the speakers. You suggested lowering the buffer size in sf::Music although pointed out there would still be a delay, only smaller and that the music might not play smoothly.

I thought I could just use a simple queue to store the 3 buffers and use the "oldest" one for FFT analysis. When new samples were loaded I would push them into the queue and just pop the "oldest" one. It doesn't work and is still roughly 2 seconds infront.

I would've thought this would solve the delay caused by the triple buffering in sf::Music, but it doesn't and I can't figure out why....I probably dun goofed somewhere.


2
Audio / Getting a sample buffer in sync with music's own.
« on: March 31, 2014, 10:55:25 pm »
I'm trying to visualize an FFT using the sf::Music class. However my visualization happens 2 or so seconds before what gets played which is what I expected.

I'ts pretty easy to do this just by using an sf::SoundBuffer on it's own but then there is a 3-4 second delay loading the file and easily 100mb+ memory usage.

Having read this thread I can't understand why I cannot simply do this:


class FFT: public sf::Music
{
public:

        app()
        {
                loadFromFile("music.ogg");
                play();
        }

        void input()
        {
                standard event stuff...
        }

        virtual bool onGetData(sf::SoundStream::Chunk& data)
        {
                bool result = sf::Music::onGetData(data);

                chunkQ.push(data);

                if (chunkQ.size() > bufferCount)
                {
                        chunkQ.pop();
                }

                chunkData = chunkQ.front();

                return result;
        }

        void render()
        {
                rendering vertex array....
        }
       
        void update()
        {
                crazy FFT shit going on here....
        }

        void run()
        {
                typical run loop....
        }

private:

        sf::SoundStream::Chunk chunkData;
        std::queue<sf::SoundStream::Chunk> chunkQ;

        window, vertex array, other stuff not important
};
 

3
Graphics / Re: Tilemap rendering issues
« on: March 08, 2014, 05:34:23 am »
It does seem strange although I found this "hack" in several forums and the general reasoning behind it was AMD/nVidia round floating point numbers differently.

I'm using whatever was the latest revision on github about a month ago, so as far as I can see from the commits nothing has been changed that would affect this.


4
Graphics / Re: Tilemap rendering issues
« on: March 07, 2014, 02:51:04 am »
After hours of googling and several dodgy hacks later I came upon one method that works 100% on all of my different set-ups!

float x = view.getCenter().x;
float y = view.getCenter().y;

x = std::floor(x);
y = std::floor(y);
x += 0.375f;
y += 0.375f;

view.setCenter(x, y);

I was already rounding the views co-ords to integers, but adding 0.375f draws the tiles pixel-perfect every time! :D

5
Graphics / Re: Tilemap rendering issues
« on: February 25, 2014, 11:41:13 pm »
Each tile in my tileset texture is 48x48 and the same on screen, so the 1:1 mapping shouldn't be the problem.

The tilemap is never moved, only the view is moved and each tile on startup is given and integer position and size (although casted to a float to work with sf::Vertex)

The code below is what I'm using to draw the tilemap.

void draw()
{
        sf::View view = window->getView();
        float cx = view.getCenter().x;
        float cy = view.getCenter().y;
        float x = cx - window->getSize().x / 2;
        float y = cy - window->getSize().y / 2;
        cx = std::floor(cx);
        cy = std::floor(cy);

        view.setCenter(cx, cy);
        rTexture.setView(view);

        rTexture.clear(sf::Color::Transparent);
        rTexture.draw(*map);
        rTexture.display();

        const sf::Texture& texture = rTexture.getTexture();

        // draw it to the window
        sf::Sprite sprite(texture);
        sprite.setPosition(x ,y);

        window->draw(sprite);
}
 

6
Graphics / Tilemap rendering issues
« on: February 25, 2014, 11:04:53 pm »
Can anyone explain why I get these rendering quirks on different GPU's?

AMD HD5850: Looks perfect no artifacts :D


nVidia Gefore GT 740M: Some tiles shift upwards/downards by 1 pixel but leave no gaps


Intel 4400:  Only horizontal gaps and weird shifting inside the tiles

Pages: [1]
anything