summaryrefslogtreecommitdiff
path: root/src/i_oplmusic.c
AgeCommit message (Collapse)Author
2015-05-27opl: Some minor tweaks to the last merge.Simon Howard
Formatting, variable names, don't pollute global variable namespace.
2015-05-27Merge pull request #516 from khokh2001/oldoplSimon Howard
Older DMX's OPL voice allocation algorithm
2015-05-27opl: Tweak voice replacement algorithm.Simon Howard
Prefer replacing a second voice before a voice from a higher- numbered channel. This resolves some issues with the MAP01 music, as noted in comments on #468; it may not be Vanilla behavior in terms of code but seems to better match it based on observation, and makes logical sense. Also adjust code to fit to the 80 column limit.
2015-03-10OPL code guideline style fixkhokh2001
2015-03-09Hexen and Heretic use older DMX. Since OPL Voice Allocating algorithm ↵khokh2001
differ. This commit adds old DMX's voice allocating alogrithm for Hexen and Heretic.
2014-11-01opl: Fix code style to match guidelines.Simon Howard
Eliminate tab characters and trailing whitespace. Add extra whitespace around operators in for() expressions.
2014-11-01Merge pull request #466 from khokh2001/opl-fix2Simon Howard
opl note limitation and octave overflow fixes Adjust how the OPL MIDI code behaves at extreme MIDI note values (high/low octaves) to better match how the Doom DMX library decides on the OPL register value (thanks Alexey Khokholov / khokh20010.
2014-11-01Merge pull request #465 from khokh2001/opl-fixSimon Howard
opl additive voice volume calculation fix Adjust how the OPL volume register values are calculated based on the channel, note and global MIDI volume, to better match how the Doom DMX library performs these calculations (thanks Alexey Khokholov / khokh2001).
2014-11-01opl: Internally swap MUS/MID percussion channel #s.Simon Howard
MIDI uses channel 9 for percussion but MUS uses channel 15. As the channel numbers matter when we run out of free voices (#468), internally swap channels 9 and 15 so that channel precedence is decided correctly.
2014-10-29opl additive voice volume calculation fixkhokh2001
opl additive voice volume calculation fix
2014-10-29Update i_oplmusic.ckhokh2001
2014-10-28Merge pull request #468 from khokh2001/opl-fix4Simon Howard
Fix voice allocation when there are no more free voices. This fixes a long-standing (but minor) discrepancy between the OPL code and the DMX library that was marked in the code with a TODO.
2014-10-29opl voice allocation fixkhokh2001
opl voice allocation fix when there are no free voices
2014-10-29opl drum note fixkhokh2001
fixed note drum instrument should be 60
2014-10-29opl note limitation and octave overflow fixeskhokh2001
2014-10-29opl additive voice volume calculation fixkhokh2001
opl additive voice volume calculation fix
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