예제 #1
0
int main(void)
{
    PaError err;
    paTestData DATA;
    int i;
    float amplitude = 32.0 / (1<<15);
    printf("PortAudio Test: output EXTREMELY QUIET sine wave with and without dithering.\n");
    /* initialise sinusoidal wavetable */
    for( i=0; i<TABLE_SIZE; i++ )
    {
        DATA.sine[i] = (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. );
    }
    printf("\nNo treatment..\n"); fflush(stdout);
    err = PlaySine( &DATA, paClipOff | paDitherOff, amplitude );
    if( err < 0 ) goto error;
    printf("\nClip.\n");
    fflush(stdout);
    err = PlaySine( &DATA, paDitherOff, amplitude );
    if( err < 0 ) goto error;
    printf("\nClip and Dither.\n");
    fflush(stdout);
    err = PlaySine( &DATA, paNoFlag, amplitude );
    if( err < 0 ) goto error;
    return 0;
error:
    fprintf( stderr, "An error occured while using the portaudio stream\n" );
    fprintf( stderr, "Error number: %d\n", err );
    fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
    return -1;
}
예제 #2
0
int main(void)
{
    PaError err;
    paTestData data;
    int i;

    printf("PortAudio Test: output sine wave with and without clipping.\n");
    /* initialise sinusoidal wavetable */
    for( i=0; i<TABLE_SIZE; i++ )
    {
        data.sine[i] = (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. );
    }

    printf("\nHalf amplitude. Should sound like sine wave.\n"); fflush(stdout);
    err = PlaySine( &data, paClipOff | paDitherOff, 0.5f );
    if( err < 0 ) goto error;

    printf("\nFull amplitude. Should sound like sine wave.\n"); fflush(stdout);
    err = PlaySine( &data, paClipOff | paDitherOff, 0.999f );
    if( err < 0 ) goto error;

    printf("\nOver range with clipping and dithering turned OFF. Should sound very nasty.\n");
    fflush(stdout);
    err = PlaySine( &data, paClipOff | paDitherOff, 1.1f );
    if( err < 0 ) goto error;

    printf("\nOver range with clipping and dithering turned ON.  Should sound smoother than previous.\n");
    fflush(stdout);
    err = PlaySine( &data, paNoFlag, 1.1f );
    if( err < 0 ) goto error;

    printf("\nOver range with paClipOff but dithering ON.\n"
           "That forces clipping ON so it should sound the same as previous.\n");
    fflush(stdout);
    err = PlaySine( &data, paClipOff, 1.1f );
    if( err < 0 ) goto error;
    
    return 0;
error:
    fprintf( stderr, "An error occured while using the portaudio stream\n" );
    fprintf( stderr, "Error number: %d\n", err );
    fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
    return 1;
}
예제 #3
0
int main(void)
{
    PaError     err;
    paTestData  DATA;
    int         i;
    float       amplitude = 4.0 / (1<<15);
    
    printf("PortAudio Test: output EXTREMELY QUIET sine wave with and without dithering.\n");
    /* initialise sinusoidal wavetable */
    for( i=0; i<TABLE_SIZE; i++ )
    {
        DATA.sine[i] = (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. );
    }
    printf("\nNo treatment..\n"); fflush(stdout);
    err = PlaySine( &DATA, paClipOff | paDitherOff, amplitude );
    if( err < 0 ) goto done;

    printf("\nClip..\n");
    fflush(stdout);
    err = PlaySine( &DATA, paDitherOff, amplitude );
    if( err < 0 ) goto done;

    printf("\nClip and Dither..\n");
    fflush(stdout);
    err = PlaySine( &DATA, paNoFlag, amplitude );
done:
    if (err)
        {
        fprintf( stderr, "An error occured while using the portaudio stream\n" );
        fprintf( stderr, "Error number: %d\n", err );
        fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
        err = 1; /* Though PlaySine() already called Pa_Terminate(), */
        }        /* we may still call Pa_GetErrorText().             */
    else
        printf("\n(Don't forget to turn the VOLUME DOWN after listening so carefully.)\n");
    return err;  /* 0 or 1. */
}