Audio-DSP

 view release on metacpan or  search on metacpan

DSP.xs  view on Meta::CPAN

#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>

#define AUDIO_FILE_BUFFER_SIZE 4096

static int
not_here(char *s)
{
    croak("%s not implemented on this architecture", s);
    return -1;
}

static double
constant(char *name, int arg)
{
    errno = 0;
    switch (*name) {
    case 'A':
        if (strEQ(name, "AFMT_A_LAW"))
#ifdef AFMT_A_LAW
            return AFMT_A_LAW;
#else
            goto not_there;
#endif
        if (strEQ(name, "AFMT_IMA_ADPCM"))
#ifdef AFMT_IMA_ADPCM
            return AFMT_IMA_ADPCM;
#else
            goto not_there;
#endif
        if (strEQ(name, "AFMT_MPEG"))
#ifdef AFMT_MPEG
            return AFMT_MPEG;
#else
            goto not_there;
#endif
        if (strEQ(name, "AFMT_MU_LAW"))
#ifdef AFMT_MU_LAW
            return AFMT_MU_LAW;
#else
            goto not_there;
#endif
        if (strEQ(name, "AFMT_QUERY"))
#ifdef AFMT_QUERY
            return AFMT_QUERY;
#else
            goto not_there;
#endif
        if (strEQ(name, "AFMT_S16_BE"))
#ifdef AFMT_S16_BE
            return AFMT_S16_BE;
#else
            goto not_there;
#endif
        if (strEQ(name, "AFMT_S16_LE"))
#ifdef AFMT_S16_LE
            return AFMT_S16_LE;
#else
            goto not_there;
#endif
        if (strEQ(name, "AFMT_S16_NE"))
#ifdef AFMT_S16_NE
            return AFMT_S16_NE;
#else
            goto not_there;
#endif
        if (strEQ(name, "AFMT_S8"))
#ifdef AFMT_S8
            return AFMT_S8;
#else
            goto not_there;
#endif
        if (strEQ(name, "AFMT_U16_BE"))
#ifdef AFMT_U16_BE
            return AFMT_U16_BE;
#else
            goto not_there;
#endif
        if (strEQ(name, "AFMT_U16_LE"))
#ifdef AFMT_U16_LE
            return AFMT_U16_LE;
#else
            goto not_there;
#endif
        if (strEQ(name, "AFMT_U8"))
#ifdef AFMT_U8
            return AFMT_U8;
#else
            goto not_there;
#endif
        break;
    }
    errno = EINVAL;
    return 0;

not_there:
    errno = ENOENT;
    return 0;
}

int _audioformat (SV* fmt) {
    char* val;

    /* format specified as integer */
    if (SvIOK(fmt))
        return (SvIV(fmt));



( run in 0.225 second using v1.01-cache-2.11-cpan-55f5a4728d2 )