Skip to content

Commit 320b8be

Browse files
committed
Inline method
1 parent de13b4d commit 320b8be

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

src/synth.c

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ static void writeOperatorReg(u8 channel, u8 op, u8 baseReg, u8 data);
3737
static void writeOctaveAndFrequency(u8 channel);
3838
static void writeSpecialModeReg(void);
3939
static u8 keyOnOffRegOffset(u8 channel);
40-
static FmChannel* fmChannel(u8 channel);
4140
static Operator* getOperator(u8 channel, u8 operator);
4241
static u8 effectiveTotalLevel(u8 channel, u8 operator, u8 totalLevel);
4342
static bool isOutputOperator(u8 algorithm, u8 operator);
@@ -90,7 +89,7 @@ void synth_noteOff(u8 channel)
9089

9190
void synth_pitch(u8 channel, u8 octave, u16 freqNumber)
9291
{
93-
FmChannel* chan = fmChannel(channel);
92+
FmChannel* chan = &fmChannels[channel];
9493
chan->octave = octave;
9594
chan->freqNumber = freqNumber;
9695
writeOctaveAndFrequency(channel);
@@ -109,21 +108,21 @@ void synth_volume(u8 channel, u8 volume)
109108

110109
void synth_stereo(u8 channel, u8 stereo)
111110
{
112-
fmChannel(channel)->stereo = stereo;
111+
fmChannels[channel].stereo = stereo;
113112
writeStereoAmsFms(channel);
114113
channelParameterUpdated(channel);
115114
}
116115

117116
void synth_algorithm(u8 channel, u8 algorithm)
118117
{
119-
fmChannel(channel)->algorithm = algorithm;
118+
fmChannels[channel].algorithm = algorithm;
120119
writeAlgorithmAndFeedback(channel);
121120
channelParameterUpdated(channel);
122121
}
123122

124123
void synth_feedback(u8 channel, u8 feedback)
125124
{
126-
fmChannel(channel)->feedback = feedback;
125+
fmChannels[channel].feedback = feedback;
127126
writeAlgorithmAndFeedback(channel);
128127
channelParameterUpdated(channel);
129128
}
@@ -225,14 +224,14 @@ void synth_globalLfoFrequency(u8 freq)
225224

226225
void synth_ams(u8 channel, u8 ams)
227226
{
228-
fmChannel(channel)->ams = ams;
227+
fmChannels[channel].ams = ams;
229228
writeStereoAmsFms(channel);
230229
channelParameterUpdated(channel);
231230
}
232231

233232
void synth_fms(u8 channel, u8 fms)
234233
{
235-
fmChannel(channel)->fms = fms;
234+
fmChannels[channel].fms = fms;
236235
writeStereoAmsFms(channel);
237236
channelParameterUpdated(channel);
238237
}
@@ -294,14 +293,9 @@ static u8 keyOnOffRegOffset(u8 channel)
294293
return (channel < 3) ? channel : (channel + 1);
295294
}
296295

297-
static FmChannel* fmChannel(u8 channel)
298-
{
299-
return &fmChannels[channel];
300-
}
301-
302296
static Operator* getOperator(u8 channel, u8 operator)
303297
{
304-
return &fmChannel(channel)->operators[operator];
298+
return &fmChannels[channel].operators[operator];
305299
}
306300

307301
static void writeGlobalLfo(void)
@@ -311,20 +305,20 @@ static void writeGlobalLfo(void)
311305

312306
static void writeOctaveAndFrequency(u8 channel)
313307
{
314-
FmChannel* chan = fmChannel(channel);
308+
FmChannel* chan = &fmChannels[channel];
315309
writeChannelReg(channel, 0xA4, (chan->freqNumber >> 8) | (chan->octave << 3));
316310
writeChannelReg(channel, 0xA0, chan->freqNumber);
317311
}
318312

319313
static void writeAlgorithmAndFeedback(u8 channel)
320314
{
321-
FmChannel* chan = fmChannel(channel);
315+
FmChannel* chan = &fmChannels[channel];
322316
writeChannelReg(channel, 0xB0, (chan->feedback << 3) + chan->algorithm);
323317
}
324318

325319
static void writeStereoAmsFms(u8 channel)
326320
{
327-
FmChannel* chan = fmChannel(channel);
321+
FmChannel* chan = &fmChannels[channel];
328322
writeChannelReg(channel, 0xB4, (chan->stereo << 6) + (chan->ams << 4) + chan->fms);
329323
}
330324

@@ -373,7 +367,7 @@ static void writeOperatorTotalLevel(u8 channel, u8 operator)
373367

374368
static u8 effectiveTotalLevel(u8 channel, u8 operator, u8 totalLevel)
375369
{
376-
return isOutputOperator(fmChannel(channel)->algorithm, operator)
370+
return isOutputOperator(fmChannels[channel].algorithm, operator)
377371
? volumeAdjustedTotalLevel(channel, totalLevel)
378372
: totalLevel;
379373
}
@@ -395,7 +389,7 @@ static u8 volumeAdjustedTotalLevel(u8 channel, u8 totalLevel)
395389

396390
const FmChannel* synth_channelParameters(u8 channel)
397391
{
398-
return fmChannel(channel);
392+
return &fmChannels[channel];
399393
}
400394

401395
const Global* synth_globalParameters()
@@ -430,7 +424,7 @@ void synth_specialModePitch(u8 op, u8 octave, u16 freqNumber)
430424
void synth_specialModeVolume(u8 operator, u8 volume)
431425
{
432426
Operator* op = getOperator(CH_SPECIAL_MODE, operator);
433-
if (!isOutputOperator(fmChannel(CH_SPECIAL_MODE)->algorithm, operator)) {
427+
if (!isOutputOperator(fmChannels[CH_SPECIAL_MODE].algorithm, operator)) {
434428
return;
435429
}
436430

0 commit comments

Comments
 (0)