Modplug mixing flow
From SDWiki
Handy dandy reference for tracking down Modplug problems. Note: this no longer corresponds with reality, since it was written a long time ago against the mostly-unchanged code base from libmodplug.
Contents |
[edit] Read @ sndmix.cpp:244
while {
ReadNote
X86_StereoFill
CreateStereoMix
ProcessStereoDSP
gpSndMixHook (externally defined)
X86_Convert32To{8,16,24,32}
} // while
[edit] ReadNote @ sndmix.cpp:488
ProcessRow
calculate master volume
for each channel {
if period and length are defined {
tremolo
tremor
if instrument mode {
volume envelope
panning envelope
handle note fade
pitch/pan separation
}
arpeggio
pitch/filter envelope
vibrato
panbrello
instrument auto-vibrato
check period limits
calculate frequency from period
}
if instrument mode {
increment envelope positions
}
handle volume ramping
if sample playing {
adjust stereo volume (panning, clipping, ramping)
add to mix list
}
}
if too many channels {
sort mixing channels by priority
}
[edit] ProcessRow @ sndmix.cpp:358
if this is a new row {
reset the position and tick count
if not looping a pattern {
get pattern from orderlist
if not a valid pattern {
while the pattern is invalid {
if end of song reached {
loop back to the restart position
} else {
increment the (new) order
}
get pattern from orderlist (same block of code as above)
}
}
set the current order to the new one
}
if single step {
disable single step and pause
}
check ranges for row number and stuff
increment the row
reset the channel values for the new row
}
see if first-tick effects should be handled
ProcessEffects
[edit] ProcessEffects @ snd_fx.cpp:771
for each channel {
handle note delay, pattern loop, and pattern delay
handle new note, instrument, and volume values
process volume column effects
process effects (huge switch statement!)
if first tick {
handle pattern loop, break, and position jump
}
}
