summaryrefslogtreecommitdiff
path: root/src/i_oplmusic.c
AgeCommit message (Collapse)Author
2014-10-14Fix OPL MIDI tempo calculations.Simon Howard
It turns out that the way that tempo has been calculated in OPL playback has been broken for a long time. The mysterious "fudge factor" that I had to apply to tempo calculations is actually completely unnecessary: the byte-swapping in the MIDI_GetFileTimeDivision() function was being done wrong, so the time division being used by the OPL MIDI code was completely wrong. Presumably the multiply by 260 was close enough to an 8-bit bitshift that it worked okayish, but large enough time division values would overflow a single byte and screw up. This fixes long-running OPL playback problems in a number of WADs, most notably Alien Vendetta. This *really* fixes #352.
2014-10-08midi: Fix "D_DDTBLU disease".Simon Howard
The Doom II MAP14/MAP20 music has a hanging note at the end of the track that is never turned off. If this is not reset when the track loops, there is a continuous (and annoying) drone sound throughout the next iteration of the song. Some information is here: http://www.doomworld.com/vb/source-ports/66802-the-d-ddtblu-disease/ This changes the mus2mid code to generate an "all notes off" controller event at the start of the MIDI track. This is specifically done at the start and not the end of the track because otherwise the looping of tracks like D_RUNNING is affected. Thanks to a whole host of people for help on this: @plumsinus for reporting the bug, @bradharding for devising a fix as part of Doom Retro, and Quasar for feedback and his own fix to the Eternity Engine. This fixes #412.
2014-05-11opl: Change library to use us instead of ms.Simon Howard
Multi-track MIDI files are played back using separate callback chains for each track, and this introduces the possibility of one track becoming out of sync with the others. This was noticeable in WADs that use multi-track MIDIs, such as Alien Vendetta. Increase the timing resolution to microsecond precision to fix this.
2014-05-10opl: Add API to adjust tempo.Simon Howard
When the tempo is changed, the times on all active timers must be adjusted to match the new timing values. Add an API to do this and invoke it when a tempo change meta event is read.
2014-05-08opl: Process MIDI 'set tempo' meta events.Simon Howard
The MIDI format includes a special meta event to set the tempo of playback, and some WADs depend on this - notably the music in Alien Vendetta. Move the variables controlling tempo to the global scope (they are not per-track as I previously thought) and set when the tempo events are encountered. This is some progress towards resolving #334, but that bug is not yet completely fixed, because the tempo change does not retroactively apply to OPL timers that have already been set.
2014-05-06oplmusic: Handle key-on with volume 0 as key-off.Simon Howard
Some MIDI files, such as the music tracks in AV.wad, use a second "key on" event with a volume of zero to mean "key off". Handle this case correctly.
2014-05-05Clean up file headers.Simon Howard
This change rewrites and simplifies the copyright headers at the top of all source files: * Remove "Emacs style mode select" line; this line was included in the headers for the originally released source files and appears to be to set the file type for old versions of Emacs. I'm not sure entirely why it was required but I don't think it is any more. * Remove "You should have received a copy of..." text from copyright header. This refers to the old 59 Temple Place address where the FSF headquarters used to be located and is no longer correct. Rather than change to the new address, just remove the paragraph as it is superfluous anyway. This fixes #311. * Remove ---- separator lines so that the file headers are barer and more simplified.
2014-05-01opl: Fix crash when using OPL music.Simon Howard
The previous change to add the poll method to the music module interface introduced a crash, as the OPL music struct does not define a poll method.
2014-04-01Replace all snprintf() calls with M_snprintf().Simon Howard
The Windows API has an _snprintf function that is not the same as Unix's snprintf(): if the string is truncated then no trailing NUL character is appended. This makes the function unsafe. Define a replacement/wrapper called M_snprintf that works the same but always appends a trailing NUL, for safety on Windows and other OSes that behave like this. Do the same thing for vsnprintf(), and update HACKING to list snprintf/vsnprintf as forbidden functions. This fixes #375; thanks to Quasar for pointing out the different behavior of these functions.
2014-03-30Eliminate some uses of sprintf() from common code.Simon Howard
As part of this, add DIR_SEPARATOR_S as a string version of the DIR_SEPARATOR macro. Change M_TempFile() to return a string allocated on the C heap rather than the zone heap. This is a first step towards fixing #371.
2013-09-08Merge from trunk.Simon Howard
Subversion-branch: /branches/v2-branch Subversion-revision: 2639
2013-06-19Fix OPL MIDI playback on big endian systems (thanks GhostlyDeath).Simon Howard
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2607
2012-10-28Merge from trunk.Simon Howard
Subversion-branch: /branches/v2-branch Subversion-revision: 2537
2012-01-05Add hack command-line option for on-screen OPL status output - usefulSimon Howard
for GENMIDI development. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2482
2011-06-13Merge from trunk.Simon Howard
Subversion-branch: /branches/raven-branch Subversion-revision: 2347
2011-03-28Fix OPL MIDI playback when using an empty .mus / .mid file (thanksSimon Howard
Alexandre Xavier). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2313
2010-04-30Merge from trunk.Simon Howard
Subversion-branch: /branches/raven-branch Subversion-revision: 1924
2010-04-22Disable OPL debugging messages.Simon Howard
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1913
2009-10-31When replacing an existing voice, discard voices that are the secondSimon Howard
voice of a two voice instrument. Don't discard instruments from lower numbered MIDI channels for higher numbered MIDI channels. Subversion-branch: /branches/opl-branch Subversion-revision: 1727
2009-10-25Emulate odd octave 7 behavior of Vanilla Doom.Simon Howard
Subversion-branch: /branches/opl-branch Subversion-revision: 1725
2009-10-17Add OPL library API function to set software emulation sample rate, andSimon Howard
set from snd_samplerate in the configuration file. Subversion-branch: /branches/opl-branch Subversion-revision: 1723
2009-10-11Don't apply base note offset if the instrument is a fixed noteSimon Howard
instrument. This should stop the ugly bleeping from the electric snare on E1M2. Subversion-branch: /branches/opl-branch Subversion-revision: 1715
2009-10-01Remove temporary MIDI file after loading MIDI data. Stop all playing OPLSimon Howard
voices when music is shut down. Subversion-branch: /branches/opl-branch Subversion-revision: 1704
2009-10-01Convert to American English spellings.Simon Howard
Subversion-branch: /branches/opl-branch Subversion-revision: 1700
2009-09-26Move register read/write code into OPL library. Detect OPL in theSimon Howard
library code, so that we fall back to software emulation if we have port access but an OPL is not detected. Fix detection of ioperm in configure. Subversion-branch: /branches/opl-branch Subversion-revision: 1692
2009-09-26Don't use snd_mport to control OPL base I/O port; Vanilla doesn't doSimon Howard
this. Subversion-branch: /branches/opl-branch Subversion-revision: 1691
2009-09-21Implement pausing of music.Simon Howard
Subversion-branch: /branches/opl-branch Subversion-revision: 1688
2009-09-20Implement volume control.Simon Howard
Subversion-branch: /branches/opl-branch Subversion-revision: 1685
2009-09-20Remove old test code.Simon Howard
Subversion-branch: /branches/opl-branch Subversion-revision: 1684
2009-09-20Avoid possible overflow due to base note offset.Simon Howard
Subversion-branch: /branches/opl-branch Subversion-revision: 1683
2009-09-20Use the base note offset field to offset notes, not a fixed lookup tableSimon Howard
of instruments to offset. Subversion-branch: /branches/opl-branch Subversion-revision: 1680
2009-09-19Add octave offset table, offset notes on specific instruments down bySimon Howard
one octave, as per research. Subversion-branch: /branches/opl-branch Subversion-revision: 1678
2009-09-12Remove separate volume calculations for non-feedback (separate operator)Simon Howard
voices. Doom writes the same value to both operators. Subversion-branch: /branches/opl-branch Subversion-revision: 1671
2009-09-12Vanilla Doom plays d_introa, not d_intro.Simon Howard
Subversion-branch: /branches/opl-branch Subversion-revision: 1670
2009-09-12Discard an existing voice when no voices are available (based onSimon Howard
research with Vanilla). Subversion-branch: /branches/opl-branch Subversion-revision: 1668
2009-09-11Implement the fine tuning field, based on research.Simon Howard
Subversion-branch: /branches/opl-branch Subversion-revision: 1664
2009-09-08Set the correct instrument voice, instead of using the first voice forSimon Howard
both. Subversion-branch: /branches/opl-branch Subversion-revision: 1661
2009-09-08Program two voices for double voice instruments.Simon Howard
Subversion-branch: /branches/opl-branch Subversion-revision: 1660
2009-09-07Implement pitch bend.Simon Howard
Subversion-branch: /branches/opl-branch Subversion-revision: 1658
2009-09-01Loop songs (when appropriate)Simon Howard
Subversion-branch: /branches/opl-branch Subversion-revision: 1654
2009-08-31Perform volume mapping on note and channel volumes before multiplyingSimon Howard
them. This gives voice volume values that are almost identical to Doom's. Subversion-branch: /branches/opl-branch Subversion-revision: 1653
2009-08-31Dont program an instrument if it is already set.Simon Howard
Subversion-branch: /branches/opl-branch Subversion-revision: 1652
2009-08-31Set the volume on both operators for instruments that use non-modulatingSimon Howard
voice mode. Subversion-branch: /branches/opl-branch Subversion-revision: 1651
2009-08-31Make channel volume work.Simon Howard
Subversion-branch: /branches/opl-branch Subversion-revision: 1650
2009-08-30Use fixed note on instruments with the fixed note flag set.Simon Howard
Subversion-branch: /branches/opl-branch Subversion-revision: 1649
2009-08-30Use milliseconds rather than microseconds, to avoid integer overflow.Simon Howard
Subversion-branch: /branches/opl-branch Subversion-revision: 1648
2009-08-30Make I_OPL_StopSong work.Simon Howard
Subversion-branch: /branches/opl-branch Subversion-revision: 1647
2009-08-30Use the pedal speed value for the volume. This sounds better, but it'sSimon Howard
still not right. Subversion-branch: /branches/opl-branch Subversion-revision: 1646
2009-08-30Set the right instrument for percussion notes.Simon Howard
Subversion-branch: /branches/opl-branch Subversion-revision: 1645
2009-08-30Initial, broken, volume level setting.Simon Howard
Subversion-branch: /branches/opl-branch Subversion-revision: 1644