bool Console::cmd_music(int argc, const char **argv) { if (argc < 2) { DebugPrintf("%s track_number or %s -offset\n", argv[0], argv[0]); DebugPrintf("Plays the MIDI track number provided, or the offset inside midi.dat\n"); DebugPrintf("A positive number signifies a track number, whereas a negative signifies an offset\n"); return true; } int param = strToInt(argv[1]); if (param == 0) { DebugPrintf("Track number/offset can't be 0!\n"); } else if (param > 0) { // Track provided PlayMidiSequence(GetTrackOffset(param - 1), false); } else if (param < 0) { // Offset provided param = param * -1; PlayMidiSequence(param, false); } return true; }
void RestoreMidiFacts(SCNHANDLE Midi, bool Loop) { StopMidi(); g_currentMidi = Midi; g_currentLoop = Loop; bool mute = false; if (ConfMan.hasKey("mute")) mute = ConfMan.getBool("mute"); PlayMidiSequence(g_currentMidi, true); SetMidiVolume(mute ? 0 : _vm->_config->_musicVolume); }
/** * Sets the volume of the MIDI music. * @param vol New volume - 0..MAXMIDIVOL */ void SetMidiVolume(int vol) { assert(vol >= 0 && vol <= Audio::Mixer::kMaxChannelVolume); static int priorVolMusic = 0; // FIXME: Avoid non-const global vars if (vol == 0 && priorVolMusic == 0) { // Nothing to do } else if (vol == 0 && priorVolMusic != 0) { // Stop current midi sequence StopMidi(); _vm->_midiMusic->setVolume(vol); } else if (vol != 0 && priorVolMusic == 0) { // Perhaps restart last midi sequence if (currentLoop) PlayMidiSequence(currentMidi, true); _vm->_midiMusic->setVolume(vol); } else if (vol != 0 && priorVolMusic != 0) { // Alter current volume _vm->_midiMusic->setVolume(vol); } priorVolMusic = vol; }