adiModifyPlayGain

Sets the play gain for the duration of the active play operation.

Supported board types

Prototype

DWORD adiModifyPlayGain ( CTAHD ctahd, int gain)

Argument

Description

ctahd

Context handle returned by ctaCreateContext or ctaAttachContext.

gain

The gain (dB) applied to the data as it is playing. The valid range is -54 through +24.

Return values

Return value

Description

SUCCESS

 

CTAERR_FUNCTION_NOT_ACTIVE

Play operation is not currently active.

CTAERR_INVALID_CTAHD

Context handle is invalid.

CTAERR_INVALID_STATE

Function not valid in the current port state.

CTAERR_SVR_COMM

Server communication error.

Details

Use adiModifyPlayGain to alter the gain applied to voice data as it is being transmitted. The gain remains set only for the current play operation instance. Values specified out of range are limited by the range.

See also

adiModifyPlaySpeed, adiPlayAsync, adiPlayFromMemory, adiStartPlaying, adiStopPlaying

Example

int myPlaySmartly( CTAHD ctahd, unsigned encoding,
                 void *buffer, unsigned bufsize )
{
  ADI_PLAY_PARMS playparms;
    CTA_EVENT event;
  int currentgain = 0;
  int currentspeed = 100;

  ctaGetParms( ADI_COLLECT_PARMID, &playparms, sizeof playparms );
  playparms.DTMFabort = 0x0; /* Don't abort on any DTMF */

  if( adiPlayFromMemory( ctahd, encoding,
                         buffer, bufsize, &playparms ) != SUCCESS )
      return MYFAILURE;

  do
  {
      myGetEvent( &event ); /* see ctaWaitEvent example */

      switch( event.id )
      {
          case ADIEVN_DIGIT_BEGIN:
              switch( (char)event.value )
              {
                    case '1': /* slower */
                        currentspeed -= 20;
                        adiModifyPlaySpeed( ctahd, currentspeed );
                        break;

                    case '3': /* faster */
                        currentspeed += 20;
                        adiModifyPlaySpeed( ctahd, currentspeed );
                        break;

                    case '4': /* softer */
                        currentgain -= 3; /* decrement 3 dB */
                        adiModifyPlayGain( ctahd, currentgain );
                        break;

                    case '6': /* louder */
                        currentgain += 3; /* increment 3 dB */
                        adiModifyPlayGain( ctahd, currentgain );
                        break;

                    default: /* ignore others */
                        break;
              }
                break;

          case ADIEVN_DIGIT_END: /* ignore end of dtmf */
          case 0: /* no event */
          default:
              break;
      }
  } while( event.id != ADIEVN_PLAY_DONE );

  if( event.value != CTA_REASON_FINISHED )
      return MYFAILURE;

  return SUCCESS;
}