---
name: "YSetAudioModeValues"
section: "3"
platform: "linux"
package: "liby-dev"
version: "2.14.5-7"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/YSetAudioModeValues"
---

# YSetAudioModeValues(3)

Audio values setting

## NAME

YSetAudioModeValues - Audio values setting

## SYNTAX

\#include \<Y2/Y.h\>\
 \#include \<Y2/Ylib.h\>

int YSetAudioModeValues(\
\
         YConnection \**connection*,\
\
         int *sample\_size*,\
\
         int *channels*,\
\
         int *sample\_rate*,\
\
         int *direction*,\
\
         int *allow\_fragmenting*,\
\
         int *num\_fragments*,\
\
         int *fragment\_size*\
 )

## ARGUMENTS

- *connection*

  Specifies the connection to the Y server, obtained by a call to YOpenConnection.

- *sample\_size*

  Specifies the sample size in bits, valid values are 8 or 16.

- *channels*

  Specifies the number of channels, valid values are 1 or 2. (mono and stereo respectivly).

- *sample\_rate*

  Specifies the same rate in Hz. Setting this value to 0 has a special meaning (see description farther below).

- *direction*

  Specifies to play or record, 0 for play and 1 for record. Note that record has not been fully implmented yet as of Y2, most Y servers do not support it!

- *allow\_fragmenting*

  Specifies whether to allow fragmenting of buffers (this is an OSS compliancy option). This should always be set to 1 (true) to comply with OSS.

- *num\_fragments*

  Specifies the number of buffer fragments, a value of 2 is the default.

- *fragment\_size*

  Specifies the size of each buffer fragment in bytes.

## DESCRIPTION

Audio to the values specified. Any sound objects currently being played will be killed and the owning Y clients will be notified.

If sample\_rate is set to 0, then the recorder will be shelled out. Allowing other direct programs to use the recorder's devices (DSP device, mixer, etc). Y clients will not notice any differance, the Y server will emulate (but not actually perform) normal operations (including the playing of sound objects).

To unshell the recorder, simply call YSetAudioModeValues or YChangeAudioModePreset with valid values.

## RETURN VALUE

The YSetAudioModeValues function returns -1 on error/invalid value or 0 on success.

## EXAMPLE

\#include \<stdio.h\>\
 \#include \<Y2/Y.h\>\
 \#include \<Y2/Ylib.h\>

int main(int argc, char \*argv\[\])\
 {\
\
         YConnection \*con = YOpenConnection(\
\
                 "/usr/sbin/starty",\
\
                 "127.0.0.1:9433"\
\
         );\
\
         if(con == NULL)\
\
                 [return(1)](/return/1.md);

        if(YSetAudioModeValues(\
\
                 con,     /\* Connection. \*/\
\
                 8,       /\* Sample size. \*/\
\
                 2,       /\* Channels. \*/\
\
                 11025,   /\* Sample rate. \*/\
\
                 0,       /\* Play. \*/\
\
                 True,    /\* Allow fragmenting. \*/\
\
                 2,       /\* Number of buf frags. \*/\
\
                 1024     /\* Buffer frag size in bytes. \*/\
\
         ))\
\
                 printf("Failed.\\n");\
\
         else\
\
                 printf("Success.\\n");

        YCloseConnection(con, False);

        return(0);\
 }

## SEE ALSO

[YChangeAudioModePreset(3)](/YChangeAudioModePreset/3.md) [YGetAudioStats(3)](/YGetAudioStats/3.md)
