コード例 #1
0
ファイル: mixtest.c プロジェクト: ricpelo/prometeo
int main(void)
  {
    init();

/*    start_sound(sound[0], 0, ON);*/ /* Start up the jet engine */

    printf("Press:\n");
    printf("  1)  Machine Gun\n");
    printf("  2)  Crash\n");
    printf("  3)  Cannon\n");
    printf("  4)  Laser\n");
    printf("  5)  Breaking glass\n");
    printf("  Q)  Quit\n");

    stop = FALSE;

    counter = 0;

    do
      {
       /* Increment and display counters */
        counter++;
        cprintf("%8lu %8lu %4u", counter, intcount, voicecount);
        gotoxy(1, wherey());

       /* Maybe start a random sound */
        if (!random(10000))
          {
           num = (random(NUMSOUNDS-1))+1;
           start_sound(sound[num], num, OFF);
          }

       /* Start a sound if a key is pressed */
        if (kbhit())
          {
            inkey = getch();
            if ((inkey >= '0') && (inkey <= '9'))
              {
                num = inkey - '0'; /* Convert to integer */
                if (num < NUMSOUNDS)
                  start_sound(sound[num], num, FALSE);
              }
            else
              stop = TRUE;
          }
      }
    while (!stop);

    printf("\n");
    stop_sound(1); /* Stop the jet engine */

    shutdown();

    return(EXIT_SUCCESS);
  }
コード例 #2
0
ファイル: sound.cpp プロジェクト: protonrc/mbtx
uint32_t test_sound()
{
//	uint32_t i ;
//	uint32_t j ;
	start_sound() ;
	return 0 ;
//	i = 0 ;
//	while ( ( DMA1->HISR & DMA_HISR_TCIF5 ) == 0 )
//	{
//		if ( ++i > 10000000 )
//		{
//			end_sound() ;
//			return 0xFFFF ;
//		}
//	}
//	j = DMA1_Stream5->FCR ;
//	TIM13->CNT = 0 ;
//	TIM13->EGR = 1 ;		// Re-start counter
//	i = 0 ;
//	while ( ( DAC->SR & DAC_SR_DMAUDR1 ) == 0 )
//	{
//		if ( ++i > 10000000 )
//		{
//			end_sound() ;
//			return 0xFFFE ;
//		}
//	}
//	return (j<<16) | TIM13->CNT ;
}
コード例 #3
0
ファイル: piezo-speaker.c プロジェクト: lgywata/soletta
static enum tune_iteration_state
tune_iterate(struct piezo_speaker_data *mdata)
{
    if (mdata->periods_us[mdata->curr_idx] == SPEAKER_NOTE_SENTINEL) {
        goto _end;
    } else {
        int r = start_sound(mdata, mdata->periods_us[mdata->curr_idx]);
        SOL_INT_CHECK(r, < 0, ITER_ERROR);
    }

_end:
    if (mdata->curr_idx == mdata->num_entries - 1 && !mdata->loop)
        return ITER_LAST;

    return ITER_NEXT;
}
コード例 #4
0
char SSInit(void)
{
	mixbuffer = (uint8_t *)malloc(SAMPLE_RATE * 2 * 2);
	
	// zero everything in all channels
	memset(channel, 0, sizeof(channel));
	for(int i=0;i<SS_NUM_CHANNELS;i++)
		channel[i].volume = SDL_MIX_MAXVOLUME;
	
	stat("sslib: initilization was successful.");

	//lockcount = 0;

	start_sound();
	
	return 0;
}
コード例 #5
0
ファイル: sound.c プロジェクト: mahiso/JudoShiai
gpointer sound_thread(gpointer args)
{
    open_sound();

    for ( ; *((gboolean *)args) ; )   /* exit loop when flag is cleared */
    {
        if (play) {
            start_sound(args);
            play = FALSE;
        } else {
            g_usleep(100000);
        }
    }

    close_sound();
    g_thread_exit(NULL);    /* not required just good pratice */
    return NULL;
}
コード例 #6
0
int main() {
	int i = 0;
	int j = 1;
	int musicCounter = 0;
	UINT8 *base = Physbase();
	UINT8 *base2 = buffer;
	
	UINT8 ch;
	UINT8 has_moved = 1;
	UINT8 switchBase = 0;
	
	UINT32 timeNow, timeThen, prevCall;

	struct Model game;
	struct Model *gamePtr = &game;
	
	base2 += 256 - ((long)base2 & (long)0xFF);

	init_model(gamePtr);
	
	disable_cursor();
	Setscreen(-1, base2, -1);
	disable_cursor();
	Setscreen(-1, base, -1);
	
	timeNow = get_time();
	timeThen = timeNow + DELAY;
	
	start_sound();
	prevCall = timeNow;
	srand(time(0));
	
	while(!game_over(gamePtr)) {
	
		if(update_music(get_time() - prevCall)){
			prevCall = get_time();		
		}
			
		/* Check if there is kbd input */
		if(kbd_is_waiting()) {
			ch = kbd_read_char();	
			request_player_move(gamePtr, 0, ch);
		}

		/* If clock ticked */
		if(timeNow != get_time()) {

			
			/* Check if a second has passed */
			if(timeNow >= timeThen) {
				update_score(gamePtr, 1);
				timeThen = timeNow + DELAY;
			}
			
			/* Move player ship */
			has_moved = move_player_ship(gamePtr, 0);
			if(has_moved){
				thruster();
			}

			/* Move enemy ships and check collisions with player ship */
			for(i = 0; i < NUM_ENEMIES; i++) {
				move_enemy_ship(gamePtr, i);
				collision(gamePtr,i,0);
			}	
			

			/* Render the model with double buffering */
			if(switchBase) {
				render_model(gamePtr, base, has_moved);
				Setscreen(-1, base, -1);
			}
			else {
				render_model(gamePtr, base2, has_moved);
				Setscreen(-1, base2, -1);
			}

			Vsync();
			switchBase = !switchBase;
			
		}
		
		stop_thruster();		
		timeNow = get_time();
	
	}
	
	stop_sound();
	explosion();
	
	render_model(gamePtr, base, has_moved);
	Setscreen(-1, base, -1);
	Vsync();
	
	return 0;
}