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:
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
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?
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();
}
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)
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?