b=1012609 improve PeriodicWave phase-wrapping logic r=rillian

This approach takes advantage of the fact that periodicWaveSize is a power of
2 and uses unsigned integer modulo arithmetic to find the appropriate phase
of the period.

--HG--
extra : rebase_source : bb5fc413785d5f12a76cff4cbb5ba2ed5e979b41