12 #include "../stdafx.h"
15 #include "midifile.hpp"
18 #include "../safeguards.h"
21 static MIDI *
_midi =
nullptr;
27 extern int _allegro_instance_count;
31 if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno,
nullptr)) {
32 Debug(driver, 0,
"allegro: install_allegro failed '{}'", allegro_error);
33 return "Failed to set up Allegro";
35 _allegro_instance_count++;
38 if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT,
nullptr) != 0) {
39 Debug(driver, 0,
"allegro: install_sound failed '{}'", allegro_error);
40 return "Failed to set up Allegro sound";
44 if (midi_card == MIDI_NONE) {
45 Debug(driver, 0,
"allegro: no midi card found");
46 return "No sound card found";
57 if (--_allegro_instance_count == 0) allegro_exit();
65 if (!filename.empty()) {
66 _midi = load_midi(filename.c_str());
67 play_midi(
_midi,
false);
Base support for playing music via allegro.
Factory for allegro's music player.
void SetVolume(uint8_t vol) override
Set the volume, if possible.
void StopSong() override
Stop playing the current song.
std::optional< std::string_view > Start(const StringList ¶m) override
Start this driver.
void PlaySong(const MusicSongInfo &song) override
Play a particular song.
bool IsSongPlaying() override
Are we currently playing a song?
void Stop() override
Stop this driver.
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
static struct @11 _midi
Metadata about the midi we're playing.
std::vector< std::string > StringList
Type for a list of strings.
static std::string GetSMFFile(const MusicSongInfo &song)
Get the name of a Standard MIDI File for a given song.
Metadata about a music track.