Пример #1
0
int	trap_GetSoundVolume(lua_State *s)
{
	int volume;
	CHANNEL c;
		
	trap_args(s, "GetSoundVolume", "i", &c);
	volume = sound_get_volume(c);
	lua_pushinteger(s, volume);
	return 1;
}
Пример #2
0
static void handle_control_message(struct lfd_control_message *msg, int s)
{
	int ret = 0;

	switch (msg->command) {
		case LFD_COMMAND_GET_VOLUME:
			msg->payload = sound_get_volume();
			msg->command |= LFD_RESPONSE;
			break;

		case LFD_COMMAND_SET_VOLUME:
			sound_set_volume(msg->payload);
			break;

		case LFD_COMMAND_GET_BACKLIGHT:
			msg->payload = backlight_get();
			msg->command |= LFD_RESPONSE;
			break;

		case LFD_COMMAND_SET_BACKLIGHT:
			backlight_set(msg->payload);
			break;

		case LFD_COMMAND_SET_BACKLIGHT_NEXT:
			backlight_next();
			break;

		case LFD_COMMAND_SET_RTC_TO_SYSTIME:
			time_set_rtc();
			break;

		case LFD_COMMAND_GET_BATTERY_MV:
			msg->payload = mv;
			msg->command |= LFD_RESPONSE;
			break;

		default:
			dbprintf("unknown LFD command: 0x%X\n", msg->command);
			return;
	};

	if (msg->command & LFD_RESPONSE) {
		ret = send(s, msg, sizeof(*msg), MSG_NOSIGNAL);
		if (ret < 0)
			dbprintf("can't send response\n");
	}
}
Пример #3
0
static int
sound_init_blip( Blip_Buffer **buf, Blip_Synth **synth )
{
  *buf = new_Blip_Buffer();
  blip_buffer_set_clock_rate( *buf, sound_get_effective_processor_speed() );
  /* Allow up to 1s of playback buffer - this allows us to cope with slowing
     down to 2% of speed where a single Speccy frame generates just under 1s
     of sound */
  if ( blip_buffer_set_sample_rate( *buf, settings_current.sound_freq, 1000 ) ) {
    sound_end();
    ui_error( UI_ERROR_ERROR, "out of memory at %s:%d", __FILE__, __LINE__ );
    return 0;
  }

  *synth = new_Blip_Synth();

  blip_synth_set_volume( *synth, sound_get_volume( settings_current.volume_beeper ) );
  blip_synth_set_output( *synth, *buf );

  blip_buffer_set_bass_freq( *buf, speaker_type[ option_enumerate_sound_speaker_type() ].bass );
  blip_synth_set_treble_eq( *synth, speaker_type[ option_enumerate_sound_speaker_type() ].treble );

  return 1;
}
Пример #4
0
void
sound_init( const char *device )
{
  float hz;
  double treble;
  Blip_Synth **ay_left_synth;
  Blip_Synth **ay_mid_synth;
  Blip_Synth **ay_mid_synth_r;
  Blip_Synth **ay_right_synth;

  /* Allow sound as long as emulation speed is greater than 2%
     (less than that and a single Speccy frame generates more
     than a seconds worth of sound which is bigger than the
     maximum Blip_Buffer of 1 second) */
  if( !( !sound_enabled && settings_current.sound &&
         settings_current.emulation_speed > 1 ) )
    return;

  /* only try for stereo if we need it */
  sound_stereo_ay = option_enumerate_sound_stereo_ay();

  if( settings_current.sound &&
      sound_lowlevel_init( device, &settings_current.sound_freq,
                           &sound_stereo_ay ) )
    return;

  if( !sound_init_blip(&left_buf, &left_beeper_synth) ) return;
  if( sound_stereo_ay != SOUND_STEREO_AY_NONE &&
      !sound_init_blip(&right_buf, &right_beeper_synth) )
    return;

  treble = speaker_type[ option_enumerate_sound_speaker_type() ].treble;

  ay_a_synth = new_Blip_Synth();
  blip_synth_set_volume( ay_a_synth, sound_get_volume( settings_current.volume_ay) );
  blip_synth_set_treble_eq( ay_a_synth, treble );

  ay_b_synth = new_Blip_Synth();
  blip_synth_set_volume( ay_b_synth, sound_get_volume( settings_current.volume_ay) );
  blip_synth_set_treble_eq( ay_b_synth, treble );

  ay_c_synth = new_Blip_Synth();
  blip_synth_set_volume( ay_c_synth, sound_get_volume( settings_current.volume_ay) );
  blip_synth_set_treble_eq( ay_c_synth, treble );

  left_specdrum_synth = new_Blip_Synth();
  blip_synth_set_volume( left_specdrum_synth, sound_get_volume( settings_current.volume_specdrum ) );
  blip_synth_set_output( left_specdrum_synth, left_buf );
  blip_synth_set_treble_eq( left_specdrum_synth, treble );
  
  /* important to override these settings if not using stereo
   * (it would probably be confusing to mess with the stereo
   * settings in settings_current though, which is why we make copies
   * rather than using the real ones).
   */

  ay_a_synth_r = NULL;
  ay_b_synth_r = NULL;
  ay_c_synth_r = NULL;

  if( sound_stereo_ay != SOUND_STEREO_AY_NONE ) {
    /* Attach the Blip_Synth's we've already created as appropriate, and
     * create one more Blip_Synth for the middle channel's right buffer. */
    if( sound_stereo_ay == SOUND_STEREO_AY_ACB ) {
      ay_left_synth = &ay_a_synth;
      ay_mid_synth = &ay_c_synth;
      ay_mid_synth_r = &ay_c_synth_r;
      ay_right_synth = &ay_b_synth;
    } else if ( sound_stereo_ay == SOUND_STEREO_AY_ABC ) {
      ay_left_synth = &ay_a_synth;
      ay_mid_synth = &ay_b_synth;
      ay_mid_synth_r = &ay_b_synth_r;
      ay_right_synth = &ay_c_synth;
    } else {
      ui_error( UI_ERROR_ERROR, "unknown AY stereo separation type: %d", sound_stereo_ay );
      fuse_abort();
    }

    blip_synth_set_output( *ay_left_synth, left_buf );
    blip_synth_set_output( *ay_mid_synth, left_buf );
    blip_synth_set_output( *ay_right_synth, right_buf );

    *ay_mid_synth_r = new_Blip_Synth();
    blip_synth_set_volume( *ay_mid_synth_r,
                           sound_get_volume( settings_current.volume_ay ) );
    blip_synth_set_output( *ay_mid_synth_r, right_buf );
    blip_synth_set_treble_eq( *ay_mid_synth_r, treble );

    right_specdrum_synth = new_Blip_Synth();
    blip_synth_set_volume( right_specdrum_synth, sound_get_volume( settings_current.volume_specdrum ) );
    blip_synth_set_output( right_specdrum_synth, right_buf );
    blip_synth_set_treble_eq( right_specdrum_synth, treble );
  } else {
    blip_synth_set_output( ay_a_synth, left_buf );
    blip_synth_set_output( ay_b_synth, left_buf );
    blip_synth_set_output( ay_c_synth, left_buf );
  }

  sound_enabled = sound_enabled_ever = 1;

  sound_channels = ( sound_stereo_ay != SOUND_STEREO_AY_NONE ? 2 : 1 );

  /* Adjust relative processor speed to deal with adjusting sound generation
     frequency against emulation speed (more flexible than adjusting generated
     sample rate) */
  hz = ( float )sound_get_effective_processor_speed() /
                machine_current->timings.tstates_per_frame;

  /* Size of audio data we will get from running a single Spectrum frame */
  sound_framesiz = ( float )settings_current.sound_freq / hz;
  sound_framesiz++;

  samples =
    (blip_sample_t *)libspectrum_calloc( sound_framesiz * sound_channels,
                                         sizeof(blip_sample_t) );
  /* initialize movie settings... */
  movie_init_sound( settings_current.sound_freq, sound_stereo_ay );

}
Пример #5
0
void
sound_init( const char *device )
{
  int ret;
  float hz;

  /* Allow sound as long as emulation speed is greater than 2%
     (less than that and a single Speccy frame generates more
     than a seconds worth of sound which is bigger than the
     maximum Blip_Buffer of 1 second) */
  if( !( !sound_enabled && settings_current.sound &&
         settings_current.emulation_speed > 1 ) )
    return;

  sound_stereo_ay = settings_current.stereo_ay;

  /* only try for stereo if we need it */
  if( sound_stereo_ay )
    sound_stereo = 1;

  ret =
    sound_lowlevel_init( device, &settings_current.sound_freq, &sound_stereo );

  if( ret )
    return;

  if( !sound_init_blip(&left_buf, &left_beeper_synth) ) return;
  if( sound_stereo && !sound_init_blip(&right_buf, &right_beeper_synth) ) return;

  ay_a_synth = new_Blip_Synth();
  blip_synth_set_volume( ay_a_synth, sound_get_volume( settings_current.volume_ay) );
  blip_synth_set_output( ay_a_synth, left_buf );
  blip_synth_set_treble_eq( ay_a_synth, speaker_type[ settings_current.speaker_type ].treble );

  ay_b_synth = new_Blip_Synth();
  blip_synth_set_volume( ay_b_synth, sound_get_volume( settings_current.volume_ay) );
  blip_synth_set_treble_eq( ay_b_synth, speaker_type[ settings_current.speaker_type ].treble );

  ay_c_synth = new_Blip_Synth();
  blip_synth_set_volume( ay_c_synth, sound_get_volume( settings_current.volume_ay) );
  blip_synth_set_output( ay_c_synth, left_buf );
  blip_synth_set_treble_eq( ay_c_synth, speaker_type[ settings_current.speaker_type ].treble );

  /* important to override these settings if not using stereo
   * (it would probably be confusing to mess with the stereo
   * settings in settings_current though, which is why we make copies
   * rather than using the real ones).
   */
  if( !sound_stereo ) {
    sound_stereo_ay = 0;
  }

  ay_a_synth_r = NULL;
  ay_b_synth_r = NULL;
  ay_c_synth_r = NULL;

  if( sound_stereo ) {
    ay_c_synth_r = new_Blip_Synth();
    blip_synth_set_volume( ay_c_synth_r, sound_get_volume( settings_current.volume_ay ) );
    blip_synth_set_output( ay_c_synth_r, right_buf );

    if( sound_stereo_ay ) {
      /* stereo with ACB stereo. */
      blip_synth_set_output( ay_b_synth, right_buf );
    } else {
      ay_a_synth_r = new_Blip_Synth();
      blip_synth_set_volume( ay_a_synth_r, sound_get_volume( settings_current.volume_ay ) );
      blip_synth_set_output( ay_a_synth_r, right_buf );
      blip_synth_set_treble_eq( ay_a_synth_r, speaker_type[ settings_current.speaker_type ].treble );

      blip_synth_set_output( ay_b_synth, left_buf );

      ay_b_synth_r = new_Blip_Synth();
      blip_synth_set_volume( ay_b_synth_r, sound_get_volume( settings_current.volume_ay ) );
      blip_synth_set_output( ay_b_synth_r, right_buf );
      blip_synth_set_treble_eq( ay_b_synth_r, speaker_type[ settings_current.speaker_type ].treble );
    }
  } else {
    blip_synth_set_output( ay_b_synth, left_buf );
  }

  sound_enabled = sound_enabled_ever = 1;

  sound_channels = ( sound_stereo ? 2 : 1 );

  /* Adjust relative processor speed to deal with adjusting sound generation
     frequency against emulation speed (more flexible than adjusting generated
     sample rate) */
  hz = ( float )sound_get_effective_processor_speed() /
                machine_current->timings.tstates_per_frame;

  /* Size of audio data we will get from running a single Spectrum frame */
  sound_framesiz = ( float )settings_current.sound_freq / hz;
  sound_framesiz++;

  samples = (blip_sample_t *)calloc( sound_framesiz * sound_channels,
                                     sizeof(blip_sample_t) );
}