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

Author Topic: Sound Stream Processing Interval  (Read 7928 times)

0 Members and 2 Guests are viewing this topic.

OofingBomb

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Sound Stream Processing Interval
« 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!
« Last Edit: August 23, 2021, 12:42:21 pm by OofingBomb »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Sound Stream Processing Interval
« Reply #1 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().
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

OofingBomb

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: Sound Stream Processing Interval
« Reply #2 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?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Sound Stream Processing Interval
« Reply #3 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/
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/