void RNDEND_load_assets(void)
{
   rndend_win_gfx   = COMMON_load_texture(WIN_GFX_PATH);
   rndend_loss_gfx  = COMMON_load_texture(LOSS_GFX_PATH);

    if (exists(WIN_CHIME_PATH))
        rndend_win_chime = load_sample(WIN_CHIME_PATH);
    else
    {
        rndend_win_chime = create_sample(8, 0, 1, 1);
        OH_SMEG("missing sound: %s", WIN_CHIME_PATH);
    }

    if (exists(LOSS_CHIME_PATH))
        rndend_loss_chime = load_sample(LOSS_CHIME_PATH);
    else
    {
        rndend_loss_chime = create_sample(8, 0, 1, 1);
        OH_SMEG("missing sound: %s", LOSS_CHIME_PATH);
    }

   RNDEND_reset();

   rndend_uv_tmp[0].u = 0.0f;
   rndend_uv_tmp[0].v = 0.0f;

   rndend_uv_tmp[1].u = 1.0f;
   rndend_uv_tmp[1].v = 0.0f;

   rndend_uv_tmp[2].u = 1.0f;
   rndend_uv_tmp[2].v = 1.0f;

   rndend_uv_tmp[3].u = 0.0f;
   rndend_uv_tmp[3].v = 1.0f;
}
PlayerComponent::PlayerComponent() : Component( "PlayerComponent" )
{
  angelCounter = 200;
  xVel = yVel = 0.0;
  gravity = 0.2;
  speed = 2.5;
  angel = false;
  state = "idle";

  startX = 1717.5;
  startY = 732.5;

  windVol = 64.0;
  windPan = 128.0;
  windFreq = 300.0;

  transformCounter = 0;
  flapCounter = 0;
  deathCounter = -1;

  wind2 = load_sample( "data/sfx/wind.wav" );
  wind = load_sample( "data/sfx/wind.wav" );
  die = load_sample( "data/sfx/wind.wav" );
  play_sample( wind, windVol, windPan, windFreq, 1 );
  play_sample( wind2, windVol/1.5, 200, windFreq/2.13, 1 );
}
Ejemplo n.º 3
0
class sound* sound_list::load(char* sound_name)
{
	class sound *curr;
	char tmp3[1024];
	
	curr=start;
	while (curr->next!=NULL)
	{
		curr=curr->next;
		if (strcmp(curr->name,sound_name)==0)
		{
			return curr;
		};
	};
	
	end->next=new sound;
	curr=end->next;
	curr->prev=end;
	curr->next=NULL;
	end=curr;
	
	strcpy(end->name,sound_name);
  strcpy(tmp3,game->mod);
	strcat(tmp3,"/sounds/");
	strcat(tmp3,sound_name);
	end->snd=load_sample(tmp3);
  if (end->snd==NULL)
  {
    strcpy(tmp3,"default/sounds/");
    strcat(tmp3,sound_name);
    end->snd=load_sample(tmp3);
  };
	return end;
};
Ejemplo n.º 4
0
/* ----------------------------------------------------------------------------
 * Loads data about the leader type from a data file.
 */
