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.


Topics - smith199910

Pages: [1]
1
Audio / Operating with sample rate
« on: January 05, 2017, 06:04:12 pm »
I am taking half second samples of audio.
I would like to collect a large amount of audio data in that time
What timing is setSampleRate() in?
What sample rate would you suggest?

2
Audio / Music from buffer
« on: December 21, 2016, 05:27:24 pm »
// 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[]) {
        //check if audio capture is available
        if (!sf::SoundBufferRecorder::isAvailable())
        {
                std::cout << "error: audio capture is not available on this system" << std::endl;
                std::cin.get();
        }
        else
        {
                // create the recorder
                HandleSamples sampler;
                std::vector<std::string> devices = sampler.getAvailableDevices();
                std::cout << !devices.empty() << std::endl;
                if (!(devices.empty())) {
                        HandleSamples sampler;
                        sampler.setDevice(devices.at(0));
                        sampler.start();
                        std::cout << "sampler has started" << std::endl;
                        Sleep(1000000);
                        sampler.stop();
                }
                else
                        // handle if no microphone can be detected
                {
                        std::cout << "error: There is no audio input device detected on this system" << std::endl;
                        std::cin.get();
                }
               
               
        }
}
void handlePitch(float pitch) {
        std::cout << pitch << std::endl;
}

 



//sampler.cpp
#include "stdafx.h"
#include <SFML\Audio.hpp>
#include <thread>
#include <iostream>
#include "MethodHeaders.h"
bool HandleSamples::onProcessSamples(const sf::Int16* samples, std::size_t sampleCount) {
        sf::Music music;
        music.openFromMemory(samples, sampleCount);
        float pitch = music.getPitch();
        music.play();
        handlePitch(pitch);

        return true;
}

This is the error I get.
Failed to open sound file from memory (format not supported)
Failed to play audio stream: sound parameters have not been initialized (call initialize() first)
 

How would I fix this?

3
Audio / I am new to SFML how do i save buffers
« on: December 20, 2016, 05:10:47 pm »
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)

Pages: [1]