Valve timing is critical to the performance of hydraulic piston motors and pumps. With non-optimal valve timing, the pressure differential across the valve during a valve opening or closing can be significant, causing transitional throttling loss and reducing the energy efficiency. The goal of this thesis is to provide a fundamental understanding of the role of valve timing and propose a viable active valve solution for better efficiency of hydraulic pumps and motors. Previously, researchers have proposed a variety of valve timing models based on analytical modeling, numerical simulation, and optimization. However, many critical questions, such as the relationship between the valve timing and throttling energy loss, the meaning of the valve timing optimality, and the influence of the fluid compressibility with entrained gas, have not been fully answered. Prior work on valves with active timing have focused on reducing the valve transition time, leakage, and dead volume. The cylindrical rotary valve architecture has been found to be a promising solution, provided that the leakage issue is solved. In this research, a new two-phase analytical valve timing solution, a complete active motor-valve numerical model, a prototype cylindrical rotary valve, and a novel fluid compressibility experiment have been developed. Results have shown that the analytical valve timing solution is capable of capturing the trade-offs between throttling energy loss and output piston work. A full model of a motor was used to optimize valve timing for a specific operating condition. The numerical model was validated experimentally, where a prototype active rotary valve was integrated into a commercial pump. A rectified bulk modulus model was derived from a novel mass transfer experiment to determine the compressibility of oil with entrained gas based on an optical bubble size measurement. The contributions of the thesis are: (1) the validated analytical and numerical models that allow finding the optimal valve timing as a function of the operating conditions, (2) a new active valve architecture that enables variable valve timing motor/pump, and (3) a rectified fluid compressibility model based on a lumped interfacial mass transport equation that predicts the effective fluid bulk modulus dynamically.