Welcome,
Guest
. Please
login
or
register
. Did you miss your
activation email?
French forum
Home
Help
Search
Login
Register
SFML community forums
»
Help
»
Audio
»
Capturing sound then play it
Print
Pages: [
1
]
Author
Topic: Capturing sound then play it (Read 2681 times)
0 Members and 1 Guest are viewing this topic.
Computer Mail
Newbie
Posts: 4
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 ?
«
Last Edit: May 05, 2017, 05:55:07 pm by Computer Mail
»
Logged
eXpl0it3r
SFML Team
Hero Member
Posts: 11032
Re: Capturing sound then play it
«
Reply #1 on:
May 05, 2017, 06:03:41 pm »
Are you selecting the correct recording device?
Logged
Official FAQ:
https://www.sfml-dev.org/faq.php
Official Discord Server:
https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog:
https://duerrenberger.dev/blog/
Computer Mail
Newbie
Posts: 4
Re: Capturing sound then play it
«
Reply #2 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.
Logged
Print
Pages: [
1
]
SFML community forums
»
Help
»
Audio
»
Capturing sound then play it