void leader_type::load_from_file(
    data_node* file, const bool load_resources,
    vector<pair<size_t, string> >* anim_conversions
) {
    pluck_delay =
        s2f(file->get_child_by_name("pluck_delay")->value);
    whistle_range =
        s2f(
            file->get_child_by_name("whistle_range")->get_value_or_default(
                f2s(DEF_WHISTLE_RANGE)
            )
        );
    punch_strength =
        s2i(file->get_child_by_name("punch_strength")->value); //TODO default.
    throw_height_mult =
        s2f(
            file->get_child_by_name("throw_height_mult")->get_value_or_default(
                "1"
            )
        );
        
    if(load_resources) {
        //TODO don't use load_sample for these.
        sfx_dismiss =
            load_sample(file->get_child_by_name("dismiss_sfx")->value, mixer);
        sfx_name_call =
            load_sample(file->get_child_by_name("name_call_sfx")->value, mixer);
        sfx_whistle =
            load_sample(file->get_child_by_name("whistle_sfx")->value, mixer);
        bmp_icon =
            bitmaps.get(file->get_child_by_name("icon")->value, file);
    }
    
#define new_conversion(id, name) \
    anim_conversions->push_back(make_pair((id), (name)))
    
    new_conversion(LEADER_ANIM_IDLING,         "idling");
    new_conversion(LEADER_ANIM_WALKING,         "walking");
    new_conversion(LEADER_ANIM_PLUCKING,        "plucking");
    new_conversion(LEADER_ANIM_GETTING_UP,       "getting_up");
    new_conversion(LEADER_ANIM_DISMISSING,      "dismissing");
    new_conversion(LEADER_ANIM_THROWING,        "throwing");
    new_conversion(LEADER_ANIM_WHISTLING,    "whistling");
    new_conversion(LEADER_ANIM_LYING,          "lying");
    new_conversion(LEADER_ANIM_PAIN,         "pain");
    new_conversion(LEADER_ANIM_KNOCKED_DOWN, "knocked_down");
    new_conversion(LEADER_ANIM_SPRAYING,     "spraying");
    
#undef new_conversion
    
}
Ejemplo n.º 5
0
int main (int argc, char *argv[])
{
     DirectResult        ret;
     IFusionSound       *sound;
     IFusionSoundBuffer *buffer;

     ret = FusionSoundInit (&argc, &argv);
     if (ret)
          FusionSoundErrorFatal ("FusionSoundInit", ret);

     if (argc != 2) {
          fprintf (stderr, "\nUsage: %s <filename>\n", argv[0]);
          return -1;
     }

     ret = FusionSoundCreate (&sound);
     if (ret)
          FusionSoundErrorFatal ("FusionSoundCreate", ret);

     buffer = load_sample (sound, argv[1]);
     if (buffer) {
          do_playback_tests (buffer);

          buffer->Release (buffer);
     }

     sound->Release (sound);

     return 0;
}
Ejemplo n.º 6
0
static void *create_plugin_data(const SoundPluginType *plugin_type, struct SoundPlugin *plugin, hash_t *state, float samplerate, int block_size){

  //const char *filename="/home/kjetil/brenn/downloaded/temp/CATEGORY/SYNTH/PAD/NAMED1/etrnpadl.xi"; // one sample
  //const char *filename="/home/kjetil/brenn/downloaded/temp/CATEGORY/SYNTH/PAD/NAMED1/elecpad.xi"; // multile samples
  //const char *filename="/home/kjetil/brenn/downloaded/temp/CATEGORY/SYNTH/PAD/NAMED1/flpad2.xi"; // multile samples
  //const char *filename="/home/kjetil/brenn/downloaded/temp/CATEGORY/SYNTH/PAD/NAMED1/BIGPAD1.XI"; // multile samples
  //const char *filename="/home/kjetil/brenn/downloaded/temp/waveworld/wav/synths/temp/prophe07.wav";
  //const char *filename="/gammelhd/home/kjetil/poing-imperatif/karin.wav";
  //const char *filename="/home/kjetil/brenn/downloaded/temp/CATEGORY/BASS/ACOUSTIC/acbs02r.xi";
  //const char *filename="/home/kjetil/brenn/downloaded/temp/CATEGORY/SYNTH/SEQUENCE/SH101/sh101sq1.xi";
  //const char *filename="/home/kjetil/brenn/downloaded/temp/CATEGORY/BELL/CHURCH/CHRBEL01.XI";
  //const char *filename="/gammelhd/gammelhd/gammel_lyd/2_channel_short.wav";
  //const char *filename="/gammelhd/gammelhd/gammelhd/gammel_lyd/d_lydfiler/instrument/keyboard/mellotron.sf2";
  wchar_t *default_sound_filename = STRING_append(OS_get_program_path2(),
                                    STRING_append(STRING_create(OS_get_directory_separator()),
                                    STRING_append(STRING_create("sounds"),
                                    STRING_append(STRING_create(OS_get_directory_separator()),
                                                  !strcmp(plugin_type->name, "Click")
                                                  ? STRING_create("243749__unfa__metronome-1khz-weak-pulse.flac")
                                                  : STRING_create("016.WAV")))));
    
  Data *data = create_data(samplerate,NULL,default_sound_filename,0,RESAMPLER_CUBIC); // cubic is the default

  if(load_sample(data,default_sound_filename,0)==false){
    free(data);
    return NULL;
  }

  return data;
}
Ejemplo n.º 7
0
void playerLose()
{

     
    SAMPLE *death = load_sample("Death.wav");
     
 
     BITMAP *loseBackground = NULL;
     loseBackground = load_bitmap("Spider Victor 3D.bmp", NULL); 
     BITMAP *explosion = NULL;
     explosion = load_bitmap("Explosion.bmp", NULL);
     BITMAP *spider = NULL;
     spider = load_bitmap("Spider1.bmp", NULL); 
     
     
  
     playerIsDead = 1;
     clear_bitmap(buffer);
     draw_sprite(buffer, loseBackground, 0, 0);     
     draw_sprite(buffer, explosion, turretX - 20, turretY - 20);
     draw_sprite(buffer, spider, spiderX[j], spiderY[j]);
     currentImage = 2;
     play_sample(death, 255, 0, 500, 0);
     return;
     
     


     
}
//Load Sound .wav to memory
int AddVoice(const char *filename, int sfx)
{
    SAMPLE *samp;
    int v;
    samp=load_sample(filename);
    if(!samp)
        return 0;
    if((v=allocate_voice(samp))==-1)
    {
        destroy_sample(samp);
        return 0;
    }
    if(sfx)
    {
        voice_len_sfx++;
        VoicesSfx=(int*)realloc(VoicesSfx,voice_len_sfx*sizeof(int));
        VoicesSfx[voice_len_sfx-1]=v;
        voice_set_volume(v,Effect_volume);
    }
    else
    {
        voice_len_music++;
        VoicesMusic=(int*)realloc(VoicesMusic,voice_len_music*sizeof(int));
        VoicesMusic[voice_len_music-1]=v;
        voice_set_volume(v,Music_volume);
    }

    return v;
}
SoundProxy::SoundProxy(const char* sndFile)
{
	volume = 255;
	pan = 128;
	speed = 1000;
	snd = load_sample(sndFile);
}
Ejemplo n.º 10
0
static void get_smpl(struct module_data *m, int size, FILE *f, void *parm)
{
	struct xmp_module *mod = &m->mod;
	int i, flags;

	D_(D_INFO "Stored samples: %d", mod->smp);

	for (i = 0; i < mod->smp; i++) {
		flags = read32b(f);
		mod->xxs[i].len = read32b(f);

		if (flags & 0x02) {
			mod->xxs[i].flg |= XMP_SAMPLE_16BIT;
		}

		if (flags & 0x04) {	/* Skip 32-bit samples */
			mod->xxs[i].len <<= 2;
			fseek(f, mod->xxs[i].len, SEEK_CUR);
			continue;
		}
		
		load_sample(f, SAMPLE_FLAG_BIGEND, &mod->xxs[i], NULL);

		if (mod->xxs[i].len == 0)
			continue;

		D_(D_INFO "[%2X] %08x %05x%c%05x %05x %c",
			i, flags, mod->xxs[i].len,
			mod->xxs[i].flg & XMP_SAMPLE_16BIT ? '+' : ' ',
			mod->xxs[i].lps, mod->xxs[i].lpe,
			mod->xxs[i].flg & XMP_SAMPLE_LOOP ?
			(mod->xxs[i].flg & XMP_SAMPLE_LOOP_BIDIR ? 'B' : 'L') : ' ');

	}
}
Ejemplo n.º 11
0
void abertura(){

	SAMPLE *som;
   	som = load_sample("Abertura1.wav");
   	play_sample(som, 255, 128, 1000, FALSE);
   	
}
Ejemplo n.º 12
0
void expl(){

	SAMPLE *som;
   	som = load_sample("boom.wav");
   	play_sample(som, 255, 128, 1000, FALSE);

}
Ejemplo n.º 13
0
void loser(){

	SAMPLE *som;
   	som = load_sample("loser.wav");
   	play_sample(som, 255, 128, 1000, FALSE);

}
Ejemplo n.º 14
0
void escnave(){

	SAMPLE *som;
   	som = load_sample("affair.wav");
   	play_sample(som, 255, 128, 1000, FALSE);

}
Ejemplo n.º 15
0
int mmd_load_hybrid_instrument(HIO_HANDLE *f, struct module_data *m, int i,
			int smp_idx, struct SynthInstr *synth,
			struct InstrExt *exp_smp, struct MMD0sample *sample)
{
	struct xmp_module *mod = &m->mod;
	struct xmp_instrument *xxi = &mod->xxi[i];
	struct xmp_subinstrument *sub;
	struct xmp_sample *xxs;
	int length, type;
	int pos = hio_tell(f);

