Skip to content

Commit

Permalink
fixed linux build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ozguronsoy committed Dec 9, 2024
1 parent 40aad9d commit 02cbd4c
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 3 deletions.
13 changes: 10 additions & 3 deletions HephAudio/HeaderFiles/Audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,25 @@ namespace HephAudio
enum AudioAPI
{
Default,

#if defined(_WIN32)
WASAPI,
DirectSound,
MMEAPI,
#elif defined(__APPLE__)
#endif

#if defined(__APPLE__)
CoreAudio,
#elif defined(__ANDROID__)
#endif

#if defined(__ANDROID__)
#if __ANDROID_API__ >= HEPHAUDIO_ANDROID_AAUDIO_MIN_API_LEVEL
AAudio,
#endif
OpenSLES,
#elif defined(__linux__)
#endif

#if defined(__linux__) && !defined(__ANDROID__)
ALSA,
#endif
};
Expand Down
12 changes: 12 additions & 0 deletions HephAudio/HeaderFiles/AudioChannelLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,5 +449,17 @@ namespace HephAudio
{
return AudioChannelLayout::GetChannelCount(layout.mask);
}

/**
* gets the channel mapping that corresponds to the channel mask.
*
*/
static std::vector<AudioChannelMask> GetChannelMapping(AudioChannelMask mask);

/**
* gets the channel mapping that corresponds to the channel layout.
*
*/
static std::vector<AudioChannelMask> GetChannelMapping(const AudioChannelLayout& layout);
};
}
1 change: 1 addition & 0 deletions HephAudio/HephAudio.vcxitems
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
<ClInclude Include="$(MSBuildThisFileDirectory)HeaderFiles\AudioEffects\Spatializer.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(MSBuildThisFileDirectory)SourceFiles\AudioChannelLayout.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)SourceFiles\AudioEffects\ChannelMapper.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)SourceFiles\AudioEffects\PitchShifter.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)SourceFiles\AudioEffects\BandPassFilter.cpp" />
Expand Down
1 change: 1 addition & 0 deletions HephAudio/HephAudio.vcxitems.filters
Original file line number Diff line number Diff line change
Expand Up @@ -425,5 +425,6 @@
<ClCompile Include="$(MSBuildThisFileDirectory)SourceFiles\AudioEffects\PitchShifter.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)SourceFiles\AudioEffects\Spatializer.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)SourceFiles\AudioEffects\ChannelMapper.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)SourceFiles\AudioChannelLayout.cpp" />
</ItemGroup>
</Project>
70 changes: 70 additions & 0 deletions HephAudio/SourceFiles/AudioChannelLayout.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#include "AudioChannelLayout.h"

