Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML 2 sf::SoundRecorder  (Read 10421 times)

0 Members and 1 Guest are viewing this topic.

kobilica

  • Newbie
  • *
  • Posts: 15
    • View Profile
SFML 2 sf::SoundRecorder
« 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML 2 sf::SoundRecorder
« Reply #1 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.
Laurent Gomila - SFML developer

kobilica

  • Newbie
  • *
  • Posts: 15
    • View Profile
SFML 2 sf::SoundRecorder
« Reply #2 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.

kobilica

  • Newbie
  • *
  • Posts: 15
    • View Profile
SFML 2 sf::SoundRecorder
« Reply #3 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML 2 sf::SoundRecorder
« Reply #4 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.
Laurent Gomila - SFML developer

kobilica

  • Newbie
  • *
  • Posts: 15
    • View Profile
SFML 2 sf::SoundRecorder
« Reply #5 on: December 29, 2011, 04:14:44 pm »
Ok, thanks, will do!

kobilica

  • Newbie
  • *
  • Posts: 15
    • View Profile
SFML 2 sf::SoundRecorder
« Reply #6 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML 2 sf::SoundRecorder
« Reply #7 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.
Laurent Gomila - SFML developer

kobilica

  • Newbie
  • *
  • Posts: 15
    • View Profile
SFML 2 sf::SoundRecorder
« Reply #8 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.

kobilica

  • Newbie
  • *
  • Posts: 15
    • View Profile
SFML 2 sf::SoundRecorder
« Reply #9 on: January 06, 2012, 01:07:53 am »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML 2 sf::SoundRecorder
« Reply #10 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, ...
Laurent Gomila - SFML developer

kobilica

  • Newbie
  • *
  • Posts: 15
    • View Profile
SFML 2 sf::SoundRecorder
« Reply #11 on: January 06, 2012, 03:22:38 pm »
I will. Gonna report soon  8)

kobilica

  • Newbie
  • *
  • Posts: 15
    • View Profile
SFML 2 sf::SoundRecorder
« Reply #12 on: January 06, 2012, 03:54:18 pm »
No difference. Still 2205 Samples.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML 2 sf::SoundRecorder
« Reply #13 on: January 06, 2012, 04:35:42 pm »
Hmm... Maybe an internal limitation in OpenAL.
Laurent Gomila - SFML developer

kobilica

  • Newbie
  • *
  • Posts: 15
    • View Profile
SFML 2 sf::SoundRecorder
« Reply #14 on: January 09, 2012, 09:13:19 am »
so is there any posibilities that i speed up this? should i recompile openal or something?