OfxPDSP - Stereo audio player

Hello,

I’m trying to dive into ofxPDSP, but I don’t understand how to keep the stereo when using the audioplayer exemple. Indeed, it seems that this player mix the right and left channel of the wav file I loaded.

Is there a way to keep the stereo ?

Thank you :slight_smile:

Hi! are you talking about the example_song_player ? it should work in stereo, if it’s always mono i should fix it.

Hi !

Yes I’m talking about that example. I use this audio file to test :

I tried to do some changes with the sampler, but I don’t manage your addon yet, so if you can help me to fix and understand this it will be super nice ‘

strange, it is working in stereo on my system ( debian 9 ).

The audio player internally use 2 samplers, sampler0 and sampler1, and pdsp::SampleBuffer named sample. Each pdsp::Sampler is mono, so you have to set them to different channels if the sample is stereo and to the same channel of the buffer if it is mono, is it what happens at line 139:

        // switch to mono if the sample has just one channel
        if( sample.channels == 1 ){
            sampler1.setSample( &sample, 0, 0 );
        }else{
            sampler1.setSample( &sample, 0, 1 );
        }

if you changed some of those things it could lead to the sampler for the right channel using the wrong channel of the audio buffer.

Also please state the OS and IDE you are using (if using one), and please test also that the ofxAudioFile/example is working with your sample (it is working on my platform)

Indeed, ofxAudioFile/example works as expected with my stereo test file. And i tested again the example_song_player and it works too. So … I probably messed up by modifying some code, sorry for the false alert :slight_smile: and thank you for your help (and the work you’ve done with this lib !)

thank you for using it! i made the API clearer some months ago, now i should try to find some time to make less complex examples,

let me know if something is not very clear!

Ok I understood the error I made : I wanted to use a bitcrucher effect and I wrote :

ctrl >> effect.in_bits();    
player.out("0") >> effect >> engine.audio_out(0);
player.out("1") >> effect >> engine.audio_out(1);

But by doing that I mixed the left and right in the “effect patch” … So as I understand I have to duplicate the effect to have stereo channels.

I have an higher level bitcruncher class here that could be useful to you:

just remember to copy it to your project as i change the code of those classes whatever i want

Thanks for this, super interesting to see how you implement a higher level effect, I will dig into this :slight_smile:

in general in oF when i make something reusable i abstract all the functionality into ofParameters already added to an ofParameterGroup, so i have just to setup my object and add them to the GUI, sometimes they are just the default modules with those ready to use parameters (other times they are my synths / sequences )