	synth->defaultdecay = hio_read8(f);
	hio_seek(f, 3, SEEK_CUR);
	synth->rep = hio_read16b(f);
	synth->replen = hio_read16b(f);
	synth->voltbllen = hio_read16b(f);
	synth->wftbllen = hio_read16b(f);
	synth->volspeed = hio_read8(f);
	synth->wfspeed = hio_read8(f);
	synth->wforms = hio_read16b(f);
	hio_read(synth->voltbl, 1, 128, f);;
	hio_read(synth->wftbl, 1, 128, f);;

	hio_seek(f, pos - 6 + hio_read32b(f), SEEK_SET);
	length = hio_read32b(f);
	type = hio_read16b(f);

	if (med_new_instrument_extras(xxi) != 0)
		return -1;

	xxi->nsm = 1;
	if (subinstrument_alloc(mod, i, 1) < 0)
		return -1;

	MED_INSTRUMENT_EXTRAS((*xxi))->vts = synth->volspeed;
	MED_INSTRUMENT_EXTRAS((*xxi))->wts = synth->wfspeed;

	sub = &xxi->sub[0];

	sub->pan = 0x80;
	sub->vol = sample->svol;
	sub->xpo = sample->strans;
	sub->sid = smp_idx;
	sub->fin = exp_smp->finetune;

	xxs = &mod->xxs[smp_idx];

	xxs->len = length;
	xxs->lps = 2 * sample->rep;
	xxs->lpe = xxs->lps + 2 * sample->replen;
	xxs->flg = sample->replen > 1 ?  XMP_SAMPLE_LOOP : 0;

	if (load_sample(m, f, 0, xxs, NULL) < 0)
		return -1;

	return 0;
}
Ejemplo n.º 16
0
void carregaSom_Abertura (SAMPLE **s, char arq[])
{
	*s = load_sample (arq);
	if (*s == NULL)
	{
		printf ("file not found: %s", arq);
		exit(1);
	}
}
Ejemplo n.º 17
0
void chargerContenuMenu(t_graphmenu* pgm)
{
    int i;
    char filename[100];
    FILE *boutons_xy;
    boutons_xy = fopen("files/menu/boutons_xy.txt", "r");
    pgm->music = load_sample("files/menu/music.wav");
    pgm->flap = load_sample("files/menu/flap.wav");
    if (boutons_xy==NULL)
    {
        allegro_message("Erreur chargement du fichier \"boutons_xy.txt\"");
        allegro_exit();
        exit(EXIT_FAILURE);
    }
    rewind(boutons_xy);
    for(i=0; i<NIMGMENU/2; i++)
    {
        fscanf(boutons_xy, "%d", &pgm->boutons_x[i]);
        fscanf(boutons_xy, "%d", &pgm->boutons_y[i]);
    }
    pgm->img_menu = chargerImage("files/menu/menu.bmp");
    pgm->cursor = chargerImage("files/menu/cursor.bmp");
    for (i=0; i<NIMGMENU; i++)
    {
        sprintf(filename, "files/menu/bouton%d.bmp", i);
        pgm->img_boutons[i] = chargerImage(filename);
    }
    for (i=0; i<NIMGSON; i++)
    {
        sprintf(filename, "files/menu/son%d.bmp", i);
        pgm->img_son[i] = chargerImage(filename);
    }
    for (i=0; i<6; i++)
    {
        sprintf(filename, "files/menu/bird%d.bmp", i);
        pgm->img_perso[i] = chargerImage(filename);
    }

    for (i=0; i<4; i++)
    {
        pgm->img_perso[i+6] = pgm->img_perso[4-i];
    }
}
Ejemplo n.º 18
0
int main( void )
{
    int depth;   /* represents color depth */

    /* first, set up Allegro and the graphics mode */
    allegro_init(); /* initialize Allegro */
    install_keyboard(); /* install the keyboard for Allegro to use */
    install_sound( DIGI_AUTODETECT, MIDI_AUTODETECT, NULL );

    depth = desktop_color_depth();  /* find out what color depth is on our computer */
    if (depth == 0)
        depth = 32;
    set_color_depth( depth ); /* set the color depth to depth used by our computer */

    set_gfx_mode( GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0 ); /* set graphics mode */
    ball = load_bitmap( "ball.bmp", NULL ); /* load the ball bitmap */
    bar = load_bitmap( "bar.bmp", NULL); /* load the bar bitmap */
    buffer = create_bitmap(SCREEN_W, SCREEN_H);/* create buffer */
    boing = load_sample( "boing.wav" ); /* load the sound file */
    pongFont = load_font( "pongfont.pcx", NULL, NULL ); /* load the font */
    ball_x = SCREEN_W / 2; /* give the ball its initial x-coordinate */
    ball_y = SCREEN_H / 2; /* give the ball its initial y-coordinate */
    barL_y = SCREEN_H / 2; /* give left paddle its initial y-coordinate */
    barR_y = SCREEN_H / 2; /* give right paddle its initial y-coordinate */
    scoreL = 0; /* set left player’s score to 0 */
    scoreR = 0; /* set right player’s score to 0 */
    srand( time( NULL ) ); /* seed the random function ... */
    direction = rand() % 4; /* and then make a random initial direction */

    while ( !key[KEY_ESC] )/* until the escape key is pressed ... */
    {
        moveBall(); /* move the ball */
        respondToKeyboard(); /* respond to keyboard input */
        /* now, perform double buffering */
        clear_to_color( buffer, makecol( 255, 255, 255 ) );
        blit( ball, buffer, 0, 0, ball_x, ball_y, ball->w, ball->h );
        blit( bar, buffer, 0, 0, 0, barL_y, bar->w, bar->h );
        blit( bar, buffer, 0, 0, 620, barR_y, bar->w, bar->h );
        /* draw text onto the buffer */
        textprintf_ex( buffer, pongFont, 75, 0, makecol( 0, 0, 0 ),
                       -1, "Left Player Score: %d", scoreL );
        textprintf_ex( buffer, pongFont, 400, 0, makecol( 0, 0, 0 ),
                       -1, "Right Player Score: %d", scoreR );
        blit( buffer, screen, 0, 0, 0, 0, buffer->w, buffer->h );
        clear_bitmap( buffer );
    } /* end while */

    destroy_bitmap( ball ); /* destroy the ball bitmap */
    destroy_bitmap( bar ); /* destroy the bar bitmap */
    destroy_bitmap( buffer ); /* destroy the buffer bitmap */
    destroy_sample( boing ); /* destroy the boing sound file */
    destroy_font( pongFont ); /* destroy the font */
    return 0;
} /* end function main */
Ejemplo n.º 19
0
Sound::Sample::Sample(const Sample& s)
:
    filename     (s.filename),
    sample       (0),
    unique       (s.unique),
    loud         (s.loud),
    quiet        (s.quiet),
    last_was_loud(s.last_was_loud)
{
    sample = load_sample(filename.c_str());
}
Ejemplo n.º 20
0
Sound::Sample::Sample(const std::string& f)
:
    filename     (f),
    sample       (0),
    unique       (true),
    loud         (false),
    quiet        (false),
    last_was_loud(false)
{
    sample = load_sample(filename.c_str());
}
Ejemplo n.º 21
0
//returns a pointer to SAMPLE (char *aFilename) and shows
//error message on failure
SAMPLE *makeSample(char *aFilename)
{
	SAMPLE *samplePointer;
	if (!(samplePointer = load_sample(aFilename)))
	{
      set_gfx_mode(GFX_TEXT, 1024,768,0,0);
		allegro_message("Error! Could not find the file \"%s\"!", aFilename);
		exit(1);
	}
	return(samplePointer);
}
Ejemplo n.º 22
0
static void get_8smp(struct module_data *m, int size, xmp_file f, void *parm)
{
    struct xmp_module *mod = &m->mod;
    int i;

    D_(D_INFO "Stored samples : %d ", mod->smp);

    for (i = 0; i < mod->smp; i++) {
	load_sample(m, f, 0, &mod->xxs[i], NULL);
    }
}
Ejemplo n.º 23
0
Sonido::Sonido(string nombreFichero)
{
    sample = NULL ;
    char buf[256] ;
    replace_filename(buf, Interfaz::Configuracion::GetNombreDirectorio().c_str(), nombreFichero.c_str(), sizeof(buf));
    sample = load_sample(buf);
    
    if ( !sample )
    {
        throw Error::ExcepcionParametro("Graficos::Sonido::Sonido(string)", 1);
    }
}    
Ejemplo n.º 24
0
//default constructor which initializes tiles in order from 1 - 15
TileShop::TileShop()
{
    moves = 0;
    pictures = load_bmp("tiles.bmp", NULL);
    click = load_sample("click.wav");
    for (int i = 0; i < 16; i++)
    {
        tiles[i] = Tile(i, pictures);
    }
    sortTiles();

}
Ejemplo n.º 25
0
Sound::Sample& Sound::Sample::operator = (const Sample& s)
{
    if (&s == this) return *this;
    filename      = s.filename;
    unique        = s.unique;
    loud          = s.loud;
    quiet         = s.quiet;
    last_was_loud = s.last_was_loud;

    if (sample) destroy_sample(sample);
    sample = load_sample(filename.c_str());
    return *this;
}
Ejemplo n.º 26
0
/**
 * Loads a sample from a file, supporting both mono and stereo WAV and
 * mono VOC files, in 8 or 16-bit formats.
 */
static VALUE sample_load(VALUE self, VALUE filename) {
  SAMPLE *sample;

  Check_Type(filename, T_STRING);

  sample = load_sample(STR2CSTR(filename));

  if (!sample) {
    rb_raise(rb_eRuntimeError, "could not load sample");
  }
  
  return Data_Wrap_Struct(c_allegro_sample, 0, destroy_sample, sample);;
}
Ejemplo n.º 27
0
void EffectsManager::initialize()
{
	char filename[] = "DATA/sfx/GAME_0000.wav";
	currentAnnouncer = NULL;
	for ( int i = 0; i < TOTAL_NUM_SFX; i++ )
	{
		filename[14] = (i/1000)%10 + '0';
		filename[15] = (i/100)%10 + '0';
		filename[16] = (i/10)%10 + '0';
		filename[17] = (i % 10) + '0';
		basic_sfx[i] = load_sample(filename);
	}
}
Ejemplo n.º 28
0
static int get_8smp(struct module_data *m, int size, HIO_HANDLE * f, void *parm)
{
	struct xmp_module *mod = &m->mod;
	int i;

	D_(D_INFO "Stored samples : %d ", mod->smp);

	for (i = 0; i < mod->smp; i++) {
		if (load_sample(m, f, 0, &mod->xxs[i], NULL) < 0)
			return -1;
	}

	return 0;
}
Ejemplo n.º 29
0
/***
* Init function
*/
void Initr() {
	int depth, res;
	allegro_init();
	depth = desktop_color_depth();
	if (depth == 0) depth = 32;
	set_color_depth(depth);
	res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0);
	if (res != 0) {
		allegro_message(allegro_error);
		exit(-1);
	}

	install_timer();
	install_keyboard();
	install_mouse();
	
	// Init time counter
	LOCK_VARIABLE(contadorTempo);
    LOCK_FUNCTION(contar_tempo);
    install_int_ex(contar_tempo, BPS_TO_TIMER(30)); // Count time at each 30 FPS
    
    // Init music
    install_sound(DIGI_AUTODETECT,MIDI_AUTODETECT,NULL);
    set_volume(255, 128); // volume setup

    MIDI *mid = load_midi("..\\recursos\\musica.mid");
    play_midi(mid,1);    
    
    // Init SFX
    sompulo = load_sample("..\\recursos\\pulo.wav");
    somponto = load_sample("..\\recursos\\ponto.wav");
    somdano = load_sample("..\\recursos\\dano.wav");
    
    //
    srand(time(NULL));
    
}
Ejemplo n.º 30
0
static bool set_new_sample(struct SoundPlugin *plugin, const wchar_t *filename, int instrument_number, int resampler_type){
  bool success=false;

  Data *data = NULL;
  Data *old_data = plugin->data;

  filename = OS_loading_get_resolved_file_path(filename);
  if (filename==NULL)
    goto exit;

  data = create_data(old_data->samplerate, plugin->data, filename, instrument_number, resampler_type);

  if(load_sample(data,filename,instrument_number)==false)
    goto exit;

  // Put loop_onoff into storage.
  PLUGIN_set_effect_value2(plugin, -1, EFF_LOOP_ONOFF, data->loop_onoff==true?1.0f:0.0f, PLUGIN_STORED_TYPE, PLUGIN_STORE_VALUE, FX_single, PLAYERLOCK_NOT_REQUIRED);

  if(SP_is_plugin_running(plugin)){

    PLAYER_lock();{  
      old_data->new_data = data;
    }PLAYER_unlock();

    if (PLAYER_is_running())
      RSEMAPHORE_wait(old_data->signal_from_RT,1);

  } else {

    plugin->data = data;

  }

  delete_data(old_data);

  update_peaks(plugin);

  volatile struct Patch *patch = plugin->patch;
  if(patch!=NULL)
    GFX_update_instrument_widget((struct Patch*)patch); // Update "loop" button.

  success = true;

 exit:
  if(success==false)
    free(data);

  return success;
}