Пример #1
0
/**
 * @brief Loads an SPC file from the memory.
 * @param sound_data the memory area to read
 * @param sound_size size of the memory area in bytes
 */
void SpcDecoder::load(int16_t *sound_data, size_t sound_size) {

  // load the SPC data into the SPC library
  spc_load_spc(snes_spc_manager, (short int*) sound_data, sound_size);
  spc_clear_echo(snes_spc_manager);
  spc_filter_clear(snes_spc_filter);
}
Пример #2
0
int main( int argc, char** argv )
{
	/* Create emulator and filter */
	SNES_SPC* snes_spc = spc_new();
	SPC_Filter* filter = spc_filter_new();
	if ( !snes_spc || !filter ) error( "Out of memory" );
	
	/* Load SPC */
	{
		/* Load file into memory */
		long spc_size;
		void* spc = load_file( (argc > 1) ? argv [1] : "test.spc", &spc_size );
		
		/* Load SPC data into emulator */
		error( spc_load_spc( snes_spc, spc, spc_size ) );
		free( spc ); /* emulator makes copy of data */
		
		/* Most SPC files have garbage data in the echo buffer, so clear that */
		spc_clear_echo( snes_spc );
		
		/* Clear filter before playing */
		spc_filter_clear( filter );
	}
	
	/* Record 20 seconds to wave file */
	wave_open( spc_sample_rate, "out.wav" );
	wave_enable_stereo();
	while ( wave_sample_count() < 60 * spc_sample_rate * 2 )
	{
		/* Play into buffer */
		#define BUF_SIZE 2048
		short buf [BUF_SIZE];
		error( spc_play( snes_spc, BUF_SIZE, buf ) );
		
		/* Filter samples */
		spc_filter_run( filter, buf, BUF_SIZE );
		
		wave_write( buf, BUF_SIZE );
	}
	
	/* Cleanup */
	spc_filter_delete( filter );
	spc_delete( snes_spc );
	wave_close();
	
	return 0;
}
Пример #3
0
void make_save_state( const char* path )
{
	/* Load SPC */
	long spc_size;
	void* spc = load_file( path, &spc_size );
	error( spc_load_spc( snes_spc, spc, spc_size ) );
	free( spc );
	spc_clear_echo( snes_spc );
	
	/* Skip several seconds */
	error( spc_play( snes_spc, 5 * spc_sample_rate * 2, 0 ) );
	
	/* Save state to file */
	{
		static unsigned char state [spc_state_size]; /* buffer large enough for data */
		unsigned char* out = state;
		spc_copy_state( snes_spc, &out, state_save );
		write_file( "state.bin", state, out - state );
	}
	
	record_wav( "first.wav", 5 );
}