MCPcopy Create free account
hub / github.com/SFML/SFML / open

Method open

src/SFML/Audio/SoundFileWriterWav.cpp:88–221  ·  view source on GitHub ↗

///////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

86
87////////////////////////////////////////////////////////////
88bool SoundFileWriterWav::open(const std::filesystem::path& filename,
89 unsigned int sampleRate,
90 unsigned int channelCount,
91 const std::vector<SoundChannel>& channelMap)
92{
93 auto channelMask = 0u;
94
95 if (channelCount == 0)
96 {
97 err() << "WAV sound file channel count 0" << std::endl;
98 return false;
99 }
100
101 if (channelCount == 1)
102 {
103 m_remapTable[0] = 0;
104 }
105 else if (channelCount == 2)
106 {
107 m_remapTable[0] = 0;
108 m_remapTable[1] = 1;
109 }
110 else
111 {
112 // For WAVE channel mapping refer to: https://learn.microsoft.com/en-us/previous-versions/windows/hardware/design/dn653308(v=vs.85)#default-channel-ordering
113 static constexpr auto speakerFrontLeft = 0x1u;
114 static constexpr auto speakerFrontRight = 0x2u;
115 static constexpr auto speakerFrontCenter = 0x4u;
116 static constexpr auto speakerLowFrequency = 0x8u;
117 static constexpr auto speakerBackLeft = 0x10u;
118 static constexpr auto speakerBackRight = 0x20u;
119 static constexpr auto speakerFrontLeftOfCenter = 0x40u;
120 static constexpr auto speakerFrontRightOfCenter = 0x80u;
121 static constexpr auto speakerBackCenter = 0x100u;
122 static constexpr auto speakerSideLeft = 0x200u;
123 static constexpr auto speakerSideRight = 0x400u;
124 static constexpr auto speakerTopCenter = 0x800u;
125 static constexpr auto speakerTopFrontLeft = 0x1000u;
126 static constexpr auto speakerTopFrontCenter = 0x2000u;
127 static constexpr auto speakerTopFrontRight = 0x4000u;
128 static constexpr auto speakerTopBackLeft = 0x8000u;
129 static constexpr auto speakerTopBackCenter = 0x10000u;
130 static constexpr auto speakerTopBackRight = 0x20000u;
131
132 struct SupportedChannel
133 {
134 std::uint32_t bit;
135 SoundChannel channel;
136 };
137
138 std::vector<SupportedChannel>
139 targetChannelMap{{speakerFrontLeft, SoundChannel::FrontLeft},
140 {speakerFrontRight, SoundChannel::FrontRight},
141 {speakerFrontCenter, SoundChannel::FrontCenter},
142 {speakerLowFrequency, SoundChannel::LowFrequencyEffects},
143 {speakerBackLeft, SoundChannel::BackLeft},
144 {speakerBackRight, SoundChannel::BackRight},
145 {speakerFrontLeftOfCenter, SoundChannel::FrontLeftOfCenter},

Callers

nothing calls this directly

Calls 4

formatDebugPathInfoFunction · 0.85
eraseMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected