NAS Library: Some examples

Play a file to the current server

#include <audio.h>

...
{
  AuServer *aud;
  int err;

  aud = AuOpenServer(NULL, 0, NULL, 0, NULL, NULL);
  if (!aud)
    {
      fprintf(stderr, "Can't connect to audio server\n");
      exit(-1);
    }

  err = AuSoundPlaySynchronousFromFile(aud, "hallo.au", 100);
  if (err!=0)
    printf(stderr,"Error playing file\n");

  AuCloseServer(aud);
}

Get information about a file

#include <audio.h>

...
{
  s = SoundOpenFileForReading("boing.wav");

  if (s)
   {
     printf("%15s %.80s\n", "File Format:", SoundFileFormatString(s));
     printf("%15s %.80s\n", "Data Format:",
            AuFormatToString(SoundDataFormat(s)));
     printf("%15s %d\n", "Tracks:", SoundNumTracks(s));
     printf("%15s %d Hz\n", "Frequency:", SoundSampleRate(s));
     printf("%15s %.2f seconds\n", "Duration:",
            (float) SoundNumSamples(s) / SoundSampleRate(s));
     printf("\n%s\n", SoundComment(s));
     SoundCloseFile(s);
   }
  else
   {
     printf(stderr,"Error reading file\n");
   }
}

Created:02.12.1998
Last modified:14.12.1998
KLOE DAQ Audio
Send comments to: Igor Sfiligoi