NAO robot: porting ALSoundExtractor to qi framwork

后端 未结 4 777
臣服心动
臣服心动 2021-01-22 07:28

When porting from NAOqi to qi framework I achieved a partial success. I do however still have the following problem. I do not know how to implement sound processing with ALSound

4条回答
  •  南方客
    南方客 (楼主)
    2021-01-22 08:17

    I never worked with ALExtractor nor ALSoundExtractor, but here is what I know.

    1. How to create a class in qi framework that inherits from the old style class ALSoundExtractor?

    in the old Naoqi, an "ALExtractor"

    • could run either from within the main process (using autoload.ini) or from another one (known as remote mode). With the qi framework, only the remote mode is supported. 
    • could inherit from ALExtractor or ALAudioExtractor to get some code factored out. Those classes have not been ported to the qi framework. So if you don't want to keep using libnaoqi, you should find a way to do without them.

    Good news: inheriting from them never was really needed. You'll find yourself in a similar position as in the following question where an extractor is implemented in python (and thus cannot inherit from a C++ class, nor be loaded in the main process from autoload.ini). NAO robot remote audio problems

    1. How to declare a function that is overriding the virtual function - technically the base class function process() expects variables in old AL:: convention.

    Whenever you use the "old Naoqi" you're actually using a compatibility layer on top of the qi framework. So whenever you use the "old Naoqi", you're already using the qi framework. libqi's qi::AnyValue is extensible at runtime, libnaoqi extends it to let it know how to handle an ALValue: how to convert it into primitive types (floating point number, list of ints, string, buffer, etc.).

    So whenever an old ALSoundExtractor receives an AL::ALvalue, it is actually a qi::AnyValue which has been converted into an ALValue just before calling the process() method. If you don't link with libnaoqi, you won't be able to use the value as an ALValue, but you can use it as a qi::AnyValue or even use it as a primitive type.

    The original prototype is (cfr doxygen http://doc.aldebaran.com/2-8/ref/libalaudio/classAL_1_1ALSoundExtractor.html) is

    void ALSoundExtractor::process (const int &nbOfChannels, const int &nbrOfSamplesByChannel, const AL_SOUND_FORMAT *buffer, const ALValue ×tamp);
    

    Since timestamp is probably a list of two ints, I would try something like this

    void TmpSoundExtractor::process (const int &nbOfChannels, const int &nbrOfSamplesByChannel, qi::AnyValue buffer, const std::vector ×tamp);
    

    I'm not sure how to handle the buffer variable, but let first get the rest working.

提交回复
热议问题