Closed tgill880 closed 5 years ago
Hello @tgill880,
Please share the fork so we can test. I recently did a similar thing where I implemented my own Read() function to get raw mic data and I didn't get the same issue so we'd need to check it out!
Best, Samreen
Hi, Samreen,
I solved my problem by compiling just the microphone_array.cpp
with my code, which contains the overloaded ::Read()
. Then I can link with the standard matrix-creator-hal.so
library. Something like this:
g++ -std=c++11 my_app.cpp microphone_array.cpp -o my_app -lmatrix-creator-hal -lwiringPi
I have no idea why I needed to link with wiringPi
.
Declaration for new ::Read()
:
bool Read(std::array<int16_t, kMicarrayBufferSize>& mic_data);
Code:
bool MicrophoneArray::Read(std::array<int16_t, kMicarrayBufferSize>& mic_data) {
if (!bus_) return false;
irq_cv.wait(lock_);
if (!bus_->Read(kMicrophoneArrayBaseAddress,
reinterpret_cast<unsigned char *>(&mic_data[0]),
sizeof(int16_t) * kMicarrayBufferSize)) {
return false;
}
return true;
}
Let me know if you need more info.
HOWEVER, the microphone data I get is somehow corrupted or malformed, and I only get an odd 'machine like' sound out of my files. Off topic, so I will open another ticket.
I will close this issue within several days.
I am trying to customize my own version of
MicrophoneArray::Read()
, but cannot get the linker to recognize the new method.Steps:
matrix-creator-hal
to my own repository.MicrophoneArray::Read2()
. The code in the method is not relevant at this point.microphone_array.h
and.cpp
files changed correctly.Read2()
, I get the following error./tmp/ccWgMLxt.o: In function `SLS_record<short, (unsigned short)8, (unsigned short)512, (unsigned short)2000>::start()': /home/pi/Projects/Matrix-HAL-demos/SLS_record.hpp:129: undefined reference to `matrix_hal::MicrophoneArray::Read2()' collect2: error: ld returned 1 exit status
undefined reference
looks like a linker error to me. If I substitute the standardRead()
call, everything builds correctly (but I don't have the new functionality I need).microphone_array.h
is installed in/usr/local/include/matrix_hal
.lib matrix_creator_hal.so
files to be sure old version were not updated.g++ -std=c++11 -g test_api.cpp -o test_api -lmatrix_creator_hal
Any help appreciated.