Skip to content

Commit eb77409

Browse files
committed
refactor: tidy up pitchcents module
1 parent f225ef0 commit eb77409

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/pitchcents.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,11 @@ PitchCents pc_bend(u8 pitch, s8 cents, u16 pitchBend, PitchCents range)
55
{
66
s16 centsRange = range.pitch * 100 + range.cents;
77
s16 centsAdd = ((pitchBend - MIDI_PITCH_BEND_CENTRE) * centsRange) / 8192;
8-
PitchCents pc = { .pitch = pitch, .cents = cents };
9-
return pc_shift(pc, centsAdd);
8+
return pc_shift((PitchCents) { .pitch = pitch, .cents = cents }, centsAdd);
109
}
1110

1211
PitchCents pc_shift(PitchCents pc, s16 centsAdd)
1312
{
14-
u16 totalCents = (pc.pitch * 100) + pc.cents;
15-
totalCents += centsAdd;
16-
17-
pc.pitch = totalCents / 100;
18-
pc.cents = totalCents % 100;
19-
return pc;
13+
u16 totalCents = ((pc.pitch * 100) + pc.cents) + centsAdd;
14+
return (PitchCents) { .pitch = totalCents / 100, .cents = totalCents % 100 };
2015
}

0 commit comments

Comments
 (0)