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 - Notnasiul

Pages: [1]
1
Audio / Pitch detection algorithms
« on: August 06, 2011, 07:50:12 pm »
Is SFML suitable for implementing pitch detection algorithms? I guess so, given that accessing sound buffers is relatively simple and fast.

At first I considered AMDF, as it seems easy to implement. Indeed, I already implemented it in Processing, but I switched to SFML looking for speed. I could consider FFT based algorithms, using the FFTW library to extract the Fourier Transform.

But I would like some advice from someone with a little bit of experience. Have you tried to detect pitch from a recorded human voice?

2
Audio / Creating an oscillator
« on: July 25, 2011, 01:01:30 pm »
Has anyone done this? I'm starting with SFML, so I'm still pretty lost. I found this basic effect generator http://www.sfml-dev.org/forum/viewtopic.php?t=3449&highlight=soundman which is great for precise sound effects, but I need something that creates a continuous sound. That is, an oscillator.

I guess I have to fill a soundbuffer with the right samples (using a sine wave, knowing the target frequency and amplitude), feed it to a sound object and play it. But I must be doing something wrong... Just as a test I did this:

Code: [Select]

#include <SFML/Audio.hpp>
#include "math.h"

int main()
{
    int nSamples = 10000; // How many samples do I need for a cycle?
    sf::Int16 samples[nSamples];
    sf::SoundBuffer buffer;
    sf::Sound sound;
    //Fill samples with a pure A tone (440hrz)
    for (int i = 0; i < nSamples ; i++) {
        samples[i] = ( sin(440.0f * (2.0f * 3.1415f) * i / 44100));
    }
    bool ok = buffer.LoadFromSamples(samples, nSamples , 1, 44100);
    if (!ok) exit(-1);
    sound.SetBuffer(buffer);
    sound.Play();
    sf::Sleep(5.0f);
    return 0;
}


Nothing is heard when executed...

3
Audio / Increasing Sound::GetPlayingOffset() precision
« on: July 23, 2011, 05:00:04 pm »
Hi! First post in these forums : ) First of all, congratulations for this great library.

I'm working with sound in a project that is closely related to a karaoke. Therefore, I need access to sound buffers. At some point,  sound/music is playing and I must get the raw values from the buffer from the exact playing offset.

It's easy by knowing its sample rate and the playing offset. However, sound.GetPlayingOffset() returns floats with just two decimals (e.g. 2.23) so the resolution is pretty low.

If I use Clock.GetElapsedTime() the precision is higher (e.g. 2.23154), which is more discriminative. Just see this example:

2.22 x 44100 -> 97902
2.23 x 44100 -> 98343

There are like 1000 samples lost in just 1/100 seconds. But it's even worse: many consecutive calls return the same playing offset, so I get the same sample even when time has obviously advanced (a few milliseconds, but it's not the same)

If I do something like this (just imagine that Sound is already playing):

Code: [Select]
std::cout << Clock.GetElapsedTime() << " " << Sound.GetPlayingOffset() << std::endl

see how Clock is much more precise than GetPlayingOffset in this few samples:

0.060948 0.06
0.0629533 0.06
0.0649569 0.06
0.0667986 0.06
0.0687719 0.06
0.0704301 0.07
0.072469 0.07
0.074509 0.07
0.0758784 0.07
0.0778292 0.07

I hope I managed to explain myself... Is it possible to increase GetPlayingOffset somehow?

Pages: [1]