#include <iostream>
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <fftw3.h>
#include <Windows.h>
int main()
{
// Create the main window
sf::RenderWindow window(sf::VideoMode(800, 600), "OUR TEST");
sf::SoundBuffer buffer;
sf::Sound sound;
if (!buffer.loadFromFile("Etherwood - Spoken.wav"))
{
std::cout << "ERROR"<<std::endl;
}
sound.setBuffer(buffer);
sound.setVolume(25);
std::cout << "Sample Rate: " << buffer.getSampleRate() << std::endl;
while (window.isOpen())
{
// Process events
sf::Event event;
while (window.pollEvent(event))
{
/*while (sound.getStatus() == sf::Sound::Playing) {
std::cout << buffer.getSamples() << std::endl;
Sleep(400);
}*/
switch (event.type)
{
case sf::Event::Closed:
window.close();
break;
case sf::Event::KeyPressed:
if (event.key.code == sf::Keyboard:: P)
{
sound.play();
}
if (event.key.code == sf::Keyboard::Escape)
window.close();
break;
}
}
window.clear();
window.display();
}
return EXIT_SUCCESS;
}
This is my entire code. I run the getSamples() on the buffer.
I want to get a real time array from my buffer that is streaming the audio