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

Pages: [1] 2 3 ... 29
1
Audio / Re: No sound is played. (When loading with samples)
« on: January 28, 2016, 10:35:37 am »
Ok so how many elements should I put to hear the sound ?
 

PS : I've put 10 000 elements in the vector but I can't heart anything.

Code: [Select]
#include <SFML/Audio.hpp>
int main(int argc, char* argv[]) {
    std::vector<sf::Int16> samples;
    for (unsigned int i = 0; i < 1000000; i++)
        samples.push_back(1000);
    sf::SoundBuffer buffer;
    buffer.loadFromSamples(samples.data(),samples.size(),1,44100);
    sf::Sound sound;
    sound.setBuffer(buffer);
    sound.setLoop(true);
    sound.play();
    while (true) {}

    return 0;
}

2
Audio / No sound is played. (When loading with samples)
« on: January 27, 2016, 09:01:12 pm »
Hi!
I want to play an ultra sound but no sound is played.

Actually I'm on ubuntu 14.04 64 bits version.

Here is the code.

#include <SFML/Audio.hpp>
int main(int argc, char* argv[]) {
    std::vector<sf::Int16> samples = {10000};
    sf::SoundBuffer buffer;
    buffer.loadFromSamples(samples.data(),samples.size(),1,44100);
    sf::Sound sound;
    sound.setBuffer(buffer);
    sound.setLoop(true);
    sound.play();
    while (true) {}

    return 0;
}
 

I've turn down the frequency to listen if it works.

3
Graphics / Re: Problem with character size.
« on: January 21, 2016, 02:38:32 pm »
Ok, thanks.

4
Graphics / Re: Problem with character size.
« on: January 21, 2016, 01:52:50 pm »
Yes but I would like to be able to insert text in the text field cause I want to edit scripts into my editor.

So I've to set the same width for each character and when I click on text I want to set the cursor at the right position to insert text.

How can I do that ?

Isn't there any way to force character's width ?

Here's what I want to do :

unsigned int pos = text.findCharacterPos(mousePos);
text.insert(pos, caracter);
 

Thanks.


5
Graphics / Problem with character size.
« on: January 21, 2016, 11:27:49 am »
Hi!

I've a problem with the character size :

I want to make a text area, so, each time I enter text, I advance the cursor like this :

cursorPos.x += text.getCharacterSize();
 

The problem is that the cursor advance faster than the glyph.

So I don't think that the getCharacterSize function member is returning the right character size.

I've also difficulties to adapt text size to the size of my labels...

Is that method returning the size of one character ?

6
General / Why is sf::String removing unknow ascii characters ?
« on: December 31, 2015, 09:43:52 am »
Hi, I've coded a custom filedialog, the problem is when my std::string contains the character 'é' by example, the character is removed by sf::String and it fails to open my file.
std::string Label::getText() {
       return text.getString().toAnsiString();
}
 
