Csound Csound-dev Csound-tekno Search About

[CUD] rtaudio.c modif for linux

Date1999-03-02 17:31
FromAntoine Lefebvre
Subject[CUD] rtaudio.c modif for linux
Hello csounder,
I have made an useful modification to rtaudio.c for the people who have
two soundcard and want to use one for input and the other for output.

#ifdef LINUX                                  /* Jonathan Mohr  1995 Oct 17 */
#include 
#include 
/* in this section you can specify your device for input and for
output */
#define DSPIN_NAME  "/dev/dsp1"
#define DSPOUT_NAME    "/dev/dsp"
static int dspinfd;
static int dspoutfd;
/* */
void setsndparms(int, int, int, float, unsigned);
void setvolume(volume);
#endif
.
.
.
/* in this section I change DSP_NAME for DSPIN_NAME and
dspfd for dspinfd */

#ifdef LINUX                                  /* Jonathan Mohr  1995 Oct 17 */
        /* open DSP device for reading */
        if ( (dspinfd = open(DSPIN_NAME, O_RDONLY)) == -1 ) 
          die("unable to open soundcard for audio input");

        /* initialize data format, channels, sample rate, and buffer size */
        setsndparms( dspinfd, O.informat, nchnls, esr, oMaxLag * O.insampsiz );
#endif
.
.
.

/*same thing here but for DSPOUT_NAME and dspoutfd */
#ifdef LINUX                                       /*  J. Mohr  1995 Oct 17 */
/* The following code not only opens the DSP device (soundcard and driver)
   for writing and initializes it for the proper sample size, rate, and
   channels, but allows the user to set the output volume.                  */
    {
        extern void setscheduler(void);
        /* open DSP device for writing */
        if ( (dspoutfd = open(DSPOUT_NAME, O_WRONLY)) == -1 )
          die("unable to open soundcard for audio output");

        /* set sample size/format, rate, channels, and DMA buffer size */
        setsndparms( dspoutfd, O.outformat, nchnls, esr,
                     O.outbufsamps * O.outsampsiz);

.
.
.
/* after that, all the dspfd are change to dspinfd or dspoutfd
depending if they are use for input or output*/

/*Don't forget to close the two file descriptor*/


It is possible to use a 
csound -odevaudio -idevaudio .....
csound will use the good soundcard


-- 
Antoine Lefebvre
antoinelefebvre@softhome.net
http://pages.infinit.net/linux/music/music.html

Date1999-03-03 06:07
FromNicola Bernardini
SubjectRe: [CUD] rtaudio.c modif for linux
Dear Antoine,

thank you very much for you patch to rtaudio.c - we should consider
inserting it into the unofficial distribution and have it controlled
by the configure process. I can handle that. However, you seem to have
quite an old version: rtaudio.c is not used any longer - rtlinux.c has
been created (both in the official and unofficial distribution). Also,
you should send a complete diff file (possibly from a recent version)
that you can obtain by running:

	diff -BbNu rtlinux.c.orig rtlinux.c

so that we can just apply it with 'patch' and work from there (sorry
if you already know all these things, I just mean to save time...).

Thanks again!

Nicola

------------------------------------------------------------------------
Nicola Bernardini
E-mail: nicb@axnet.it
 
Re graphics: A picture is worth 10K words -- but only those to describe
the picture.  Hardly any sets of 10K words can be adequately described
with pictures.

On Tue, 2 Mar 1999, Antoine Lefebvre wrote:

> Hello csounder,
> I have made an useful modification to rtaudio.c for the people who have
> two soundcard and want to use one for input and the other for output.
> 
> #ifdef LINUX                                  /* Jonathan Mohr  1995 Oct 17 */
> #include 
> #include 
> /* in this section you can specify your device for input and for
> output */
> #define DSPIN_NAME  "/dev/dsp1"
> #define DSPOUT_NAME    "/dev/dsp"
> static int dspinfd;
> static int dspoutfd;
> /* */
> void setsndparms(int, int, int, float, unsigned);
> void setvolume(volume);
> #endif
>