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 
27 namespace Ultima {
28 namespace Nuvie {
29 
37 protected:
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 
54 public:
57 
59  void send(int8 source, uint32 b) override;
60  void metaEvent(int8 source, byte type, byte *data, uint16 length) override;
61 
62 protected:
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, uint8 instrumentId) override;
67  uint16 calculateFrequency(uint8 channel, uint8 source, uint8 note) override;
68  uint8 calculateUnscaledVolume(uint8 channel, uint8 source, uint8 velocity, OplInstrumentDefinition &instrumentDef, uint8 operatorNum) override;
69  void writeVolume(uint8 oplChannel, uint8 operatorNum, OplInstrumentRhythmType rhythmType = RHYTHM_TYPE_UNDEFINED) override;
70 
71  void deinitSource(uint8 source) override;
72 
73  void onTimer() override;
74 
75  // Number of F-num units each channel will increase/decrease each tick.
76  int8 _slideValues[9];
77  // Maximum number of F-num units the frequency will be changed by vibrato,
78  // before applying the factor, for each channel. This is the difference
79  // between the lowest and highest value (so twice the amplitude).
80  uint8 _vibratoDepths[9];
81  // Multiplication factor for vibrato F-num values for each channel.
82  uint8 _vibratoFactors[9];
83  // The current "progression" of vibrato through the cycle for each channel.
84  // This is before the vibrato factor is applied.
85  uint8 _vibratoCurrentDepths[9];
86  // The current direction in which the vibrato is progressing for each
87  // channel (rising or falling frequency).
88  VibratoDirection _vibratoDirections[9];
89  // The direction of the fade currently active on each channel (in or out).
90  // NONE indicates no fade is active.
91  FadeDirection _fadeDirections[9];
92  // The delay in ticks between each level increase or decrease for each
93  // channel.
94  uint8 _fadeStepDelays[9];
95  // The current fade delay counter value for each channel.
96  uint8 _fadeCurrentDelays[9];
97 };
98 
99 } // End of namespace Nuvie
100 } // End of namespace Ultima
101 
102 #endif
uint8 allocateOplChannel(uint8 channel, uint8 source, uint8 instrumentId) override
void metaEvent(int8 source, byte type, byte *data, uint16 length) override
void deinitSource(uint8 source) override
uint8 calculateUnscaledVolume(uint8 channel, uint8 source, uint8 velocity, OplInstrumentDefinition &instrumentDef, uint8 operatorNum) override
void programChange(uint8 channel, uint8 program, uint8 source) override
Definition: adlib_ms.h:289
Definition: detection.h:27
void modulation(uint8 channel, uint8 modulation, uint8 source) override
void send(int8 source, uint32 b) override
void send(uint32 b) override
void writeVolume(uint8 oplChannel, uint8 operatorNum, OplInstrumentRhythmType rhythmType=RHYTHM_TYPE_UNDEFINED) override
Definition: adlib_ms.h:79
Definition: mididrv_m_adlib.h:36
uint16 calculateFrequency(uint8 channel, uint8 source, uint8 note) override