Mario Goebbels wrote:
I've cleaned up the little hacking I've did here and there this week.
The patch works against build 1015 (CDDL). Comments about code quality
would be nice, since I'm jumping into cold water here in regards to
writing C.

Supports front output on the Xonar DX only. I'll be looking into the
other outputs somewhen next week. I'm using it right now and works fine
for simple stereo playback.

-mg


------------------------------------------------------------------------

_______________________________________________
oss-devel mailing list
oss-devel@mailman.opensound.com
http://mailman.opensound.com/mailman/listinfo/oss-devel


Thanks Mario. I'd like you to also check 4/5.1 output.
Enclosed is an app that you can compile
(cc -o playw playw.c -lm) and it should play multichannel output

You may need to disable vmix (run ossdetect -v) (or set vmix_multichannel=1 in /kernel/drv/vmix.conf and run ossdetect again)

playw.c is a nifty app - it will play 1 beep on front left, 2 beeps on front right, 3 beeps on rear left, 4 on rear right and so on. You can modify the app to do 8 channels or 4 channels or 2 channels.

regards
Dev Mazumdar

--
-----------------------------------------------------------
4Front Technologies
4035 Lafayette Place, Unit F, Culver City, CA 90232, USA.
Tel: (310) 202 8530             URL: www.opensound.com
Fax: (310) 202 0496             Email: [EMAIL PROTECTED]
-----------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
#include <math.h>

/* set the number of channels to  2, 4 or 8 */

#define TEST_CHANNELS 6
char DEVICE[50];

#define PI2 (3.14159265358*2)

static float incr = PI2 * 440 / 48000;

short
get_sample ()
{
  static float phase = 0;
  static int s_out = 0;
  short dta;
  short limit;

  phase += incr;
  s_out++;

  if (s_out > 1024)
    {
      //incr+=((rand()&32767)-16384)*(0.001/32767);     
      s_out = 0;
    }

  while (phase >= PI2)
    phase -= PI2;

  dta = (short) ((sin (phase) + 0.000000001) * 16384);

  limit = ((rand () & 1023) + 16384 - 1023);
  if (dta > limit)
    dta = limit;
  else if (dta < -limit)
    dta = -limit;
  return dta;
}

int samples_out = 0;
int pulses = 0;

short
get_analognoise ()
{
  return (rand () & 127) + (rand () & 127) + (rand () & 127) +
    (rand () & 127) + (rand () & 127) + (rand () & 127) + (rand () & 127) +
    (rand () & 127);

}

short
get_pulse ()
{
  samples_out++;
  if (samples_out > 26000)
    {
      pulses++;
      samples_out = 0;
    }

  if (samples_out > 10000)
    return get_sample () + get_analognoise ();
  else
    return get_analognoise ();
}

int
main (int argc, char **argv)
{
  short dta[1024];
  int t, channels, arg, fd, k;
  FILE *fdz;
  int i=0, j;

//  for (i = 0; i < 48; i++)
    {
      sprintf (DEVICE, "/dev/dsp_multich");
      printf ("testing %s\n", DEVICE);
      fdz = fopen (DEVICE, "wb");
      if (!fdz)
        {
          printf ("Unable to open device\n");
          return -1;
        }

      fd = fileno (fdz);

      arg = 0x0002000F;
      if (ioctl (fd, SNDCTL_DSP_SETFRAGMENT, &arg) == -1)
        perror ("SNDCTL_DSP_SETFRAGMENT");


      arg = AFMT_S16_LE;
      if (ioctl (fd, SNDCTL_DSP_SETFMT, &arg) == -1)
        perror ("SNDCTL_DSP_SETFMT");
      fprintf (stderr, "Format %s\n", (arg == 16) ? "stereo" : "mono");

      arg = TEST_CHANNELS;
      if (ioctl (fd, SNDCTL_DSP_CHANNELS, &arg) == -1)
        perror ("SNDCTL_DSP_CHANNELS");
      if (arg == 1)
        arg = 2;
      if (ioctl (fd, SNDCTL_DSP_CHANNELS, &arg) == -1)
        perror ("SNDCTL_DSP_CHANNELS");
      channels = arg;

      fprintf (stderr, "Channels %d\n", arg);

      arg = 48000;
      if (ioctl (fd, SNDCTL_DSP_SPEED, &arg) == -1)
        perror ("SNDCTL_DSP_SPEED");


      j = 0;
      while (j < 2)
        {
          for (t = 0; t < channels; t++)
            {
              printf ("playing chan = %d\n", t + 1);
              samples_out = 0;
              pulses = 0;
              while (pulses != (t + 1))
                {
                  for (k = 0; k < channels; k++)
                    {
                      if (k == t)
                        dta[k] = get_pulse ();
                      else
                        dta[k] = 0;

                    }
                  fwrite (dta, 2, channels, fdz);
                }
            }
          j++;
        }
      fclose (fdz);
    }
  return 0;
}
_______________________________________________
oss-devel mailing list
oss-devel@mailman.opensound.com
http://mailman.opensound.com/mailman/listinfo/oss-devel

Reply via email to