SFML community forums

Help => Audio => Topic started by: kobilica on December 22, 2011, 11:06:23 pm

Title: SFML 2 sf::SoundRecorder
Post by: kobilica on December 22, 2011, 11:06:23 pm
Hello, this code:

Code: [Select]

class Recorder : public sf::SoundRecorder
{

    virtual bool OnProcessSamples(const sf::Int16* Samples, std::size_t SamplesCount)
    {
        cout << *(Samples+1000) << "\n";
        return true;
    }

};


Outputs me (from console) this kind of numbers:

Code: [Select]

0
-6
4
1
-8
-4
0
9
-2
7
-3
-3
2
-8
-5
-2
5
6
-4
-2
-7
-1
6
2
-15
-8
-4
-2
-2
2
-1
2
-1
-1
0
3
-5
-3


no matter what, if audio is playing or not, numbers are same.

I have X-FI, and I use "What u hear" as a recording input.

Now, what I want to know, does SFML always records from default audio device, and always records from microphone?

Hint, I want to make realtime audio visualizator.
Title: SFML 2 sf::SoundRecorder
Post by: Laurent on December 22, 2011, 11:11:45 pm
Don't be afraid to use the "Edit" button, instead of creating a new thread just because you forgot to say something...

Yes, SFML always records from the default device.
Title: SFML 2 sf::SoundRecorder
Post by: kobilica on December 26, 2011, 07:32:08 pm
Heh, looks like I didn't really had set up my "what u hear" device properly. It's working now, thanks.
Title: SFML 2 sf::SoundRecorder
Post by: kobilica on December 29, 2011, 01:02:51 pm
Hello, I just wanted to ask, how can I speed up refresh rate? Right now it is 10 times per second, how can I make that atleast 40 times per second? Thanks.
Title: SFML 2 sf::SoundRecorder
Post by: Laurent on December 29, 2011, 01:15:56 pm
The current version doesn't allow you to change the processing rate. You must change it in the SoundRecorder.cpp (there's a sf::Sleep(100) somewhere) and recompile SFML.
Title: SFML 2 sf::SoundRecorder
Post by: kobilica on December 29, 2011, 04:14:44 pm
Ok, thanks, will do!
Title: SFML 2 sf::SoundRecorder
Post by: kobilica on January 05, 2012, 09:59:51 pm
Hello. I have encountered new problem. I have set sf::Sleep(20), which should gave me ~882 Samples (44100/50) 50=1000ms/20ms.
But it always gives me 2205 samples, which should happen at sf::Sleep(50).

I suspect I have to change something, but don't know what.
Title: SFML 2 sf::SoundRecorder
Post by: Laurent on January 05, 2012, 10:17:04 pm
Nop, it should work. Either it's what you do in OnProcessSamples which takes these extra 30 ms, or it's your OS' scheduler that has a very high resolution.
Title: SFML 2 sf::SoundRecorder
Post by: kobilica on January 06, 2012, 01:06:28 am
I have sf::Clock, which resets at begining of OnProcessSamples and outputs number at end of it. It takes only 2ms max to process everything.

So, it's my OS  scheduler thing... how can I change that? I use Win 7.
Title: SFML 2 sf::SoundRecorder
Post by: kobilica on January 06, 2012, 01:07:53 am
http://www.facebook.com/photo.php?v=3034090137048

Also, FFT is working!
Title: SFML 2 sf::SoundRecorder
Post by: Laurent on January 06, 2012, 07:55:54 am
Windows 7 is not supposed to have such a bad resolution. Can you try sf::Sleep with different numbers? Like 1, 5, 10, 15, ...
Title: SFML 2 sf::SoundRecorder
Post by: kobilica on January 06, 2012, 03:22:38 pm
I will. Gonna report soon  8)
Title: SFML 2 sf::SoundRecorder
Post by: kobilica on January 06, 2012, 03:54:18 pm
No difference. Still 2205 Samples.
Title: SFML 2 sf::SoundRecorder
Post by: Laurent on January 06, 2012, 04:35:42 pm
Hmm... Maybe an internal limitation in OpenAL.
Title: SFML 2 sf::SoundRecorder
Post by: kobilica on January 09, 2012, 09:13:19 am
so is there any posibilities that i speed up this? should i recompile openal or something?
Title: SFML 2 sf::SoundRecorder
Post by: Laurent on January 09, 2012, 09:14:06 am
I don't know, I have to do some tests and investigations.
Title: SFML 2 sf::SoundRecorder
Post by: kobilica on January 09, 2012, 12:45:23 pm
Ok sweet! Then I will continue developing and then later update sfml. It would be nice, if you could run onprocesssamples every so captured samples (like every 2048 samples)
Title: SFML 2 sf::SoundRecorder
Post by: kobilica on January 10, 2012, 03:16:36 am
Or, don't stretch yourself much, I found CLAM library, gonna try infuse it with SFML.
Title: SFML 2 sf::SoundRecorder
Post by: kobilica on March 13, 2012, 05:18:05 pm
Or I could use little help  :lol: I really need to speed up this, I don't want to mess with CLAM yet.
Title: SFML 2 sf::SoundRecorder
Post by: Laurent on March 13, 2012, 05:51:51 pm
Sorry but I won't have the time to investigate this now. I'm very busy with the release of SFML 2.