frequency encoding input and output