Writing Ogg to console

Hi all,
Hope you all are doing well.

Last time I have posted one question related to writing WAV format to standered out. I got satisfactory answer and I tried the suggested way. Thanks for the same. :smiley:
Now I want to try the Ogg format output to be written on the standered output. I tried the way I did WAV but I am always getting following error:
jucelib_static_Win32_debug.lib(juce_OggVorbisAudioFormat.obj) : error LNK2005: _bitreverse already defined

The way I am doing is:
I have defined another class TempOggWriter, which is copy of the OggWriter, I have just replaced the “ouptut” which is OutputStream with stdout file handler and using fwrite() to write the data to standered out.

Please help me in this too


Thanks and Regards,
Santo.

Maybe you’re linking to other libraries that use that symbol.

Perhaps try the amalgamated version?

And surely the sensible way to do what you want would be to write yourself a simple OutputStream class that writes to stdout (probably only about 20 lines of code), and pass that to the normal ogg writer??

Hi Jules,

Yes i tried this one in my Application the way you told and yes it is working well.

K.

Hello Jules,

Thanks for your reply!

I found that the error was due to the non-required lib I was using in my application.
I will try the suggested way and let you know!

Thanks,
Santo

I was surprised to find that JUCE doesn’t have such an OutputStream included in it!

Here’s an incomplete (doesn’t handle failing writes) implementation in the 20 lines of code budget:

class StdOutputStream : public juce::OutputStream
{
public:
    StdOutputStream (std::ostream& stream_) : stream (stream_) {}

    void flush() override { stream.flush(); }
    int64 getPosition() override { return stream.tellp(); }
    bool setPosition (int64 pos) override
    {
        stream.seekp (pos);
        return getPosition() == pos;
    }
    bool write (const void* data, size_t size) override
    {
        stream.write ((const char*) data, size);
        return true;
    }

private:
    std::ostream& stream;
};
4 Likes