예제 #1
0
void Ay_Emu::set_tempo_( double t )
{
    int p = spectrum_period;
    if ( clock_rate() != spectrum_clock )
        p = clock_rate() / 50;

    core.set_play_period( blip_time_t (p / t) );
}
예제 #2
0
blargg_err_t Sgc_Core::load_( Data_Reader& dr )
{
	RETURN_ERR( Sgc_Impl::load_( dr ) );
	
	if ( sega_mapping() && fm_apu_.supported() )
		RETURN_ERR( fm_apu_.init( clock_rate(), clock_rate() / 72 ) );
	
	set_tempo( 1.0 );
	return blargg_ok;
}
blargg_err_t Effects_Buffer::set_channel_count( int count, int const* types )
{
    RETURN_ERR( Multi_Buffer::set_channel_count( count, types ) );

    delete_bufs();

    mixer.samples_read = 0;

    RETURN_ERR( chans.resize( count + extra_chans ) );

    RETURN_ERR( new_bufs( min( bufs_max, count + extra_chans ) ) );

    for ( int i = bufs_size; --i >= 0; )
        RETURN_ERR( bufs [i].set_sample_rate( sample_rate(), length() ) );

    for ( int i = chans.size(); --i >= 0; )
    {
        chan_t& ch = chans [i];
        ch.cfg.vol      = 1.0f;
        ch.cfg.pan      = 0.0f;
        ch.cfg.surround = false;
        ch.cfg.echo     = false;
    }
    // side channels with echo
    chans [2].cfg.echo = true;
    chans [3].cfg.echo = true;

    clock_rate( clock_rate_ );
    bass_freq( bass_freq_ );
    apply_config();
    clear();

    return 0;
}
예제 #4
0
파일: Nsf_Impl.cpp 프로젝트: kode54/Cog
int nsf_header_t::play_period() const
{
	// NTSC
	int         clocks   = 29780;
	int         value    = 0x411A;
	byte const* rate_ptr = ntsc_speed;
	
	// PAL
	if ( pal_only() )
	{
		clocks   = 33247;
		value    = 0x4E20;
		rate_ptr = pal_speed;
	}
	
	// Default rate
	int rate = get_le16( rate_ptr );
	if ( rate == 0 )
		rate = value;
	
	// Custom rate
	if ( rate != value )
		clocks = (int) (rate * clock_rate() * (1.0/1000000.0));
	
	return clocks;
}
예제 #5
0
Blip_Buffer::blargg_err_t Blip_Buffer::set_sample_rate( long new_rate, int msec )
{
	if ( buffer_size_ == silent_buf_size )
	{
		assert( 0 );
		return "Internal (tried to resize Silent_Blip_Buffer)";
	}

	// start with maximum length that resampled time can represent
	long new_size = (ULONG_MAX >> BLIP_BUFFER_ACCURACY) - blip_buffer_extra_ - 64;
	if ( msec != blip_max_length )
	{
		long s = (new_rate * (msec + 1) + 999) / 1000;
		if ( s < new_size )
			new_size = s;
		else
			assert( 0 ); // fails if requested buffer length exceeds limit
	}

	if ( buffer_size_ != new_size )
	{
		void* p = realloc( buffer_, (new_size + blip_buffer_extra_) * sizeof *buffer_ );
		if ( !p )
			return "Out of memory";
		buffer_ = (buf_t_*) p;
	}

	buffer_size_ = new_size;
	assert( buffer_size_ != silent_buf_size ); // size should never happen to match this

	// update things based on the sample rate
	sample_rate_ = new_rate;
	length_ = new_size * 1000 / new_rate - 1;
	if ( msec )
		assert( length_ == msec ); // ensure length is same as that passed in

	// update these since they depend on sample rate
	if ( clock_rate_ )
		clock_rate( clock_rate_ );
	bass_freq( bass_freq_ );

	clear();

	return 0; // success
}
예제 #6
0
blargg_err_t Sgc_Impl::load_( Data_Reader& in )
{
	RETURN_ERR( rom.load( in, header_.size, &header_, 0 ) );
	
	if ( !header_.valid_tag() )
		return blargg_err_file_type;
	
	if ( header_.vers != 1 )
		set_warning( "Unknown file version" );
	
	if ( header_.system > 2 )
		set_warning( "Unknown system" );
	
	addr_t load_addr = get_le16( header_.load_addr );
	if ( load_addr < 0x400 )
		set_warning( "Invalid load address" );
	
	rom.set_addr( load_addr );
	play_period = clock_rate() / 60;
	
	if ( sega_mapping() )
	{
		RETURN_ERR( ram.resize( 0x2000 + Sgc_Cpu::page_padding ) );
		RETURN_ERR( ram2.resize( bank_size + Sgc_Cpu::page_padding ) );
	}
	else
	{
		RETURN_ERR( ram.resize( 0x400 + Sgc_Cpu::page_padding ) );
	}
	
	RETURN_ERR( vectors.resize( Sgc_Cpu::page_size + Sgc_Cpu::page_padding ) );
	
	// TODO: doesn't need to be larger than page size, if we do mapping calls right
	RETURN_ERR( unmapped_write.resize( bank_size ) );
	
	return blargg_ok;
}
예제 #7
0
Blip_Buffer::blargg_err_t Blip_Buffer::set_sample_rate( long new_rate, int msec )
{
	// start with maximum length that resampled time can represent
	long new_size = (ULONG_MAX >> BLIP_BUFFER_ACCURACY) - buffer_extra - 64;
	if ( msec != blip_max_length )
	{
		long s = (new_rate * (msec + 1) + 999) / 1000;
		if ( s < new_size )
			new_size = s;
		else
			assert( 0 ); // fails if requested buffer length exceeds limit
	}
	
	if ( buffer_size_ != new_size )
	{
		void* p = realloc( buffer_, (new_size + buffer_extra) * sizeof *buffer_ );
		if ( !p )
			return "Out of memory";
		buffer_ = (buf_t_*) p;
	}
	
	buffer_size_ = new_size;
	
	// update things based on the sample rate
	sample_rate_ = new_rate;
	length_ = int(new_size * 1000 / new_rate - 1);
	if ( msec )
		assert( length_ == msec ); // ensure length is same as that passed in
	if ( clock_rate_ )
		clock_rate( clock_rate_ );
	bass_freq( bass_freq_ );
	
	clear();
	
	return 0; // success
}
예제 #8
0
void Sgc_Core::set_tempo( double t )
{
	set_play_period( clock_rate() / (header().rate ? 50 : 60) / t );
}
예제 #9
0
파일: Ay_Emu.cpp 프로젝트: HipsterLion/SRB2
void Ay_Emu::set_tempo_( double t )
{
	play_period = blip_time_t (clock_rate() / 50 / t);
}