int x_wait_for_last_refresh(double _w) { if (_w<0.0) { // on est trop lent : ca a pris plus d'une 1/60ieme de seconde pour construire la frame return 0 ; } #ifdef DRIVER_IOS extern int x_frame_rate; if (x_frame_rate==60 && g_video_offscreen_has_been_modified && !x_vbl_count) #else if (g_video_offscreen_has_been_modified && !x_vbl_count) #endif { while(!x_vbl_count && !r_sim65816.should_emulator_terminate()) micro_sleep(0.01); x_vbl_count--; } else { if(_w>0.0) { double s = get_dtime(); if (_w>0.01) micro_sleep(_w); // sur windows le micro_sleep est lÈgËrement en retard! while( get_dtime() < s+_w); } } return 0; }
static void iterate( void ) { ALfloat orientation[] = { 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f }; ALfloat xaxis[] = { 1.0f, 0.0f, 0.0f }; ALfloat yaxis[] = { 0.0f, 1.0f, 0.0f }; ALfloat zaxis[] = { 0.0f, 0.0f, 1.0f }; ALfloat *at = orientation; ALfloat *up = &orientation[3]; static ALint angle = 0; /* * rotate up vector about at vector by angle degrees. */ _alRotatePointAboutAxis(TORAD(angle), up, at); fprintf(stderr, "orientation: \n\tAT(%f %f %f)\n\tUP(%f %f %f)\n", orientation[0], orientation[1], orientation[2], orientation[3], orientation[4], orientation[5]); fprintf(stderr, "angle = %d\n", angle); angle += 15; /* increment fifeteen degrees degree */ alListenerfv(AL_ORIENTATION, orientation); micro_sleep(900000); }
static void iterate( void ) { static ALfloat position[] = { 10.0, 0.0, 4.0 }; static ALfloat movefactor = 4.5; static time_t then = 0; time_t now; ALint byteloki; ALint size; now = time( NULL ); /* Switch between left and right stereo sample every two seconds. */ if( now - then > 2 ) { then = now; movefactor *= -1.0; } position[0] += movefactor; alSourcefv( moving_source, AL_POSITION, position ); micro_sleep(500000); alGetSourceiv( moving_source, AL_BYTE_LOKI, &byteloki); alGetBufferi( stereo, AL_SIZE, &size); fprintf(stderr, "byteloki = %d size = %d\n", byteloki, size); return; }
static void iterate( void ) { static ALfloat position[] = { 10.0f, 0.0f, -4.0f }; static ALfloat movefactor = 4.5; static time_t then = 0; time_t now; int i; now = time( NULL ); /* Switch between left and right bid sample every two seconds. */ if( now - then > 2 ) { then = now; movefactor *= -1.0; } position[0] += movefactor; for(i = 0; i < NUMCONTEXTS; i++) { alcMakeContextCurrent( context_ids[i] ); alSourcefv( moving_sources[i], AL_POSITION, position ); } micro_sleep(500000); return; }
bool Play( float fadeout, float fadein, Music &oldmusic ) { if (m) { int fadesteps = fadeout*100; for (int i = fadesteps; i >= 0; i--) { oldmusic.SetVolume( i/(float) fadesteps ); micro_sleep( 10000 ); } Mix_FadeInMusic( m, 1, fadein ) != -1; micro_sleep( fadein*1000000 ); return true; } else { return false; } }
static void iterate( void ) { int i; fprintf(stderr, "NOW\n"); alSourcePlay( multis); fprintf(stderr, "OVER\n"); micro_sleep(1000000); }
int main( int argc, char* argv[] ) { ALCdevice *dev; int attrlist[] = { ALC_FREQUENCY, 22050, ALC_INVALID }; time_t shouldend; int i; dev = alcOpenDevice( NULL ); if( dev == NULL ) { return 1; } /* Initialize ALUT. */ context_id = alcCreateContext( dev, attrlist); if(context_id == NULL) { alcCloseDevice( dev ); return 1; } alcMakeContextCurrent( context_id ); fixup_function_pointers(); if(argc == 1) { init(WAVEFILE); } else { init(argv[1]); } alSourcePlay(moving_source); for(i = 0; i < 100; i++ ) { ALfloat gain = (sin(i) / 2.0) + .5; fprintf(stderr, "%f\n", gain); alListenerf(AL_GAIN_LINEAR_LOKI, gain); micro_sleep(800000); } cleanup(); alcCloseDevice( dev ); return 0; }
/* * * void Play(float fadeout, float fadein, Music &oldmusic){ * if (!m) return; * FSOUND_Stream_SetEndCallback(m,endcallback,0); * FSOUND_Stream_SetSynchCallback(m, endcallback, 0); * channel = FSOUND_Stream_PlayEx(FSOUND_FREE, m, NULL, 1); * FSOUND_SetPaused(channel, 0); * SetVolume(0); * if (fadeout*100>1) { * for (unsigned int i=0;i<fadeout*100;i++) { * SetVolume(i/(float)fadeout); * oldmusic.SetVolume(((float)fadeout-i)/fadeout); * micro_sleep (10000); * } * } * SetVolume(1); * oldmusic.Stop(); * } * void SetVolume(float vol) { * if (m) { * F_API FSOUND_SetVolume(this->channel,(int)(vol*GetMaxVolume())); * } * } */ void Play( float fadeout, float fadein, Music &oldmusic ) { if (!m) return; FSOUND_Stream_SetEndCallback( m, endcallback, 0 ); FSOUND_Stream_SetSynchCallback( m, endcallback, 0 ); channel = FSOUND_Stream_Play( FSOUND_FREE, m ); SetVolume( 0 ); if (fadeout*10 > 1) for (unsigned int i = 0; i < fadeout*10; i++) { float ratio = ( (float) i )/(fadeout*10.); SetVolume( ratio ); oldmusic.SetVolume( 1-ratio ); micro_sleep( 10000 ); } oldmusic.Stop(); oldmusic.Free(); SetVolume( 1 ); }
int main( int argc, char* argv[] ) { int attrlist[] = { ALC_FREQUENCY, 22050, 0 }; int i = 5; #if 0 const ALubyte *devspec = (const ALubyte *) "'( ( sampling-rate 22050 ) ( devices '(null)))"; #else const ALubyte *devspec = NULL; #endif /* Initialize device and context. */ dev = alcOpenDevice( devspec ); if( dev == NULL ) { return 1; } context_id = alcCreateContext( dev, attrlist ); if(context_id == NULL) { alcCloseDevice( dev ); return 1; } alcMakeContextCurrent( context_id ); fixup_function_pointers(); if(argc == 1) { init(WAVEFILE); } else { init(argv[1]); } iterate(); while(SourceIsPlaying(multis) == AL_TRUE) { micro_sleep(1000000); } cleanup(); return 0; }
static int fs_lock_obtain(Lock *lock) { int f; int trys = LOCK_OBTAIN_TIMEOUT; while (((f = open(lock->name, O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR)) < 0) && (trys > 0)) { /* sleep for 10 milliseconds */ micro_sleep(10000); trys--; } if (f >= 0) { close(f); return true; } else { return false; } }
static void iterate( void ) { ALfloat orientation[] = { 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f }; static ALint angle = 0; /* * rotate at vector about up vector by angle degrees. */ _alRotatePointAboutAxis(TORAD(angle), orientation, &orientation[3]); angle += 15; /* increment fifeteen degrees degree */ fprintf(stderr, "orientation: \n\tAT(%f %f %f)\n\tUP(%f %f %f)\n", orientation[0], orientation[1], orientation[2], orientation[3], orientation[4], orientation[5]); alListenerfv(AL_ORIENTATION, orientation); micro_sleep(1500000); }
static void iterate( void ) { static ALfloat position[] = { 10.0f, 0.0f, 4.0f }; static ALfloat movefactor = 4.5; static time_t then = 0; time_t now; now = time( NULL ); /* Switch between left and right stereo sample every two seconds. */ if( now - then > 2 ) { then = now; movefactor *= -1.0; } position[0] += movefactor; alSourcefv( moving_source, AL_POSITION, position ); micro_sleep(500000); }
int main( int argc, char* argv[] ) { ALCdevice *dev; int i = 5; dev = alcOpenDevice( NULL ); if( dev == NULL ) { return 1; } /* Initialize ALUT. */ context_id = alcCreateContext( dev, NULL ); if(context_id == NULL) { alcCloseDevice( dev ); return 1; } alcMakeContextCurrent( context_id ); fixup_function_pointers(); if(argc == 1) { init(WAVEFILE); } else { init(argv[1]); } iterate(); while(SourceIsPlaying(multis) == AL_TRUE) { micro_sleep(1000000); } cleanup(); alcCloseDevice( dev ); return 0; }
int main( int argc, char* argv[] ) { ALCdevice *dev; int i; dev = alcOpenDevice( NULL ); if( dev == NULL ) { return 1; } context_id = alcCreateContext( dev, NULL); if(context_id == NULL) { alcCloseDevice( dev ); return 1; } alcMakeContextCurrent( context_id ); fixup_function_pointers(); if(argc == 1) { init(WAVEFILE); } else { init(argv[1]); } alSourcePlay(reverb_sid); for(i = 0; i < 10; i++) { micro_sleep(1000000); } cleanup(); alcCloseDevice( dev ); return 0; }
/*---------------------------------------------------------------------------*/ static uint8_t raven_gui_loop(process_event_t ev, process_data_t data) { uint8_t i,activeconnections,radio_state; // PRINTF("\nevent %d ",ev); #if DEBUGSERIAL printf_P(PSTR("Buffer [%d]="),serialcount); serialcount=0; for (i=0;i<30;i++) { printf_P(PSTR(" %d"),dbuf[i]); dbuf[i]=0; } #endif if(ev == tcpip_icmp6_event) switch(*((uint8_t *)data)) { // case ICMP6_NS: /*Tell the 3290 we are being solicited. */ // send_frame(REPORT_NS,...); // break; //fall through for beep // case ICMP6_RA: /*Tell the 3290 we have a router. */ // send_frame(REPORT_NA,...); // break; //fall through for beep case ICMP6_ECHO_REQUEST: /* We have received a ping request over the air. Tell the 3290 */ send_frame(REPORT_PING_BEEP, 0, 0); break; case ICMP6_ECHO_REPLY: /* We have received a ping reply over the air. Send frame back to 3290 */ send_frame(REPORT_PING, 1, &seqno); break; } else switch (ev) { case SERIAL_CMD: /* Check for command from serial port, execute it. */ /* Note cmd frame is written in an interrupt - delays here can cause overwriting by next command */ PRINTF("\nCommand %d length %d done %d",cmd.cmd,cmd.len,cmd.done); if (cmd.done){ /* Execute the waiting command */ switch (cmd.cmd){ case SEND_PING: /* Send ping request over the air */ seqno = cmd.frame[0]; raven_ping6(); break; case SEND_TEMP: #if AVR_WEBSERVER /* Set temperature string in web server */ web_set_temp((char *)cmd.frame); #endif break; case SEND_ADC2: #if AVR_WEBSERVER /* Set ext voltage string in web server */ web_set_voltage((char *)cmd.frame); #endif break; case SEND_SLEEP: /* Sleep radio and 1284p. */ if (cmd.frame[0]==0) { //Time to sleep in seconds /* Unconditional sleep. Don't wake until a serial interrupt. */ } else { /* Sleep specified number of seconds (3290p "DOZE" mode) */ /* It sleeps a bit longer so we will be always be awake for the next sleep command. */ #if UIP_CONF_TCP /* Only sleep this cycle if no active TCP/IP connections, for fast browser responsed */ activeconnections=0; for(i = 0; i < UIP_CONNS; ++i) { if((uip_conns[i].tcpstateflags & UIP_TS_MASK) != UIP_CLOSED) activeconnections++; } if (activeconnections) { PRINTF("\nWaiting for %d connections",activeconnections); break; } #endif } radio_state = NETSTACK_RADIO.off(); PRINTF ("\nsleep %d radio state %d...",cmd.frame[0],radio_state); /*Sleep for specified time*/ PRINTF("\nSleeping..."); micro_sleep(cmd.frame[0]); radio_state = NETSTACK_RADIO.on(); if (radio_state > 0) { PRINTF("Awake!"); } else { PRINTF("Radio wake error %d\n",radio_state); } break; case SEND_WAKE: /* 3290p requests return message showing awake status */ send_frame(REPORT_WAKE, 0, 0); break; default: break; } /* Reset command done flag. */ cmd.done = 0; } break; default: break; } return 0; }
int main( int argc, char* argv[] ) { ALCdevice *dev; FILE *fh; time_t shouldend; int blah = 0; struct stat sbuf; int speed; void *data; int size; char *fname; int i = 0; dev = alcOpenDevice( NULL ); if( dev == NULL ) { return 1; } /* Initialize ALUT. */ context_id = alcCreateContext( dev, NULL ); if(context_id == NULL) { alcCloseDevice( dev ); return 1; } alcMakeContextCurrent( context_id ); fixup_function_pointers(); init( ); if(argc == 1) { fname = MP3_FILE; } else { fname = argv[1]; } if(stat(fname, &sbuf) == -1) { perror(fname); return errno; } size = sbuf.st_size; data = malloc(size); if(data == NULL) { exit(1); } fh = fopen(fname, "rb"); if(fh == NULL) { fprintf(stderr, "Could not open %s\n", fname); free(data); exit(1); } fread(data, 1, size, fh); alutLoadMP3p = (mp3Loader *) alGetProcAddress((ALubyte *) MP3_FUNC); if(alutLoadMP3p == NULL) { free(data); fprintf(stderr, "Could not GetProc %s\n", (ALubyte *) MP3_FUNC); exit(-4); } for(i = 0; i < MAX_SOURCES; i++) { if(alutLoadMP3p(mp3buf[i], data, size) != AL_TRUE) { fprintf(stderr, "alutLoadMP3p failed\n"); exit(-2); } alSourcePlay(mp3source[i]); micro_sleep(80000); } free( data ); while(SourceIsPlaying(mp3source[0]) == AL_TRUE) { sleep(1); } cleanup(); alcCloseDevice( dev ); return 0; }
int main( int argc, char* argv[] ) { ALCdevice *dev; time_t shouldend; int attrlist[] = { ALC_FREQUENCY, DEFFREQ, ALC_INVALID }; char *musicitr = musicstr; ALfloat pitch = 1.0; int beats; char note; dev = alcOpenDevice( NULL ); if( dev == NULL ) { return 1; } cc = alcCreateContext( dev, attrlist); if(cc == NULL) { alcCloseDevice( dev ); return 1; } alcMakeContextCurrent( cc ); fixup_function_pointers(); if(argc == 1) { init(WAVEFILE); } else { init(argv[1]); } while(*musicitr) { alSourceStop( moving_source ); while(*musicitr == ' ') { musicitr++; } switch(*musicitr) { case 'c': pitch = 0.500010; break; case 'd': pitch = 0.561223; break; case 'e': pitch = 0.629967; break; case 'f': pitch = 0.667425; break; case 'g': pitch = 0.749164; break; case 'a': pitch = 0.840898; break; case 'b': pitch = 0.943870; break; case 'C': pitch = 1.0; break; case 'D': pitch = 1.122465; break; case 'E': pitch = 1.259933; break; case 'F': pitch = 1.339704; break; case 'G': pitch = 1.498309; break; case 'A': pitch = 1.681796; break; case 'B': pitch = 1.897754; break; default: fprintf(stderr, "unknown note %d\n", *musicitr); break; } note = *musicitr; musicitr++; /* skip note */ while(*musicitr == ' ') { musicitr++; } beats = (int) *musicitr - '0'; musicitr++; fprintf(stderr, "note %c beats %d\n", note, beats); alSourcef(moving_source, AL_PITCH, pitch); alSourcePlay( moving_source ); micro_sleep(beats / 4.0 * 1000000); } cleanup(); alcCloseDevice( dev ); return 0; }
uint COSTimer:: msleep(uint msecs) { return micro_sleep(msecs); }
int main( int argc, char* argv[] ) { ALCdevice *dev; int attrlist[] = { ALC_FREQUENCY, 22050, 0 }; time_t shouldend, start; ALint test = AL_FALSE; dev = alcOpenDevice( NULL ); if( dev == NULL ) { return 1; } /* Initialize ALUT. */ context_id = alcCreateContext( dev, attrlist); if(context_id == NULL) { alcCloseDevice( dev ); exit(1); } alcMakeContextCurrent( context_id ); fixup_function_pointers(); talBombOnError(); if(argc == 1) { init(WAVEFILE); } else { init(argv[1]); } fprintf( stderr, "Loop for 4 seconds\n"); alSourcePlay( moving_source ); shouldend = start = time( NULL ); while( shouldend - start <= 4 ) { shouldend = time(NULL); micro_sleep( 1000000 ); } alSourceStop( moving_source ); test = -1; alGetSourceiv( moving_source, AL_LOOPING, &test ); fprintf(stderr, "is looping? getsi says %s\n", (test == AL_TRUE)?"AL_TRUE":"AL_FALSE"); /* part the second */ fprintf( stderr, "Play once\n"); micro_sleep( 1000000 ); alSourcei( moving_source, AL_LOOPING, AL_FALSE ); alSourcePlay( moving_source ); do { micro_sleep( 1000000 ); } while( SourceIsPlaying( moving_source ) ); alcDestroyContext(context_id); alcCloseDevice( dev ); cleanup(); return 0; }
int main( int argc, char* argv[] ) { ALCdevice *dev; time_t start; time_t now; float sinsamp; int i; int blah = 0; int rsamps = 0; int nsamps = 0; unsigned int waitfor = 0; int attrlist[] = { ALC_FREQUENCY, 44100, ALC_SYNC, AL_TRUE, 0 }; int delay = 0; dev = alcOpenDevice( (const ALubyte *) "'((sampling-rate 44100))" ); if( dev == NULL ) { return 1; } /* Initialize ALUT. */ context_id = alcCreateContext( dev, NULL); if(context_id == NULL) { alcCloseDevice( dev ); return 1; } alcMakeContextCurrent( context_id ); fixup_function_pointers(); if( argc == 2 ) { init( argv[1] ); } else { init( RAWPCM ); } alSourcePlay( moving_source ); do { nsamps = fread(buf, 1, DATABUFSIZE, fh) / 2; rsamps = 0; while(rsamps < nsamps) { micro_sleep( delay ); waitfor = talBufferAppendWriteData(stereo, AL_FORMAT_STEREO16, &buf[rsamps], nsamps - rsamps, 44100, AL_FORMAT_STEREO16 ); rsamps += waitfor; if( waitfor == 0 ) { delay += 500; /* add 500 millisecs */ } else { /* decrease wait time */ delay -= 500; } } } while(feof(fh) == 0); fclose(fh); fprintf(stderr, "rsamps = %d\n", nsamps); /* loop for 20 seconds */ start = time(NULL); now = time(NULL); for( ; now <= start + 20; now = time(NULL)) { fprintf(stderr, "now - start = %ld\n", (long int) (now - start)); sleep(1); } alSourceStop(moving_source); cleanup(); alcCloseDevice( dev ); return 0; }