MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / LoadSample

Method LoadSample

src/openrct2/object/AudioSampleTable.cpp:151–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149 }
150
151 Audio::IAudioSource* AudioSampleTable::LoadSample(uint32_t index) const
152 {
153 Audio::IAudioSource* result{};
154 if (index < _entries.size())
155 {
156 auto& entry = _entries[index];
157 if (entry.Asset)
158 {
159 auto stream = entry.Asset->GetStream();
160 if (stream != nullptr)
161 {
162 auto& audioContext = GetContext()->GetAudioContext();
163 if (entry.PathIndex)
164 {
165 auto originalPosition = stream->GetPosition();
166 auto numSounds = stream->ReadValue<uint32_t>();
167 stream->SetPosition(originalPosition);
168
169 if (*entry.PathIndex >= numSounds)
170 {
171 auto& ui = GetContext()->GetUiContext();
172 ui.ShowMessageBox(FormatStringID(
173 STR_AUDIO_FILE_TRUNCATED, entry.Asset->GetPath().c_str(), *entry.PathIndex, numSounds));
174 }
175
176 result = audioContext.CreateStreamFromCSS(std::move(stream), *entry.PathIndex);
177 }
178 else
179 {
180 result = audioContext.CreateStreamFromWAV(std::move(stream));
181 }
182 }
183 }
184 }
185 return result;
186 }
187
188 int32_t AudioSampleTable::GetSampleModifier(uint32_t index) const
189 {

Callers 1

GetTrackSampleMethod · 0.80

Calls 10

GetContextFunction · 0.85
FormatStringIDFunction · 0.85
GetStreamMethod · 0.80
sizeMethod · 0.45
GetPositionMethod · 0.45
SetPositionMethod · 0.45
ShowMessageBoxMethod · 0.45
GetPathMethod · 0.45
CreateStreamFromCSSMethod · 0.45
CreateStreamFromWAVMethod · 0.45

Tested by

no test coverage detected