コード例 #1
0
ファイル: sound.c プロジェクト: skyfex/happygem
void sound_process()
{
   if (snd.current_pattern) {
      if (snd.delay_i) {
         snd.delay_i--;
         if (!snd.delay_i)
            sound_update();
      }
      else {
         snd.dur_i++;
         if (snd.dur_i == snd.current_pattern->sounds[snd.sound_i].dur) {
            snd.dur_i = 0;
            snd.sound_i++;
            if (snd.current_pattern->delay)
               snd.delay_i = snd.current_pattern->delay;
            if (snd.sound_i == snd.current_pattern->count) {
               snd.sound_i = 0;
               snd.repeat_i++;
               if (snd.repeat_i == snd.current_pattern->repeat) {
                  sound_stop();
                  return;
               }
            }
            sound_update();  
         }
      }
   }  
}
コード例 #2
0
ファイル: mame.cpp プロジェクト: AlanApter/steamlink-sdk
int updatescreen(void)
{
	/* update sound */
	sound_update();

	if (osd_skip_this_frame() == 0)
	{
		profiler_mark(PROFILER_VIDEO);
		if (need_to_clear_bitmap)
		{
			osd_clearbitmap(real_scrbitmap);
			need_to_clear_bitmap = 0;
		}
		draw_screen(bitmap_dirty);	/* update screen */
		bitmap_dirty = 0;
		profiler_mark(PROFILER_END);
	}

	/* the user interface must be called between vh_update() and osd_update_video_and_audio(), */
	/* to allow it to overlay things on the game display. We must call it even */
	/* if the frame is skipped, to keep a consistent timing. */
	if (handle_user_interface(real_scrbitmap))
		/* quit if the user asked to */
		return 1;

	update_video_and_audio();

	if (drv->vh_eof_callback) (*drv->vh_eof_callback)();

	return 0;
}
コード例 #3
0
int audio_update (void)
{
  int32 i, l, r;
  int32 ll = llp;
  int32 rr = rrp;

  int psg_preamp  = config.psg_preamp;
  int fm_preamp   = config.fm_preamp;
  int filter      = config.filter;
  uint32 factora  = (config.lp_range << 16) / 100;
  uint32 factorb  = 0x10000 - factora;

  int32 *fm       = snd.fm.buffer;
  int16 *psg      = snd.psg.buffer;

#ifdef NGC
  int16 *sb = (int16 *) soundbuffer[mixbuffer];
#endif

  /* get number of available samples */
  int size = sound_update(mcycles_vdp);

  /* return an aligned number of samples */
  size &= ~7;

  if (config.hq_fm)
  {
    /* resample into FM output buffer */
    Fir_Resampler_read(fm, size);

#ifdef LOGSOUND
    error("%d FM samples remaining\n",Fir_Resampler_written() >> 1);
#endif
  }
コード例 #4
0
ファイル: naev.c プロジェクト: ekrumme/naev
/**
 * @brief Split main loop from main() for secondary loop hack in toolkit.c.
 */
void main_loop (void)
{
   int tk;

   /* Check to see if toolkit is open. */
   tk = toolkit_isOpen();

   /* Clear buffer. */
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

   fps_control(); /* everyone loves fps control */

   sound_update( real_dt ); /* Update sounds. */
   if (tk) toolkit_update(); /* to simulate key repetition */
   if (!menu_isOpen(MENU_MAIN)) {
      if (!paused)
         update_all(); /* update game */
      render_all();
   }
   /* Toolkit is rendered on top. */
   if (tk) toolkit_render();

   gl_checkErr(); /* check error every loop */

   /* Draw buffer. */
   SDL_GL_SwapBuffers();
}
コード例 #5
0
static void
sound_cb(struct ev_loop *loop, ev_timer *w, int revents)
{
  (void) loop;
  (void) revents;
  SoundInfo *info = (SoundInfo *) w->data;
  sound_update(info);
}
コード例 #6
0
ファイル: nulis2.c プロジェクト: JINXSHADYLANE/quibble
bool dgreed_update(void) {
    if(char_up('q'))
        malka_states_pop();

    mfx_update();
    sound_update();

    return true;
}
コード例 #7
0
ファイル: system_sound.c プロジェクト: Cpasjuste/neopop-sdl
void
system_sound_update(int nframes)
{
    int i;
    int consumed;

    /* SDL_LockAudio(); */

    /* number of unread frames  */
    i = FRAME_DIFF(sound_frame_write, sound_frame_read);
    /* number of frames read since last call */
    consumed = FRAME_DIFF(sound_frame_read, sound_frame_read_old);
    sound_frame_read_old = sound_frame_read;

    /* SDL_UnlockAudio(); */

    for (; i<nframes; i++) {
	if (mute || paused)
	    memset(sound_buffer+sound_frame_write, silence_value, bpf);
	else {
	    dac_update(dac_data, dac_bpf);
	    /* convert to standard format */
	    acvt.buf = dac_data;
	    acvt.len = dac_bpf;
	    if (SDL_ConvertAudio(&acvt) == -1) {
		fprintf(stderr,
			"DAC data conversion failed: %s\n", SDL_GetError());
		return;
	    }
	    
	    /* get sound data */
	    sound_update((_u16 *)(sound_buffer+sound_frame_write), bpf);
	    
	    /* mix both streams into one */
	    SDL_MixAudio(sound_buffer+sound_frame_write,
			 dac_data, bpf, SDL_MIX_MAXVOLUME);
	}
	
	sound_frame_write = FRAME_INC(sound_frame_write);
	if (sound_frame_write == sound_frame_read) {
	    fprintf(stderr, "your machine is much too slow.\n");
	    /* XXX: handle this */
	    exit(1);
	}

	SDL_SemPost(rsem);
    }

    if (nframes > 1) {
	for (i=0; i<consumed; i++)
	    SDL_SemWait(wsem);
    }
    else
	SDL_SemWait(wsem);
}
コード例 #8
0
ファイル: keymingler.c プロジェクト: JINXSHADYLANE/quibble
int dgreed_main(int argc, const char** argv) {
	params_init(argc, argv);
	rand_init(time(NULL));
	layouts_init();
	layouts_set("dvorak");

	bool fullscreen = true;
	if(params_find("-windowed") != ~0)
		fullscreen = false;

	video_init_ex(SCREEN_WIDTH, SCREEN_HEIGHT, 
		SCREEN_WIDTH, SCREEN_HEIGHT, "KeyMingler", fullscreen);
	font = font_load(FONT_FILE);	
	float text_width = font_width(font, LOADING_TEXT);
	float text_height = font_height(font);
	Vector2 pos = vec2((SCREEN_WIDTH - text_width) / 2.0f,
		(SCREEN_HEIGHT - text_height) / 2.0f);
	font_draw(font, LOADING_TEXT, 0, &pos, COLOR_WHITE);	
	video_present();
	system_update();

	game_init();
	sounds_init();
	music = sound_load_stream(MUSIC_FILE);
	sound_play(music);

	while(system_update()) {
		game_update();
		game_render();
		video_present();
		sound_update();

		if(key_up(KEY_QUIT))
			break;
	}
	
	font_free(font);
	sound_free(music);
	sounds_close();
	game_close();
	video_close();
	layouts_close();

	return 0;
}
コード例 #9
0
ファイル: sound.c プロジェクト: skyfex/happygem
void sound_play(sound_pattern_t *pattern)
{
   sound_stop();
   snd.current_pattern = pattern;
   sound_update();
}
コード例 #10
0
ファイル: system.c プロジェクト: maestun/smsplus-itv
/* Run the virtual console emulation for one frame */
void system_frame(int skip_render)
{
    static int iline_table[] = {0xC0, 0xE0, 0xF0};
    int lpf = (sms.display == DISPLAY_NTSC) ? 262 : 313;
    int iline;

    /* Debounce pause key */
    if(input.system & INPUT_PAUSE)
    {
        if(!sms.paused)
        {
            sms.paused = 1;

            z80_set_irq_line(IRQ_LINE_NMI, ASSERT_LINE);
            z80_set_irq_line(IRQ_LINE_NMI, CLEAR_LINE);
        }
    }
    else
    {
         sms.paused = 0;
    }

    text_counter = 0;

    /* End of frame, parse sprites for line 0 on line 261 (VCount=$FF) */
    if(vdp.mode <= 7)
        parse_line(0);

    for(vdp.line = 0; vdp.line < lpf;)
    {
        z80_execute(227);

        iline = iline_table[vdp.extended];

        if(!skip_render)
        {
            render_line(vdp.line);
        }

        if(vdp.line <= iline)
        {
            vdp.left -= 1;
            if(vdp.left == -1)
            {
                vdp.left = vdp.reg[0x0A];
                vdp.hint_pending = 1;

                z80_execute(16);

                if(vdp.reg[0x00] & 0x10)
                {
                    z80_set_irq_line(0, ASSERT_LINE);
                }
            }
        }
        else
        {
            vdp.left = vdp.reg[0x0A];
        }

        if(vdp.line == iline)
        {
            vdp.status |= 0x80;
            vdp.vint_pending = 1;

            z80_execute(16);

            if(vdp.reg[0x01] & 0x20)
            {
                z80_set_irq_line(0, ASSERT_LINE);
            }
        }

        sound_update(vdp.line);

        ++vdp.line;

        if(vdp.mode <= 7)
            parse_line(vdp.line);
    }
}
コード例 #11
0
ファイル: game.c プロジェクト: mefistotelis/swars
static void
game_update_full (bool wait)
{
  const int max_fps = 16;
  const int32_t frame_duration = 1000 / max_fps;

  static int32_t last_frame_ticks;
  int32_t start_ticks;

  display_unlock ();

  sound_update ();
  display_update ();
  game_handle_sdl_events ();

  start_ticks = SDL_GetTicks ();

  if (wait && last_frame_ticks != 0)
    {
      int32_t last_frame_duration;

      last_frame_duration = (int32_t) (start_ticks - last_frame_ticks + 2);

      if (last_frame_duration < frame_duration)
	{
	  int32_t total_sleep_time = frame_duration - last_frame_duration;
	  const int32_t min_sleep_time = 1000 / 40;
	  const int32_t max_sleep_time = 1000 / 20;

	  total_sleep_time = frame_duration - last_frame_duration;

	  if (total_sleep_time > 0)
	    {
	      float f = (float) total_sleep_time
			* (min_sleep_time + max_sleep_time)
			/ (2 * min_sleep_time * max_sleep_time);
	      int32_t base_sleep_time = (int32_t) (total_sleep_time / f + .5f);

	      while (total_sleep_time > 0)
		{
		  int32_t sleep_time = MIN (base_sleep_time, total_sleep_time);
		  int32_t ticks = SDL_GetTicks ();

		  SDL_Delay (sleep_time);

		  display_lock ();
		  game_handle_sdl_events ();
		  sound_update ();
		  display_unlock ();

		  display_update_mouse_pointer ();

		  total_sleep_time -= SDL_GetTicks () - ticks;
		}
	    }
	}
    }

  last_frame_ticks = SDL_GetTicks ();

  display_lock ();
}
コード例 #12
0
ファイル: snddrv-SDL.c プロジェクト: toyoshim/quasi88nc
void	xmame_sound_update( void )
{
  if( sound_enabled )
    sound_update();
}
コード例 #13
0
ファイル: system.c プロジェクト: arakerlu/Genesis-Plus-GX
int audio_update(int16 *buffer)
{
  /* run sound chips until end of frame */
  int size = sound_update(mcycles_vdp);

  /* Mega CD specific */
  if (system_hw == SYSTEM_MCD)
  {
    /* sync PCM chip with other sound chips */
    pcm_update(size);

    /* read CDDA samples */
    cdd_read_audio(size);

#ifdef ALIGN_SND
    /* return an aligned number of samples if required */
    size &= ALIGN_SND;
#endif

    /* resample & mix FM/PSG, PCM & CD-DA streams to output buffer */
    blip_mix_samples(snd.blips[0], snd.blips[1], snd.blips[2], buffer, size);
  }
  else
  {
#ifdef ALIGN_SND
    /* return an aligned number of samples if required */
    size &= ALIGN_SND;
#endif

    /* resample FM/PSG mixed stream to output buffer */
    blip_read_samples(snd.blips[0], buffer, size);
  }

  /* Audio filtering */
  if (config.filter)
  {
    int samples = size;
    int16 *out = buffer;
    int32 l, r;

    if (config.filter & 1)
    {
      /* single-pole low-pass filter (6 dB/octave) */
      uint32 factora  = config.lp_range;
      uint32 factorb  = 0x10000 - factora;

      /* restore previous sample */
      l = llp;
      r = rrp;

      do
      {
        /* apply low-pass filter */
        l = l*factora + out[0]*factorb;
        r = r*factora + out[1]*factorb;

        /* 16.16 fixed point */
        l >>= 16;
        r >>= 16;

        /* update sound buffer */
        *out++ = l;
        *out++ = r;
      }
      while (--samples);

      /* save last samples for next frame */
      llp = l;
      rrp = r;
    }