The middle Pleistocene transition by frequency locking and slow ramping of internal period