ScummVM API documentation
mididrv_m_adlib.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef NUVIE_SOUND_MIDIDRV_M_ADLIB_H
23#define NUVIE_SOUND_MIDIDRV_M_ADLIB_H
24
25#include "audio/adlib_ms.h"
26
27namespace Ultima {
28namespace Nuvie {
29
37protected:
38 // The direction of a volume fade: in (increase) or out (decrease).
39 enum FadeDirection {
40 FADE_DIRECTION_NONE,
41 FADE_DIRECTION_FADE_IN,
42 FADE_DIRECTION_FADE_OUT
43 };
44
45 // The current direction of vibrato pitch change.
46 enum VibratoDirection {
47 VIBRATO_DIRECTION_RISING,
48 VIBRATO_DIRECTION_FALLING
49 };
50
51 // Converts M note values to OPL frequency (F-num) values.
52 static const uint16 FNUM_VALUES[24];
53
54public:
57
59 void send(int8 source, uint32 b) override;
60 void metaEvent(int8 source, byte type, const byte *data, uint16 length) override;
61
62protected:
63 void programChange(uint8 channel, uint8 program, uint8 source) override;
64 void modulation(uint8 channel, uint8 modulation, uint8 source) override;
65
66 uint8 allocateOplChannel(uint8 channel, uint8 source, InstrumentInfo &instrumentInfo) override;
67 void writeFrequency(uint8 oplChannel, OplInstrumentRhythmType rhythmType = RHYTHM_TYPE_UNDEFINED) override;
68 uint16 calculateFrequency(uint8 channel, uint8 source, uint8 note) override;
69 uint8 calculateUnscaledVolume(uint8 channel, uint8 source, uint8 velocity, const OplInstrumentDefinition &instrumentDef, uint8 operatorNum) override;
70 void writeVolume(uint8 oplChannel, uint8 operatorNum, OplInstrumentRhythmType rhythmType = RHYTHM_TYPE_UNDEFINED) override;
71
72 void deinitSource(uint8 source) override;
73
74 void onTimer() override;
75
76 // Number of F-num units each channel will increase/decrease each tick.
77 int8 _slideValues[9];
78 // Maximum number of F-num units the frequency will be changed by vibrato,
79 // before applying the factor, for each channel. This is the difference
80 // between the lowest and highest value (so twice the amplitude).
81 uint8 _vibratoDepths[9];
82 // Multiplication factor for vibrato F-num values for each channel.
83 uint8 _vibratoFactors[9];
84 // The current "progression" of vibrato through the cycle for each channel.
85 // This is before the vibrato factor is applied.
86 uint8 _vibratoCurrentDepths[9];
87 // The current direction in which the vibrato is progressing for each
88 // channel (rising or falling frequency).
89 VibratoDirection _vibratoDirections[9];
90 // The direction of the fade currently active on each channel (in or out).
91 // NONE indicates no fade is active.
92 FadeDirection _fadeDirections[9];
93 // The delay in ticks between each level increase or decrease for each
94 // channel.
95 uint8 _fadeStepDelays[9];
96 // The current fade delay counter value for each channel.
97 uint8 _fadeCurrentDelays[9];
98};
99
100} // End of namespace Nuvie
101} // End of namespace Ultima
102
103#endif
Definition: adlib_ms.h:295
void send(uint32 b) override
Definition: mididrv_m_adlib.h:36
uint8 calculateUnscaledVolume(uint8 channel, uint8 source, uint8 velocity, const OplInstrumentDefinition &instrumentDef, uint8 operatorNum) override
void writeVolume(uint8 oplChannel, uint8 operatorNum, OplInstrumentRhythmType rhythmType=RHYTHM_TYPE_UNDEFINED) override
void writeFrequency(uint8 oplChannel, OplInstrumentRhythmType rhythmType=RHYTHM_TYPE_UNDEFINED) override
void send(int8 source, uint32 b) override
void deinitSource(uint8 source) override
void programChange(uint8 channel, uint8 program, uint8 source) override
void modulation(uint8 channel, uint8 modulation, uint8 source) override
uint8 allocateOplChannel(uint8 channel, uint8 source, InstrumentInfo &instrumentInfo) override
void metaEvent(int8 source, byte type, const byte *data, uint16 length) override
uint16 calculateFrequency(uint8 channel, uint8 source, uint8 note) override
Definition: adlib_ms.h:79