예제 #1
0
void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context) 
{ 
    short *this_buffer=recorderBufferA;
    if (current_buffer==0) this_buffer=recorderBufferB;    
    memcpy(processBuffer,this_buffer,RECORDER_FRAMES * sizeof(short));
    audio_process(processBuffer);

    SLresult result; // enqueue another buffer 
    result = (*bqPlayerBufferQueue)->Enqueue(bqPlayerBufferQueue, processBuffer, RECORDER_FRAMES*sizeof(short));
} 
예제 #2
0
파일: mstest.c 프로젝트: nomeata/mslib
int main( int argc, char **argv ) {
	short *data;
	short *blocks;
	int fd;
	struct stat fdStat;
	int offset = 0;

	if( argc == 1 ) {
		printf( "%s <audio file>\n", argv[0] );
		return 1;
	}

	fd = open( argv[1], O_RDONLY );
	if( fd == -1 ) {
		perror( "Failed to open audio file" );
		return -1;
	}

	if( fstat( fd, &fdStat ) ) {
		perror( "Failed to stat file" );
		return -1;
	}

	data = mmap( 0, fdStat.st_size, PROT_READ, MAP_SHARED, fd, 0 );

	if( data == MAP_FAILED ) {
		close( fd );
		perror( "Failed to map file" );
		return -1;
	}

	if( !strncmp( ( argv[1] + strlen( argv[1] - 4 ) ), ".wav", 4 ) ) {
		// use a 44byte offset for .wav files to bypass header
		offset = 44;
	}
	blocks = (short *)(data + offset);

	audio_process( blocks + offset, ( fdStat.st_size - offset ) / sizeof( short ) );

	if( munmap( data, fdStat.st_size ) == -1 ) {
		perror( "Failed to unmap file" );
	}
	close( fd );

	return 0;
}
예제 #3
0
파일: main.c 프로젝트: ekiwi/led-table
int main(){
	// Initialize Peripherals
	interface_init();
	red_led_on();
	uart_init(BAUDRATE);
	animation_manager_init();
	sys_timer_start();
	audio_init();
	sei();	// enable global interrupts

	// Load Default Animation
	animation_manager_load_animation(START_ANIMATION);

	// Enter Setup if Requested
	_delay_ms(100);
	if(deb_switch_1()){
		setup_wb_run();
	}
	else if(deb_switch_2()){
		setup_orientation_run();
	}

	// Load Default Animation
	animation_manager_load_animation(START_ANIMATION);

	// Set White Balance
	_delay_ms(300);
	display_wb_update();
	while(uart_async_run());	// setup white balance

	// Control Panel is Ready => Signal this by Turning the LED Green
	red_led_off();
	green_led_on();

	while(1){
		// Sleep Mode
		if(!switch_on_off()){	// if switched off
			go_to_sleep();
		}

		// Change animations
		sw_check();
		if(sw_check_pressed(SW_LEFT, 200, true)){
			animation_manager_dec_animation();
		}
		else if(sw_check_pressed(SW_RIGHT, 200, true)){
			animation_manager_inc_animation();
		}
		else if(sw_check_pressed(SW_RAND, 300, true)){
			animation_manager_random_animation();
		}

		// Generate Image
		animation_manager_run(0);

		// Check Audio
		audio_start();
		while(audio_run());
		audio_process();

		// Display Image
		while(uart_async_run()){
			interface_async_run();
		}

	}
}