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

Pages: [1]
1
Audio / Microphone capure and play
« on: January 16, 2018, 11:15:14 pm »
Hi,
I want to record audio from microphone and play it while its recorded so that i can hear myself in real time (small delay is not a problem). What i came up with is something like this:
 sf::SoundBufferRecorder recorder;
    auto success = recorder.setDevice(avaibleDevices[0]);

    std::cout <<"recorder set device: " << success << std::endl;
    McirophoneStream stream;
    recorder.start();
    while(1){
         recorder.start();
        const sf::SoundBuffer& buffer = recorder.getBuffer();
         sf::sleep(sf::seconds(0.01f));
         recorder.stop();
        stream.load(buffer);

                stream.play();

    }
 

The problem is that the output sound is incomplete and with a litle echo effect.
I tried to get rid of the sleep functions but that resulted in failures
Unsupported number of channels (0)
Failed to play audio stream: sound parameters have not been initialized (call initialize() first)

At the end of the day my goal is to record sound, play it on speakers and maybe add some effects in between. Is there a way to achieve that?

Pages: [1]
anything