namespace HephAudio
{
std::vector<AudioChannelMask> AudioChannelLayout::GetChannelMapping(AudioChannelMask mask)
{
switch (mask)
{
case HEPHAUDIO_CH_MASK_MONO:
return { AudioChannelMask::FrontCenter };
case HEPHAUDIO_CH_MASK_STEREO:
return { AudioChannelMask::FrontLeft, AudioChannelMask::FrontRight };
case HEPHAUDIO_CH_MASK_2_POINT_1:
return { AudioChannelMask::FrontLeft, AudioChannelMask::FrontRight, AudioChannelMask::LowFrequency };
case HEPHAUDIO_CH_MASK_2_1:
return { AudioChannelMask::FrontLeft, AudioChannelMask::FrontRight, AudioChannelMask::BackCenter };
case HEPHAUDIO_CH_MASK_SURROUND:
return { AudioChannelMask::FrontLeft, AudioChannelMask::FrontRight, AudioChannelMask::FrontCenter };
case HEPHAUDIO_CH_MASK_3_POINT_1:
return { AudioChannelMask::FrontLeft, AudioChannelMask::FrontRight, AudioChannelMask::FrontCenter, AudioChannelMask::LowFrequency };
case HEPHAUDIO_CH_MASK_4_POINT_0:
return { AudioChannelMask::FrontLeft, AudioChannelMask::FrontRight, AudioChannelMask::FrontCenter, AudioChannelMask::BackCenter };
case HEPHAUDIO_CH_MASK_2_2:
return { AudioChannelMask::FrontLeft, AudioChannelMask::FrontRight, AudioChannelMask::SideLeft, AudioChannelMask::SideRight };
case HEPHAUDIO_CH_MASK_QUAD:
return { AudioChannelMask::FrontLeft, AudioChannelMask::FrontRight, AudioChannelMask::BackLeft, AudioChannelMask::BackRight };
case HEPHAUDIO_CH_MASK_4_POINT_1:
return { AudioChannelMask::FrontLeft, AudioChannelMask::FrontRight, AudioChannelMask::FrontCenter, AudioChannelMask::LowFrequency, AudioChannelMask::BackCenter };
case HEPHAUDIO_CH_MASK_5_POINT_0:
return { AudioChannelMask::FrontLeft, AudioChannelMask::FrontRight, AudioChannelMask::FrontCenter, AudioChannelMask::SideLeft, AudioChannelMask::SideRight };
case HEPHAUDIO_CH_MASK_5_POINT_0_BACK:
return { AudioChannelMask::FrontLeft, AudioChannelMask::FrontRight, AudioChannelMask::FrontCenter, AudioChannelMask::BackLeft, AudioChannelMask::BackRight };
case HEPHAUDIO_CH_MASK_5_POINT_1:
return { AudioChannelMask::FrontLeft, AudioChannelMask::FrontRight, AudioChannelMask::FrontCenter, AudioChannelMask::LowFrequency, AudioChannelMask::SideLeft, AudioChannelMask::SideRight };
case HEPHAUDIO_CH_MASK_5_POINT_1_BACK:
return { AudioChannelMask::FrontLeft, AudioChannelMask::FrontRight, AudioChannelMask::FrontCenter, AudioChannelMask::LowFrequency, AudioChannelMask::BackLeft, AudioChannelMask::BackRight };
case HEPHAUDIO_CH_MASK_6_POINT_0:
return { AudioChannelMask::FrontLeft, AudioChannelMask::FrontRight, AudioChannelMask::FrontCenter, AudioChannelMask::BackCenter, AudioChannelMask::SideLeft, AudioChannelMask::SideRight };
case HEPHAUDIO_CH_MASK_6_POINT_0_FRONT:
return { AudioChannelMask::FrontLeft, AudioChannelMask::FrontRight, AudioChannelMask::FrontLeftOfCenter, AudioChannelMask::FrontRightOfCenter, AudioChannelMask::SideLeft, AudioChannelMask::SideRight };
case HEPHAUDIO_CH_MASK_HEXAGONAL:
return { AudioChannelMask::FrontLeft, AudioChannelMask::FrontRight, AudioChannelMask::FrontCenter, AudioChannelMask::BackLeft, AudioChannelMask::BackRight, AudioChannelMask::BackCenter };
case HEPHAUDIO_CH_MASK_6_POINT_1:
return { AudioChannelMask::FrontLeft, AudioChannelMask::FrontRight, AudioChannelMask::FrontCenter, AudioChannelMask::LowFrequency, AudioChannelMask::BackCenter, AudioChannelMask::SideLeft, AudioChannelMask::SideRight };
case HEPHAUDIO_CH_MASK_6_POINT_1_BACK:
return { AudioChannelMask::FrontLeft, AudioChannelMask::FrontRight, AudioChannelMask::FrontCenter, AudioChannelMask::LowFrequency, AudioChannelMask::BackLeft, AudioChannelMask::BackRight, AudioChannelMask::BackCenter };
case HEPHAUDIO_CH_MASK_6_POINT_1_FRONT:
return { AudioChannelMask::FrontLeft, AudioChannelMask::FrontRight, AudioChannelMask::LowFrequency, AudioChannelMask::FrontLeftOfCenter, AudioChannelMask::FrontRightOfCenter, AudioChannelMask::SideLeft, AudioChannelMask::SideRight };
case HEPHAUDIO_CH_MASK_7_POINT_0:
return { AudioChannelMask::FrontLeft, AudioChannelMask::FrontRight, AudioChannelMask::FrontCenter, AudioChannelMask::BackLeft, AudioChannelMask::BackRight, AudioChannelMask::SideLeft, AudioChannelMask::SideRight };
case HEPHAUDIO_CH_MASK_7_POINT_0_FRONT:
return { AudioChannelMask::FrontLeft, AudioChannelMask::FrontRight, AudioChannelMask::FrontCenter, AudioChannelMask::FrontLeftOfCenter, AudioChannelMask::FrontRightOfCenter, AudioChannelMask::SideLeft, AudioChannelMask::SideRight };
case HEPHAUDIO_CH_MASK_7_POINT_1:
return { AudioChannelMask::FrontLeft, AudioChannelMask::FrontRight, AudioChannelMask::FrontCenter, AudioChannelMask::LowFrequency, AudioChannelMask::BackLeft, AudioChannelMask::BackRight, AudioChannelMask::SideLeft, AudioChannelMask::SideRight };
case HEPHAUDIO_CH_MASK_7_POINT_1_WIDE:
return { AudioChannelMask::FrontLeft, AudioChannelMask::FrontRight, AudioChannelMask::FrontCenter, AudioChannelMask::LowFrequency, AudioChannelMask::FrontLeftOfCenter, AudioChannelMask::FrontRightOfCenter, AudioChannelMask::SideLeft, AudioChannelMask::SideRight };
case HEPHAUDIO_CH_MASK_7_POINT_1_WIDE_BACK:
return { AudioChannelMask::FrontLeft, AudioChannelMask::FrontRight, AudioChannelMask::FrontCenter, AudioChannelMask::LowFrequency, AudioChannelMask::BackLeft, AudioChannelMask::BackRight, AudioChannelMask::FrontLeftOfCenter, AudioChannelMask::FrontRightOfCenter };
case HEPHAUDIO_CH_MASK_OCTAGONAL:
return { AudioChannelMask::FrontLeft, AudioChannelMask::FrontRight, AudioChannelMask::FrontCenter, AudioChannelMask::BackLeft, AudioChannelMask::BackRight, AudioChannelMask::BackCenter, AudioChannelMask::SideLeft, AudioChannelMask::SideRight };
default:
return {};
}
}

std::vector<AudioChannelMask> AudioChannelLayout::GetChannelMapping(const AudioChannelLayout& layout)
{
return AudioChannelLayout::GetChannelMapping(layout.mask);
}
}

0 comments on commit 02cbd4c

Please sign in to comment.