/*
 * Purpose: Recording device to local input buffer import routine for vmix
 */
/*
 * This file is part of Open Sound System
 *
 * Copyright (C) 4Front Technologies 1996-2007.
 *
 * This software is released under CDDL 1.0 source license for operating systems
 * that have their full source code available under the BSD or CDDL licenses.
 *
 * See the COPYING file included in the main directory of this source
 * distribution. Please contact sales@opensound.com for further info.
 */

/*
 * NOTE! This is not the development version of this file. Please download the
 * sources of the latest Open Sound System version from 
 * http://developer.opensound.com/sources if you plan to make any changes
 * to the software.
 */

int i, ch;

for (ch = 0; ch < channels; ch++)
  {
    float vu;

    vu = eng->vu[ch % 2];
    vu = vu / 255.0;

    op = (SAMPLE_TYPE *) inbuf;
    op += ch;

    float *chbuf;

    chbuf = chbufs[ch];

    for (i = 0; i < samples; i++)
      {
	float tmp;

#if 0 && defined(SINE_DEBUG)
	/* Generate internal sine wave test signal */
	tmp = 0;
	if (ch < 2)
	  {
	    tmp = sine_table[sine_phase[ch]];
	    sine_phase[ch] = (sine_phase[ch] + 1) % SINE_SIZE;
	  }
#else
	tmp = VMIX_BYTESWAP (*op);
	tmp /= SAMPLE_RANGE;

	if (tmp < -1.0)
	  tmp = -1.0;
	else if (tmp > 1.0)
	  tmp = 1.0;

#endif
	op += channels;

	*chbuf++ = tmp;

	/* VU meter */
	if (tmp < 0.0)
	  tmp = -tmp;
	if (tmp > vu)
	  vu = tmp;
      }

    if (ch < 2)
      {
	vu = vu * 255.0;
	eng->vu[ch] = vu;
      }
  }
