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

Extension - Handle stereo audio from TeamSpeak (cherry pick) #1240

Merged
merged 1 commit into from
Apr 13, 2023
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
1 change: 1 addition & 0 deletions extensions/src/ACRE2Core/FilterPosition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <cmath>
#pragma comment(lib, "x3daudio.lib")
#pragma comment(lib, "xaudio2.lib")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not fully sure why this is now required, it's unrelated to pr but need to build on VS17.6

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't need that on VS17.5. 🤔

Copy link
Collaborator Author

@PabstMirror PabstMirror Apr 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error

2>ACRE2Core.lib(FilterPosition.obj) : error LNK2019: unresolved external symbol __imp_X3DAudioInitialize referenced in function "public: enum acre::Result __cdecl CFilterPosition::process(short *,int,int,unsigned int,class CSoundMixdownEffect *)" (?process@CFilterPosition@@QEAA?AW4Result@acre@@PEAFHHIPEAVCSoundMixdownEffect@@@Z)
2>ACRE2Core.lib(FilterPosition.obj) : error LNK2019: unresolved external symbol __imp_X3DAudioCalculate referenced in function "public: enum acre::Result __cdecl CFilterPosition::process(short *,int,int,unsigned int,class CSoundMixdownEffect *)" (?process@CFilterPosition@@QEAA?AW4Result@acre@@PEAFHHIPEAVCSoundMixdownEffect@@@Z)

it might just be something on my machine
we could just remove the line from the pr and let it build via github automation
or fix via cmake config, but we already had a existing #pragma comment(lib

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also builds with it for me, forgot to say that. So I am fine with leaving it in.


#define MAX_FALLOFF_DISTANCE 75
#define MAX_FALLOFF_RANGE 150
Expand Down
2 changes: 1 addition & 1 deletion extensions/src/ACRE2Core/SoundEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ acre::Result CSoundEngine::onEditPlaybackVoiceDataEvent(acre::id_t id, short* sa
for (size_t i = 0; i < player->channels.size(); ++i) {
if (player->channels[i]) {
player->channels[i]->lock();
player->channels[i]->In(samples, sampleCount);
player->channels[i]->In(samples, sampleCount, channels);
player->channels[i]->unlock();
}
}
Expand Down
15 changes: 11 additions & 4 deletions extensions/src/ACRE2Core/SoundMonoChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,17 @@ CSoundChannelMono::~CSoundChannelMono() {
}
}

int CSoundChannelMono::In(short *samples, int sampleCount) {
int CSoundChannelMono::In(short *samples, int sampleCount, const int channels) {
//memset(samples, 0x00, sampleCount*sizeof(short));
if (this->bufferLength+sampleCount <= this->bufferMaxSize) {
memcpy(this->buffer+this->bufferLength, samples, sampleCount*sizeof(short));
if (this->bufferLength + sampleCount <= this->bufferMaxSize) {
if (channels == 1) {
memcpy(this->buffer + this->bufferLength, samples, sampleCount * sizeof(short));
} else {
// rare but for multi channel input just capture mono, samples[channels*sampleCount]={Left,Right,Left,...}
for (int i = 0; i < sampleCount; i++) {
this->buffer[this->bufferLength + i] = samples[channels * i];
}
}
this->bufferLength += sampleCount;
}
return this->bufferLength;
Expand Down Expand Up @@ -113,4 +120,4 @@ CSoundMixdownEffect * CSoundChannelMono::getMixdownEffectInsert(int index) {
if (index > 7)
return NULL;
return this->mixdownEffects[index];
}
}
2 changes: 1 addition & 1 deletion extensions/src/ACRE2Core/SoundMonoChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CSoundChannelMono : public CLockable {
CSoundChannelMono( int length, bool singleShot );

~CSoundChannelMono();
int In(short *samples, int sampleCount);
int In(short *samples, int sampleCount, const int channels);
int Out(short *samples, int sampleCount);
int GetCurrentBufferSize() { return this->bufferLength-this->bufferPos; };
bool IsOneShot() { return this->oneShot; };
Expand Down
2 changes: 1 addition & 1 deletion extensions/src/ACRE2Core/SoundPlayback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ acre::Result CSoundPlayback::playSound(std::string id, acre::vec3_fp32_t positio
tempChannel->getMixdownEffectInsert(0)->setParam("isWorld", 0x00000000);
}

tempChannel->In((short *)waveFile.GetData(), waveFile.GetSize()/sizeof(short));
tempChannel->In((short *)waveFile.GetData(), waveFile.GetSize()/sizeof(short), 1);
CEngine::getInstance()->getSoundEngine()->getSoundMixer()->unlock();
return acre::Result::ok;
}
Expand Down