Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

audioFromFileDevice bugfix #2663

Merged
merged 2 commits into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions doc/release/yarp_3_5/audioFromFile_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
audioFromFile_fix {#yarp_3_5}
-----------

Important Changes
-----------------

### Devices

* `audioFromFileDevice` fixed module when channels are > 1
5 changes: 3 additions & 2 deletions src/devices/audioFromFileDevice/audioFromFileDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,16 @@ void audioFromFileDevice::run()
//samples (m_samples_to_be_copied) in the buffer. This operation cannot be interrupted by stopping the device
//with m_recording_enabled=false. When the pointer reaches the end of the sound (audioFile),
//just restart from the beginning in an endless loop
size_t chan_num = m_audioFile.getChannels();
for (size_t i = 0; i < m_samples_to_be_copied; i++)
{
if (m_bpnt >= m_fsize_in_samples)
{
m_bpnt = 0;
}
for (size_t c=0; c< m_audioFile.getChannels(); c++)
for (size_t c=0; c< chan_num; c++)
{
m_inputBuffer->write((unsigned short)(m_datap.at(m_bpnt+c).get()));
m_inputBuffer->write((unsigned short)(m_datap.at(m_bpnt* chan_num +c).get()));
}
m_bpnt++;
}
Expand Down