This is the Difficult code:
// SFML 1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <SFML\Audio.hpp>
#include <Windows.h>
#include <thread>
#include <iostream>
#include "MethodHeaders.h"
#include <string>
#include <string.h>
int main(int nNumberOfArgs, char *pszArgs[])
{
if (sf::SoundBufferRecorder::isAvailable())
{
std::vector<std::string> devices = sf::SoundRecorder::getAvailableDevices();
// Record some audio data
sf::SoundBufferRecorder recorder;
if (devices.empty()) {
std::cout << "No available devices" << std::endl;
}
else
{
std::cout << "program has started" << std::endl;
recorder.setDevice(devices[0]);
while(true)
{
recorder.start();
recorder.stop();
// Get the buffer containing the captured audio data
// this makes a reference while i want a copy // const sf::SoundBuffer& buffer = r recorder.getBuffer();
// sample input stream by copy for frequencies 1 - 8, each in its own thread
// output frequency matches
//save recording to buffer
const sf::SoundBuffer buffer = recorder.getBuffer();
//save buffer to file
buffer.saveToFile("C:\\Users\\smithdus005\\Documents\\sample.ogg");
std::thread sample(sampleAudio);
std::thread play(playAudio);
sample.join();
play.join();
}
}
}
}
void playAudio() {
sf::Music music;
//change into music format
music.openFromFile("C:\\Users\\smithdus005\\Documents\\sample.ogg");
//play music
music.play();
}
void sampleAudio() {
sf::Music music;
//change into music format
music.openFromFile("C:\\Users\\smithdus005\\Documents\\sample.ogg");
//check pitch
float currentPitch = music.getPitch();
}
I get this error:
Failed to write ogg/vorbis file "C:\Users\smithdus005\Documents\sample.ogg" (unsupported bitrate)