Ejemplo n.º 1
0
Archivo: jeg.c Proyecto: Claudiu/jeg
int main( int argc, const char ** argv )
{
    PaStreamParameters outputParameters;
    PaError pa_err;
    SF_INFO sfinfo;

    int i;
    for (i = 1; i < argc; i++)
    {
        if (!strncmp(argv[i], "-m", 2))
        {
            mute = 1;
        }
        if (!strncmp(argv[i], "-o", 2))
        {
            to_stdout = 1;
        }
    }

    gen_default_drums();

    pa_err = Pa_Initialize();
    outputParameters.device = Pa_GetDefaultOutputDevice();
    outputParameters.channelCount = CHANNELS;
    outputParameters.sampleFormat = paFloat32;
    outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
    outputParameters.hostApiSpecificStreamInfo = NULL;
    pa_err = Pa_OpenStream( &stream, NULL, &outputParameters, SAMPLE_RATE, BUFFER_SIZE, paClipOff, audio_callback, NULL );

    sfinfo.samplerate = SAMPLE_RATE;
    sfinfo.channels = CHANNELS;
    sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_FLOAT;
    wave_output = sf_open( OUTPUT_FILE, SFM_WRITE, &sfinfo );

    convert_buf = (int32_t*)malloc(SAMPLE_RATE * 4 * 2);

    srand( time( 0 ) );

    bass_z = 0.0f;
    bass_freq = midi_to_hz( BASE_NOTE );

    pa_err = Pa_StartStream( stream );

    while( 1 )
        Pa_Sleep( 10000 );

    sf_close( wave_output );
    pa_err = Pa_StopStream( stream );
    pa_err = Pa_CloseStream( stream );
    Pa_Terminate();

    return 0;
}
Ejemplo n.º 2
0
Archivo: jeg.c Proyecto: deveah/jeg
int main( void )
{
	PaStreamParameters outputParameters;
	PaError pa_err;
	SF_INFO sfinfo;

	signal( SIGINT, interrupt );

	gen_default_drums();

	pa_err = Pa_Initialize();
	outputParameters.device = Pa_GetDefaultOutputDevice();
	outputParameters.channelCount = CHANNELS;
	outputParameters.sampleFormat = paFloat32;
	outputParameters.suggestedLatency =
		Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
	outputParameters.hostApiSpecificStreamInfo = NULL;
	pa_err = Pa_OpenStream( &stream, NULL, &outputParameters, SAMPLE_RATE,
		BUFFER_SIZE, paClipOff, audio_callback, NULL );

	sfinfo.samplerate = SAMPLE_RATE;
	sfinfo.channels = CHANNELS;
	sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_FLOAT;
	wave_output = sf_open( OUTPUT_FILE, SFM_WRITE, &sfinfo );

	srand( time( 0 ) );

	bass_z = 0.0f;
	bass_freq = midi_to_hz( BASE_NOTE );

	pa_err = Pa_StartStream( stream );
	
	while( 1 )
		Pa_Sleep( 1000 );

	sf_close( wave_output );
	pa_err = Pa_StopStream( stream );
	pa_err = Pa_CloseStream( stream );
	Pa_Terminate();

	return 0;
}