SFML community forums

Help => Audio => Topic started by: OofingBomb on August 23, 2021, 12:30:45 pm

Title: Sound Stream Processing Interval
Post by: OofingBomb on August 23, 2021, 12:30:45 pm
Hi!

I'm working on audio synthesis right now. I've been trying to implement a synthesizer with SoundStream class. Here's the basic code:
class AudioStream : public SoundStream {
    private:
    unsigned int m_rate;
    short* m_samples;
    int m_sampleCount;

    public:
    AudioStream (int sampleRate) {
        m_rate = sampleRate;
        initialize(1, sampleRate);
    };
    void make(int freq) {
        m_sampleCount = m_rate / freq;
        int dc = m_sampleCount / 2;
        m_samples = new short[m_sampleCount];

        for (int i = 0; i < m_sampleCount; i++) {
            m_samples[i] = (i < dc) ? -4096 : 4095;
        };
    };

    protected:
    virtual bool onGetData(Chunk& data) {
        data.sampleCount = m_sampleCount;
        data.samples = m_samples;

        return true;
    };
    virtual void onSeek(Time) {
        // not supported
        return;
    };
};
Upon running this code, the output sounds like half of it is muted. As far as I know, that's because of SoundStream processing interval. However there's no function to change it, despite it being included in the GitHub SFML page.

So is there any way to have this function in the code (I want to disable the interval)?
Thanks for answers in advance!
Title: Re: Sound Stream Processing Interval
Post by: eXpl0it3r on August 25, 2021, 07:44:44 am
I don't quite follow what the issue is.
You can't "disable" the interval, but on the master branch you can call the protected function setProcessingInterval() (https://github.com/SFML/SFML/blob/master/include/SFML/Audio/SoundStream.hpp#L266).
Title: Re: Sound Stream Processing Interval
Post by: OofingBomb on August 25, 2021, 02:57:25 pm
Sorry, but I couldn't find the definition of the function in latest releases from sfml-dev.org.
Do I need to build the library from GitHub for this to work?
Title: Re: Sound Stream Processing Interval
Post by: eXpl0it3r on August 25, 2021, 04:50:16 pm
Yes, it's part of the next release, so you'll have to build SFML from source or if compatible, get a snapshot build: https://artifacts.sfml-dev.org/by-branch/master/