Portaudio wants a callback function pointer, but I have the data in a class

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • 51423benam
    New Member
    • Apr 2018
    • 31

    Portaudio wants a callback function pointer, but I have the data in a class

    Hello,

    I want to use portaudio for my c++ audio project. The problem is: As you can see here and here, it wants me to pass the callback function as a function argument of openDefaultStre am(). The problem is: The audio data lies in a class. So there is a object of the class AudioManager() which collects the newest samples. The problem is now: I can't pass a member function pointer to openDefaultStre am(), right? Since that would require me to pass the object it should be called on as well. But if I make the function static, how can I access the newest samples then?
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Write a function that receives data from AudioManager. The function then calls the member function of your class.

    Pass the address of this function to Audiomanager.

    When AudioManager calls the function, the data received is the input argument and the function updates an object of your class.


    Check out the design pattern called Adapter.

    Comment

    Working...