std::string currentDir = lTop.getText();
std::cout<<fileName<<std::endl;
currentDir += "/"+fileName;
std::cout<<currentDir<<std::endl;
std::string currentDir = lTop.getText();
std::cout<<fileName<<std::endl;
currentDir += "/"+fileName;
std::cout<<currentDir<<std::endl;
lTop.setText(currentDir);
if (DIR* current = opendir(currentDir.c_str())) {
 
By exemple sf::String replace développement by dveloppement and I get a no such file or directory error. (Wtf  :o)
So I've just changed the type of sf::String to std::string into the sf::Text class and now it works.

There isn't any unicode version of the opendir function, so I really suggest you to don't remove unknow characters for ansi strings.

7
General / Re: When a support for a core context ?
« on: October 27, 2015, 07:24:25 pm »
And how can I create a context without the core profile ?

In the SFML source code I've seen that on windows it's a core profile which is created. O_O

Excepting in debug mode ...

With GLFW I haven't any problem ..., but when I create an opengl 3.3+ context with SFML the .exe crash. :/

For the moment I'm using GLFW, but, just wanted to mention that.


8
General / When a support for a core context ?
« on: October 26, 2015, 10:41:22 am »
Hi!

I've tried to create an opengl 4.2 core context on windows with SFML but it doesn't seem that SFML support it yet.

Only older versions of opengl are working.

So, when I execute a code with moddern opengl, it crash.

But with glfw I don't have any problem.

Do you plan to add an SFML support for modern opengl one day ?

9
Feature requests / Re: Multiple render target.
« on: May 05, 2015, 08:46:56 am »
You don't know what multiple render target is ?


10
Feature requests / Multiple render target.
« on: May 04, 2015, 09:22:37 pm »
Hi, I'm more and more interested by modern opengl for optimisation purposes, so I tend to get away more and more from SFML but I still like this library because it's really the library which one I've learned everything!

Now I'm finally able to display objects with modern opengl and then with instanced rendering and image load-store soon for my custom depth test and my order independant transparency algorithm, I'm just wondering, what'll be about SFML ?

Will you change the class rendertarget for multiple target rendering and add some modern opengl functionnalities like I do or will you just let SFML like it's now because it's sufficient for 2D games ?

11
Audio / Re: Sound which is repeating.
« on: April 03, 2015, 03:20:42 pm »
Yes I have still to change some classes for using RAII. :/


12
Audio / Re: Sound which is repeating.
« on: April 02, 2015, 10:20:35 pm »
Erf, wrong file, code block was still keeping my old project file so I've changed the wrong file.  >:(

13
Audio / Sound which is repeating.
« on: April 02, 2015, 10:01:01 pm »
Hi!
Sorry if my question is stupid and if I've missed something in the doc but :

I've created a custom audio stream like explained in the tutorial :

void Stream::load(const sf::SoundBuffer& buffer)
        {
            m_file = nullptr;
            // extract the audio samples from the sound buffer to our own container
            m_samples.assign(buffer.getSamples(), buffer.getSamples() + buffer.getSampleCount());

            // reset the current playing position
            m_currentSample = 0;

            // initialize the base class
            SoundStream::initialize(buffer.getChannelCount(), buffer.getSampleRate());
        }
        ////////////////////////////////////////////////////////////
        bool Stream::openFromFile(const std::string& filename)
        {
            // First stop the music if it was already running
            m_file = new priv::SoundFile();
            stop();

            // Open the underlying sound file
            if (!m_file->openRead(filename))
                return false;

            // Perform common initializations
            initialize();

            return true;
        }


        ////////////////////////////////////////////////////////////
        bool Stream::openFromMemory(const void* data, std::size_t sizeInBytes)
        {
            m_file = new priv::SoundFile();
            // First stop the music if it was already running
            stop();

            // Open the underlying sound file
            if (!m_file->openRead(data, sizeInBytes))
                return false;

            // Perform common initializations
            initialize();

            return true;
        }


        ////////////////////////////////////////////////////////////
        bool Stream::openFromStream(InputStream& stream)
        {
            m_file = new priv::SoundFile();
            // First stop the music if it was already running
            stop();

            // Open the underlying sound file
            if (!m_file->openRead(stream))
                return false;

            // Perform common initializations
            initialize();

            return true;
        }
        bool Stream::onGetData(Chunk& data)
        {
            Lock lock(m_mutex);
            if (m_file == nullptr) {
                // number of samples to stream every time the function is called;
                // in a more robust implementation, it would rather be a fixed
                // amount of time rather than an arbitrary number of samples
                const int samplesToStream = 50000;

                // set the pointer to the next audio samples to be played
                data.samples = &m_samples[m_currentSample];

                // have we reached the end of the sound?
                if (m_currentSample + samplesToStream <= m_samples.size())
                {
                    // end not reached: stream the samples and continue
                    data.sampleCount = samplesToStream;
                    m_currentSample += samplesToStream;
                    return true;
                }
                else
                {
                    // end of stream reached: stream the remaining samples and stop playback
                    data.sampleCount = m_samples.size() - m_currentSample;
                    m_currentSample = m_samples.size();
                    return false;
                }
            } else {
                // Fill the chunk parameters
                data.samples     = &m_samples[0];
                data.sampleCount = m_file->read(&m_samples[0], m_samples.size());

                // Check if we have reached the end of the audio file
                return data.sampleCount == m_samples.size();
            }
        }

        void Stream::onSeek(sf::Time timeOffset)
        {
            // compute the corresponding sample index according to the sample rate and channel count
            m_currentSample = static_cast<std::size_t>(timeOffset.asSeconds() * getSampleRate() * getChannelCount());
        }
        void Stream::initialize()
        {
            // Compute the music duration
            m_duration = seconds(static_cast<float>(m_file->getSampleCount()) / m_file->getSampleRate() / m_file->getChannelCount());

            // Resize the internal buffer so that it can contain 1 second of audio samples
            m_samples.resize(m_file->getSampleRate() * m_file->getChannelCount());

            // Initialize the stream
            SoundStream::initialize(m_file->getChannelCount(), m_file->getSampleRate());
        }
 

I've also created a class to play the song but I want to use only one class for playing sounds and musics :

Player::Player(SoundBuffer& buffer) {
             Stream* stream = new Stream();
             stream->load(buffer);
             this->stream = stream;
        }
        void Player::setAudioStream(SoundStream* stream) {
             this->stream = stream;
        }
        sf::SoundStream* Player::getAudioStream() {
            return stream;
        }
        void Player::play(bool loop) {
             stream->setLoop(loop);
             stream->play();
        }
        void Player::stop() {
             stream->stop();
        }
        void Player::pause() {
             stream->pause();
        }
        Player::~Player() {
            delete stream;
        }
 

The problem is that the sound is playing repeatively :

int main (int argv,char* argc[]) {
    sf::SoundBuffer buffer;
    buffer.loadFromFile("sounds/ballhurtbar.wav");
    odfaeg::audio::Stream stream;
    stream.load(buffer);
    odfaeg::audio::Player player;
    player.setAudioStream(&stream);
    player.play(false);
    const auto delay = sf::milliseconds(1);
    do {
        sf::sleep(delay);
    } while(stream.getStatus() == odfaeg::audio::Stream::Playing);
    return 0;
 

Isn't the sound supposed to be stopped when the onGetData method return false ?

Or I've I missunderstand something ?

14
Audio / Re: Sound who doens't play.
« on: April 02, 2015, 09:40:50 pm »
Arg right this is non blocking, sorry sorry.

15
Audio / Sound who doens't play.
« on: April 02, 2015, 07:46:49 pm »
Hi!

I'm trying to play a sound but it doesn't play :

int main() {
    sf::SoundBuffer buffer;
    buffer.loadFromFile ("sounds/ballhurtbar.wav");
    sf::Sound sound;
    sound.setBuffer(buffer);
    sound.play();
    return 0;
}
 

OS : ubuntu LTS 64 bits.
SFML version : 2.2.

Pages: [1] 2 3 ... 29