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 - Computer Mail

Pages: [1]
1
Audio / Re: Capturing sound then play it
« on: May 05, 2017, 08:13:44 pm »
Thank you for replying, yes all devices are good, i just found my problem, it was i had to add a loop again after to play the sound.

2
Audio / Capturing sound then play it
« on: May 05, 2017, 05:49:24 pm »
Hello,

i followed this tutorial https://www.sfml-dev.org/tutorials/2.4/audio-recording.php to capture a sample then play it, here is the code:
#include <iostream>
#include <string>
#include <chrono>
#include <SFML/Audio.hpp>
#include <SFML/Audio/SoundBuffer.hpp>
#include <SFML/Audio/SoundBufferRecorder.hpp>
#include <SFML/Audio/Sound.hpp>


unsigned long int a=1,b=0;


int main(){

if (!sf::SoundBufferRecorder::isAvailable()){std::cout<<"ERROR NO DEVICE FOUND";}

sf::SoundBufferRecorder recorder;


recorder.start();

while(a){

        ++b;

        if(b>2000000000){

                --a;}}

recorder.stop();


const sf::SoundBuffer& buffer = recorder.getBuffer();

std::cout<<"PROGRAM SUCCESSFUL"<<std::endl;

sf::Sound sound;

sound.setBuffer(buffer);

sound.play();

return 0;}

It is supposed recording a sample then play it but all what i get is PROGRAM SUCCESSFUL after time of the loop, i followed exactly all that tuto and have required devices (microphone and speakers), could someone help me to correct my mistakes ?

Pages: [1]
anything