We present a flexible and compact, digital, lock-in detection system and its use in high-resolution tunable diode laser spectroscopy. The system involves coherent sampling, and is based on the synchronization of two data acquisition cards running on a single standard computer. A software-controlled arbitrary waveform generator is used for laser modulation, and a four-channel analog/digital board records detector signals. Gas spectroscopy is performed in the wavelength modulation regime. The coherently detected signal is averaged a selected number of times before it is stored or analyzed by software-based, lock-in techniques. Multiple harmonics of the modulation signal (1f, 2f, 3f, 4f, etc.) are available in each single data set. The sensitivity is of the order of 10(-5), being limited by interference fringes in the measurement setup. The capabilities of the system are demonstrated by measurements of molecular oxygen in ambient air, as well as dispersed gas in scattering materials, such as plants and human tissue.