MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / loadMIDI

Method loadMIDI

src/Engine/GMCat.cpp:358–388  ·  view source on GitHub ↗

* Loads a MIDI object into memory. * @param i Music number to load. * @return Pointer to the loaded music. */

Source from the content-addressed store, hash-verified

356 * @return Pointer to the loaded music.
357 */
358Music *GMCatFile::loadMIDI(unsigned int i)
359{
360 Music *music = new Music;
361
362 unsigned char *raw = static_cast<unsigned char*> ((void*)load(i));
363
364 if (!raw)
365 return music;
366
367 // stream info
368 struct gmstream stream;
369 if (gmext_read_stream(&stream, getObjectSize(i), raw) == -1) {
370 delete[] raw;
371 return music;
372 }
373
374 std::vector<unsigned char> midi;
375 midi.reserve(65536);
376
377 // fields in stream still point into raw
378 if (gmext_write_midi(&stream, midi) == -1) {
379 delete[] raw;
380 return music;
381 }
382
383 delete[] raw;
384
385 music->load(&midi[0], midi.size());
386
387 return music;
388}
389
390}

Callers 1

loadMusicMethod · 0.80

Calls 4

loadFunction · 0.85
gmext_read_streamFunction · 0.85
gmext_write_midiFunction · 0.85
loadMethod · 0.45

Tested by

no test coverage detected