Text this: On-chip real-time detection of optical frequency variations with ultrahigh resolution using the sine-cosine encoder approach