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

Method open

src/SFML/Audio/SoundFileWriterFlac.cpp:55–160  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

53
54////////////////////////////////////////////////////////////
55bool SoundFileWriterFlac::open(const std::filesystem::path& filename,
56 unsigned int sampleRate,
57 unsigned int channelCount,
58 const std::vector<SoundChannel>& channelMap)
59{
60 std::vector<SoundChannel> targetChannelMap;
61
62 // For FLAC channel mapping refer to: https://xiph.org/flac/format.html#frame_header
63 switch (channelCount)
64 {
65 case 0:
66 err() << "No channels to write to FLAC file" << std::endl;
67 return false;
68 case 1:
69 targetChannelMap = {SoundChannel::Mono};
70 break;
71 case 2:
72 targetChannelMap = {SoundChannel::FrontLeft, SoundChannel::FrontRight};
73 break;
74 case 3:
75 targetChannelMap = {SoundChannel::FrontLeft, SoundChannel::FrontRight, SoundChannel::FrontCenter};
76 break;
77 case 4:
78 targetChannelMap = {SoundChannel::FrontLeft, SoundChannel::FrontRight, SoundChannel::BackLeft, SoundChannel::BackRight};
79 break;
80 case 5:
81 targetChannelMap = {SoundChannel::FrontLeft,
82 SoundChannel::FrontRight,
83 SoundChannel::FrontCenter,
84 SoundChannel::BackLeft,
85 SoundChannel::BackRight};
86 break;
87 case 6:
88 targetChannelMap = {SoundChannel::FrontLeft,
89 SoundChannel::FrontRight,
90 SoundChannel::FrontCenter,
91 SoundChannel::LowFrequencyEffects,
92 SoundChannel::BackLeft,
93 SoundChannel::BackRight};
94 break;
95 case 7:
96 targetChannelMap = {SoundChannel::FrontLeft,
97 SoundChannel::FrontRight,
98 SoundChannel::FrontCenter,
99 SoundChannel::LowFrequencyEffects,
100 SoundChannel::BackCenter,
101 SoundChannel::SideLeft,
102 SoundChannel::SideRight};
103 break;
104 case 8:
105 targetChannelMap = {SoundChannel::FrontLeft,
106 SoundChannel::FrontRight,
107 SoundChannel::FrontCenter,
108 SoundChannel::LowFrequencyEffects,
109 SoundChannel::BackLeft,
110 SoundChannel::BackRight,
111 SoundChannel::SideLeft,
112 SoundChannel::SideRight};

Callers

nothing calls this directly

Calls 6

formatDebugPathInfoFunction · 0.85
openFileFunction · 0.85
resetMethod · 0.80
getMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected